Building a Mac and Windows GUI Application
Asked Answered
P

2

15

I am planning to build a GUI application for Mac and Windows. I've been doing some research in the technology choices, as in the language, libraries, and build tools, so that I can share as much code as possible between the two platforms.

The main requirements are:

  1. Meets the Mac App Store requirements.
  2. Native look and feel on both Mac and Windows.
  3. Need to call into Quartz Window Services on Mac and the Windows API on Windows.
  4. Store and read data using SQLite.

The length of my post has gotten out of control, so I moved my questions to the top as a summary, while the context is further below.

Questions

  1. I am leaning toward using Python for the ease of programming. Is this the right choice for me? If not why would C++ be better? And if so, how exactly do I get py2app and pyobjc set up to compile the python and build a standalone app that loads XIBs for GUI?
  2. Am I right that I should not use cross-platform GUI libraries on Mac for the sake of a more native interface? Or would I be better off using QT or wxWidgets?
  3. If I am going down the wrong path and/or there are better solutions that I have not considered, please point them out :)

My research and conclusions so far

GUI libaries

For Mac, I ruled out using cross-platform GUI libraries (like QT) since it doesn't seem like they are able to provide a native look and feel on Mac (look out of place and/or difficult to write apps that follow Apple's Human Interface Guidelines). wxWidgets says it uses native libraries, but this post mentions that wxPython may use private Objective-C calls and is unlikely to be approved for the Mac App Store. Finally, even if the look is right, layouts would probably still need to vary for the two platforms.

Therefore I plan to use native Cocoa GUI libraries for the Mac interface, though still considering using wxWidgets for the Windows GUI.

Language

It seems my best choices for language for the main application logic be either C++ or Python. Obviously it's much easier to write cross-platform code with Python than C++, but there are always tradeoffs.

Python

Pros: Much quicker to write and easier maintain. Robust cross-platform libraries that can shorten development time drastically.

Cons: Using Python means using PyObjC, which hasn't been updated in over a year (as seen from svn), and it's unclear to me whether it will still work with future versions of Xcode and OSX. Also, to set up any sane build configuration with PyObjc and py2app and use xibs for GUI, outside of Xcode, is a nightmare.

C++

Pros: Easier to set up the build configuration and dependencies on both Mac and Windows. Runs much faster than Python, though performance isn't a large concern in my case.

Cons: I don't know C++. I'm pretty good with C, but it doesn't look like that will help me much at writing good C++. I have a general impression that it's much harder to write cross-platform C++, but I might be wrong. There are lots of posts about obscure bugs. Boost looks promising though.

Build tools

Setting things up if using C++ as the main language seems simple enough on both platforms. If I use Python, it also seems simple to set up on Windows since I would use wxWidgets for the GUI and py2exe to deploy.

As for Mac and Python, the standard choice seems to be pyobjc and py2app. Unfortunately, I haven't been find any examples of a build configuration with py2app that uses XIBs and Cocoa libraries rather than QT or wxWidgets. I don't want Xcode to manage the build since I would prefer the Python files and application resources be placed outside of the Xcode project directory. This would greatly simplify the setup for Windows and make the file tree cleaner.

Edit regarding QT: I took another look at QT, spending a couple of hours playing with QT designer. The basic UI elements (button, textfield, label) look the same as Cocoa elements. I put together a QWindow and a QTabView with some elements easily, and it looks like a Cocoa app. However, there were a few negatives:

  • Behavior's a little off, like lack of elastic scrolling, QTextEdit doesn't have the blue shadow indicating focus.
  • QTableView doesn't look much like its Cocoa counterpart.
  • Spacing between elements, spacing to parent view, do not follow guidelines. It's mostly fixable by tweaking the layouts, but needs to be done everywhere and I'd get it with Xcode for free.
  • Missing the HUD element for making the inspector. This is something I would very likely need in my app, at least for the Mac side.
  • Poor accessibility support.

I know I'm being picky but need to be picky to make a good UI. Overall QT seems to be a good solution for Windows, but I think I will stick to Cocoa for Mac. I did some additional research into existing programs and found that VLC, Chrome, and Transmission all make native GUIs for Mac, while VLC uses QT for Windows, Chrome uses a custom framework, and Transmission uses GTK+ and QT for Linux.

I think I've decided on using Cocoa GUI for Mac and Qt or wxWidgets for Windows, but still split between C++ and Python for the shared logic.

