Python GUI App Distribution: written in wxPython, TKinter or QT - python

My question is about the easiness of distributing the GUI app across the platforms (Mac/Linux/Windows), and I want to know the one that makes the user's job easiest.
My current understanding is that Tkinter app is the easiest for the users (to install) because as long as the user has installed a Python in her box, my application should be ready to run on that box.
For GUI app written in wxPython or pyQT, the user needs to install wxWidget or QT in her box first, which is an extra step, and then install my GUI app. (But my Ubuntu box seems to have the wxWidget libraries and QT libraries installed by default, is that a norm or just Ubuntu distro is more friendly to users? I guess Windows and Mac probably does not provide them by defualt, ie. the users need to download and install them as an extra step)

If you're running Ubuntu, PyQt will be installed by default. Most linux distros will have one of PyGtk or PyQt installed by default. WxPython was most likely installed in your Ubuntu box as a dependency for some other package in your system.
If your target market is Linux, you can just create a deb or rpm package and that'll take care of the dependencies for your application.
For Windows and Mac(and even Linux if you're so inclined) you could bundle the python interpreter with your application and its libraries into a native executable format such
as .exe, .dmg or .elf using libraries like cx_freeze, py2exe and py2app. Once this is done, your user will not have to install python or any of your libraries.

Tkinter is the only one that's included with Python. wxPython and pyQT need both the wxWindows or QT libraries and the wxPython or pyQT libraries to be installed on the system.
However, Tk does not look very nice. If you're already making the user install Python, you could just as well have them install the libraries too. (Or maybe include an installer or something.)

If the app is going to be cross-platform I would suggest WxWidgets (wxpython). I have used it several times and it has never been a problem.
Nevertheless, you should create different installers for Windows, Mac and Linux. In Linux, use .deb or .rpm to take care of dependencies.
In Windows, I've always used py2exe to create an exe file. Py2exe works by attaching the python interpreter and the needed libraries, in this case wxWidgets.
Check this link for more information: http://www.py2exe.org/

Related

GUI apps in python 3.4

I've been looking for a GUI system for python applications for a while and have found these 2, Tkinter and PyQT. The issue I'm having is that I cannot work out whether PyQT requires the end user to have QT installed and whether Tkinter will work properly on another computer as I have read a lot about it being touchy when it comes to Tk/Tcl version.
What I'm trying to do with it is create an application for a friend so that he can keep track of his beehives more easily and I didn't think that having it in a terminal would be the way to go. Thanks.
I have worked with both in the past and from my observations:
whether PyQT requires the end user to have QT installed
Yes, it does. However you can bundle your app along with the dependencies (Python + QT) using tools like PyInstaller. You will get a single package that you can distribute to your users. They can run it without installing anything.
You can also create custom installers which install Python and QT on the target systems for you. Then the users can just run the Python script.
whether Tkinter will properly on another computer as I have read a lot
about it being touchy when it comes to Tk/Tcl version
I have never faced any issues with it since I mostly deployed my Tkinter apps to Windows and I installed the same version of Python on the target systems that I used to develop. However, there might be version conflicts on other platforms (eg. Linux/OS X).
What I'm tying to do with it is create an application for a friend so
that he can keep track of his beehives more easily
Have you thought about web based GUI? A python script running a webserver on a local machine? You can use the "webbrowser" module to open up a browser to load the url when the script is run.
There is another alternative: Kivy.

Do Frozen PyQt applications need the Qt to be installed on client machines

I am new to Qt and developing with python.
Would a python application developed using Qt framework and PyQt require the entire Qt framework to be installed on a user's machine in order to run a "exe" version of the application created with something like p2exe? Or would py2exe copy the required Qt framework components into the application that it creates?
I don't know what you mean by "frozen" but if your question is whether you can create an "exe" for a pyqt python script without installing python and pyqt on user machine then answer is yes. As with any other exe you don't need to install anything on user machine.
I have created a few application using pyqt and converted them to exe using pyinstaller-2.0 and it works fine on any machine. Same is true with py2exe.
Py2exe, when used with PyQt, will only copy the basics needed to get a Qt application to run. It won't copy the plugins that likely need. You need to take extra steps to install whatever image, platform, phonon, multimedia, etc. plugins you may need.
By basics I mean it will install the directly linked libraries from the Qt framework. Qt consists of a bunch of libraries. Some of those are linked directly into any executable using them (like the PyQt library), some of them are plugins. Py2exe will not copy those plugins, since it generally has no way of knowing which ones you may need. You need to let Py2exe know about the plugins your application requires: add them to the configuration file (setup.py).
No need for further install.
e.g. Py2exe will copy everything needed.
If you have some special requirement you may have to copy other stuff manually. In my application I copy some extra ddls, some ico files and some matplotlib files.

How to install a multipart python program on Mac?

Finally making a legitimate mac installer for my product. I've made a successful Windows installer with Inno installer. I'm not sure how to do this in Mac.
This must happen:
-Python is installed
-Wx is Installed
-Py Serial is installed
-Program is copied
-Shortcut is made.
I was doing this with Bash scripts before, but my customers having been complaining about those. Perhaps X-code package maker is the solution? I know the recommended method is "just copy files" but these libraries must be installed somehow.
Thanks in advance!
Unless I am using Fink for installing packages, I usually just download the .tar.gz file from the source and install it from terminal inside the unzipped folder containing the install.py file. Terminal command:
sudo python ./setup.py install
If you would like, I can show you how to set up and use Fink, which is another easy way to install packages / libraries.
tl;dr: py2app will make a self-contained application bundle out of your Python scripts, making it real easy to employ the 'just copy files' installation process. The libraries you need are bundled into the app bundle itself, so they don't need to be installed systemwide.
Also check out Optimizing for Mac OS X from the wxPython wiki; it gives good tips on using py2app and other useful information on building a Mac-friendly Python application.
On OS X, programs are generally installed through one of three ways: the Mac App Store, a package installer (.pkg/.mpkg), or a copyable application bundle on a disk image (.app in a .dmg). Each has its strengths and weaknesses.
The Mac App Store requires that you subscribe to Apple's restrictions and requirements, and may be a good choice for apps expecting wider distribution (though, nowadays, it can be a good way to reach that wider audience easily). Copyable application bundles are by far the simplest installation method pre-App Store, and still remain one of the more popular ways to install programs. Finally, an Installer package is a user-friendly way to install more complex programs requiring more than a simple application bundle (e.g. system services, files in particular directories, system-dependent components, advanced installation logic, etc.). I should note, though, that do exist complex applications which ship as application bundles and perform the bulk of their 'installation' at first run.
My experience with the Mac App Store is limited, so I won't talk about it. You can find more details at the official website.
Python is quite amenable to being shipped as an application bundle. You can use py2app to automatically create an application bundle for the program, and then drop that bundle into a Mac disk image (.dmg) using Disk Utility to create a complete installation package. This doesn't support making shortcuts, but on OS X it is much more usual for users to just drop the app into /Applications and make the necessary dock shortcut themselves if they want.
The next way is to make a metapackage (.mpkg) which will be installed using the OS X standard Installer utility. This is in line with what users will expect from a Mac application. IIRC, both Mac Python and wxPython ship as .pkg already, which should make it easier to integrate them into a metapackage. bdist_mpkg can help with making packages for pyserial and your own program, which can be added to the metapackage. Finally, using the third-party dockutil script, you can automatically add a dock shortcut. Note, however, that installers generally do not add shortcuts to the dock; it is more usual to have a program installed to the /Applications directory.`

pyqt4 programs, how to make installer for win

I've written an application in pyqt4. It is working in linux and i guess it should work in windows without any changes (there is nothing system specific). I'd like to make an installer for windows, so windows users doesn't have python and pyqt on their systems before.
So is there any way to do it?
Use PyInstaller. It handles packaging for Windows, Linux and OS X. For an example of a packaged Qt4 application using PyInstaller, see logview.

Can I convert my python script to a .app?

Is it possible to convert my .py script to a .app that works through a text box or something?
Thanks
Try py2app.
py2app is a Python setuptools command which will allow you to make
standalone application bundles and plugins from Python scripts. py2app
is similar in purpose and design to py2exe for Windows.
Because this is a vague question, I will provide a general answer.
You need to decide on a GUI framework. There are a number of them to choose from.
PyQt4
http://qt.nokia.com/products/
http://www.riverbankcomputing.co.uk/software/pyqt/download
PySide (LGPL version of PyQt4) - http://www.pyside.org/
GTK - http://www.pygtk.org/
wxPython - http://www.wxpython.org/
TkInter
http://wiki.python.org/moin/TkInter
You could even write a web interface that communicates with your python script via RPC or an HTTP rest interface. Take your pick!
My vote is on PySide/PyQt. Its very flexible and easy to use.
At that point you would then use something like py2app to package up the entire environment into a standalone .app that can be distributed.
You can also use the cross-platform pyinstaller, which is more modern and I've had a good experience with.
sudo pip install pyinstaller
pyinstaller myprogram.py --windowed
There's a lot more configuration if you want to go cross platform, but this may get you started:
http://pythonhosted.org/PyInstaller/#building-mac-os-x-app-bundles
This creates the distrutable. From there I use things like Inno Setup on windows or app2dmg for mac.

Categories