Are there an GUI libraries for Python that allow you to compile to an EXE (windows) and APP(Mac)?
I'm working on an application that I need to be cross-platform. I'd like to use Python for it, and am looking for开发者_开发问答 GUI toolkits that make interface programming simple and easy. After a slight hunt, I found PythonCard. This looks like it fits the bill perfectly, but I'm not sure if it will be possible to compile this down to an appropriate executable for each operating system. I found these instructions, but they're 6 years old.
Whatever solution I choose must support the following:
- Write one GUI to work on both Windows and Mac OSX
- Must 'compile' into an easily distributable file for both windows/mac
- Compiled file must not require Python to be installed on the users computer
Can anyone recommend a library/solution before I have to wade into the desolate world of Java?
I think the answer here is less about the particular GUI toolkit and more about distributing stand-alone python applications. Personally, I've found the tools for this a little less perfect than I'd like but, after some finagling, they get the job done. The most likely candidate that'd fit your needs is cx_Freeze. Though there's a Windows specific py2exe and Mac specific py2app that might fill the bill if cx_Freeze is insufficient.
Use PyInstaller to distribute an app using PyQt or WxPython gui toolkits. From the website:
PyInstaller is a program that converts (packages) Python programs into stand-alone executables, under Windows, Linux, and Mac OS X.
As for gui toolkits, PyInstaller is documented to work with Qt3, Qt4, and WxPython.
StackOverflow contributor dF, uses PyInstaller "for an app which depends on PyQt, PyQwt, numpy, scipy and a few more."
Hmm.
Maybe it'd better to move my post to comments, but. Why do you want to 'compile' python code, and why do you think that some GUI framework should provide some packaging/installation facilities?
In our company we wrote cross-platform GUI app and of course we must make it easily deliverable for customers. So, we found suitable GUI framework with python bindings (Qt), then we chosen the method to hide unneeded details about realisation and vanish dependancies (Py2Exe for Windows, Py2App for Mac, and nothing for linux, but you can try PyInstaller or cx-freeze).
Installation for every OS made in that OS' way, according to the least astonishment principle. That's why we did not pack linux version in some kind of binary executables.
If you want your application to look and feel native, then wxPython is the way to go. PyQt can look native, but it doesn't sound like it always behaves in a native way (according to some threads I've read). To build binaries, use py2exe or some such for Windows and py2app for Mac
This presentation walks through the process and also winds up with Py2exe and Py2app...
For Wxpython GUI designers check this question. I breifly tried boa-contstructor but I found it too limiting -as not all widgets are supported. AFAIK none of the wxpython designers support all widgets (out of the box atleast).
I personally find it faster and easier to hand code my GUI's. Id say it only took me a few days to become reasonably comfortable/familar wxpython. If you need to do anything other then creating a simple application then taking a little bit of time to learn wxpython will pay its dividends.
If your bound to the idea of having a descent GUI designer then your best bet is probabaly PyQt as this IMHO is the only toolkit that has a solid mature editor -Qt Designer
As for creating standalone excutables Ive only used py2exe for windows. py2app does the same for mac although I have not tried that yet.
For windows installers checkout this thread
精彩评论