Can you make a universal python application that will run on both OSX and Windows? With the same menu system, etc? Or would you need to make different versions for each OS?
-
When you say "Menu system" do you have windows - based app in your mind?OnesimusUnbound– OnesimusUnbound2011年08月04日 14:54:10 +00:00Commented Aug 4, 2011 at 14:54
-
3possible duplicate of Cross-platform gui toolkit for deploying Python applicationsagf– agf2011年08月04日 14:54:14 +00:00Commented Aug 4, 2011 at 14:54
-
wxPythonOnesimusUnbound– OnesimusUnbound2011年08月04日 15:23:39 +00:00Commented Aug 4, 2011 at 15:23
5 Answers 5
I have built several cross platform applications (Windows / OS X) with wxPython. Practically all of the code translates flawlessly across the two platforms. To put into context, I usually develop the applications on Mac OS side, and if I spend let's say one week hammering out an application, I spend something like a few hours to get it running nicely in Windows.
Usually those hours consist of:
- Tweaking minor wxPython visuals (font sizes, colors)
- Making nice things like embedded icons
- Keyboard shortcuts (CMD vs CTRL)
- Main menu
Like you correctly point out, if you want identical main menus you have some work ahead of you on OS X side. I myself have never really bothered, I am fine with having some additional OS X default main menu bits and pieces.
The main menu thing aside though, considering how little tweaking you have to do, I'd say wxPython is the way to go. Together with px2exe on Windows side and py2app on OS X side it packs quite the punch.
Comments
Yes. You could build it with Qt for its interface and then you'll have to make judicious use of the os library to make sure that everything plays nicely no matter what operating system it's running on. However when it comes to packaging it for distribution, you'll have to do them separately. For Windows you can use py2exe, which will build a binary package which bundles in the Python runtime and all the libraries you use. I'm not sure how it works in Mac though.
Comments
You can try some of cross-platform tools e.g. Appcelerator Titanium Desktop supports python based development.
Comments
I'm currently developing an app on my Ubuntu Linux machine. I real life it runs on a windows xp machine with touchpad.
I'm using wxPython as the gui toolkit. In the past I've used .net predominantly but I wanted cross platform.
It really runs without any checks about which os it is running on. (save one check where i read a textfile and i have some trouble with the line endings)
Comments
To add on to what has already been given ...
If you rely on any os.system calls, you could also run into places where your code needs to handle the different platforms, well, differently.
As an example, I have an application which has a Help menu option which opens up a pdf file. My code would be like:
if arch.find("indows"):
os.system("start " + help_filename)
elif arch.find("inux"):
os.system("xdg-open " + help_filename)
else: # really this is the Mac case
os.system("open " + help_filename)