Phonogram answered 14/6, 2012 at 4:10 Comment(13)
Another option MonoMac mono-project.com/MonoMac tirania.org/monomac/archive/2011/Jan-31.html. From my understanding you'd write the front-end code twice - once for windows, once for mac. But get to share a lot of code, and get native UIs on both.Cardew
If you need Mac AppStore compatibility, why you are even considering python?Carpous
@jdi: According to this (#4940773), it's possible to deploy a Python app to the Mac AppStoreHereafter
@EmileCormier: He also says he wouldn't recommend it :-) but its really interesting to know its possibleCarpous
@EmileCormier I actually link (it's a little hidden) to a different answer on that same post, which may rule out wxPython for Mac, but yeah his recommendation not to use this for new projects shook my faith in Python.Phonogram
@Cardew Mono looks interesting, though I don't see the benefit of me learning C# to use it versus learning C++. Also biased against Microsoft :pPhonogram
@Woody maybe we should all be learning javascript! hewgill.com/~greg/stackoverflow/stack_overflow/tags/…Cardew
@Woody : Thanks for reporting on your experience with Qt on Mac. This will help other developers decide if Qt is right for them on that platform.Hereafter
@Woody : Once you settle on a decision on C++ vs Python, you should answer your own question and indicate what you ended up doing in the answer. That'll mark the question as being resolved, and it'll help you avoid having a low acceptance %.Hereafter
@Woody I'm curious, what was your decision? I know it's been a year but I'd gladly hear what are your thoughts on this after so much time.Vines
@dccarmo I meant to write down my choice like Emile suggested but couldn't really find a perfect solution or strong reasons why anyone else should follow my choices. It will depend on your resources, experience, and requirements. I went with native for Mac and wxWidgets for Windows as I wrote in my question.Phonogram
What language did you decide on? And, honestly, I'm biased against MS too, but C# is pure awesome.Selves
@Selves I ended up going with Python, using PyObjc for mac and py2exe on Windows. The setup is quite nontrivial...Phonogram
P
3

I ended up going with Python for shared logic.

On Mac, I used py2objc as the bridge, and py2app with some custom configuration for packaging. On Windows, I used Python and wxWidgets directly.

This allowed me to have native UIs on both platforms, and worked out quite nicely for lower level code.

However, I didn't actually get very far on the app before moving on to more exciting ventures. If any readers were hoping to use this question/answer as a reference, I strongly suggest looking at all the technologies listed and drawing your own conclusions.

Phonogram answered 12/9, 2013 at 0:21 Comment(0)
H
10

I think you might be ruling out Qt too quickly. This guy has reported that he publishd a Qt-based app on the Mac App Store.

According to this related answer, you can specify the Qt build target to use Cocoa instead of the deprecated Carbon API.

This Qt bug where some plist file would be written a location not approved by Apple has been resolved in version 4.8.

This Qt article discusses special features introduced to support Mac's native look and feel.


With regards to C++, there are generally no cross-platform issues if you use libraries such as Qt or Boost to abstract out the platform-dependent bits (Boost.Asio, Boost.Filesystem, and Boost.Thread come to mind, Qt has similar abstractions for networking, files, and threading).

C++ is definitely an "expert friendly" language. If it's possible to use Python and PySide bindings for Qt, while still being able to publish to the App Store, then I'm guessing that might be your best bet.

If you end up using C++, then I strongly suggest that you learn to use all the facilities at your disposal which will minimize manual memory management and raw pointers. Learn about container classes, string class, and smart (reference-counting) pointers.

Hereafter answered 14/6, 2012 at 4:44 Comment(4)
I voted this up because I am not sure where you would get a more cross platform GUI solution that is Mac AppStore capable. There are so many trade offs from what the OP said, but if he sticks to C++ then this seems like the thing.Carpous
My main concern with QT is whether I'll be able to successfully create usable GUI application that follows the Mac Human Interface Guidelines. The screenshots on the article you linked appear to be from tiger. Looks like I have to try QT and see for myself. It is nice to know it can also build against Cocoa though. Do you know of any QT apps on Mac that have good UI?Phonogram
I suggest that you try writing a prototype Qt app with all the UI elements you think you will need, and check that it meets the guidelines. This prototype app should be "dumb" without any business logic behind it. Good luck, and please let us know if you find anything in Qt that violates the guidelines.Hereafter
Just spent a couple of hours playing with QT. Added my conclusions to the question.Phonogram
P
3

I ended up going with Python for shared logic.

On Mac, I used py2objc as the bridge, and py2app with some custom configuration for packaging. On Windows, I used Python and wxWidgets directly.

This allowed me to have native UIs on both platforms, and worked out quite nicely for lower level code.

However, I didn't actually get very far on the app before moving on to more exciting ventures. If any readers were hoping to use this question/answer as a reference, I strongly suggest looking at all the technologies listed and drawing your own conclusions.

Phonogram answered 12/9, 2013 at 0:21 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.