title: Building a Mac and Windows GUI Application
body: <p>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.</p>
  <p><strong>The main requirements are:</strong></p>
  <ol>
  <li>Meets the Mac App Store requirements.</li>
  <li>Native look and feel on both Mac and Windows.</li>
  <li>Need to call into Quartz Window Services on Mac and the Windows API on Windows.</li>
  <li>Store and read data using SQLite.</li>
  </ol>
  <p>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.</p>
  <h2>Questions</h2>
  <ol>
  <li>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?</li>
  <li>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?</li>
  <li>If I am going down the wrong path and/or there are better solutions that I have not considered, please point them out :)</li>
  </ol>
  <h2>My research and conclusions so far</h2>
  <h3>GUI libaries</h3>
  <p>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 <a href="https://stackoverflow.com/a/4999048/1448071">post</a> 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.</p>
  <p>Therefore I plan to use native Cocoa GUI libraries for the Mac interface, though still considering using wxWidgets for the Windows GUI.</p>
  <h3>Language</h3>
  <p>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.</p>
  <p><strong>Python</strong></p>
  <p><em>Pros:</em> Much quicker to write and easier maintain. Robust cross-platform libraries that can shorten development time drastically.</p>
  <p><em>Cons:</em> 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.</p>
  <p><strong>C++</strong></p>
  <p><em>Pros:</em> 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.</p>
  <p><em>Cons:</em> 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.</p>
  <h3>Build tools</h3>
  <p>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.</p>
  <p>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.</p>
  <p><strong>Edit regarding QT:</strong> 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:</p>
  <ul>
  <li>Behavior's a little off, like lack of elastic scrolling, QTextEdit doesn't have the blue shadow indicating focus.</li>
  <li>QTableView doesn't look much like its Cocoa counterpart.</li>
  <li>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.</li>
  <li>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.</li>
  <li>Poor accessibility support.</li>
  </ul>
  <p>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 <a href="http://wiki.videolan.org/Interfaces" rel="noreferrer">VLC</a>, <a href="https://stackoverflow.com/questions/874609/which-gui-library-does-google-chrome-use">Chrome</a>, and <a href="http://www.transmissionbt.com/" rel="noreferrer">Transmission</a> 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.</p>
  <p>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.</p>