How to distribute a python Tkinter GUI from one Mac to another
-
I've been writing python software with Tkinter GUIs as a hobby for a while, but for the first time, I've made a some pieces of code that a few other people want to use. Unfortunately, I've been really frustrated by attempts to distribute the software because of incompatibility with Tcl/Tk installations on computers I'm distributing the software to. I'm on a Mac, and I'm distributing to other Macs at this point. I've been using py2app to bundle the code, and I can easily get the apps to run on my machine, but it seems like the slightest version mismatch between the Tkinter that gets bundled and the Tcl/Tk version on the destination machine causes a fatal error. For example, I have tk 8.6.0 installed, abd Tkinter 2.7.3, but the .app that I made wouldn't run on a machine that had tk 8.5.12. It has worked on a computer where the Tcl/Tk installation matched mine, but I obviously can't guarantee that will be the case all the time. Here's are my related questions: 1. Is there a way to somehow include Tcl/Tk with the py2app bundle so it doesn't depend on the destination machine having the right version? 2. Is there instead a good way to include multiple versions of Tkinter and have software attempt to import each of them until one of them is found to work? 3. Should I give up on doing this with Tkinter? Is there a GUI framework that is more "portable"? I know wxPython is not pure python either, so does that suffer the same issues? 4. Or am I asking the wrong questions here?
-
Answer:
I know nothing about the app bundles that py2app creates, but on OSX you can include Foo.framework inside the application bundle and use it in preference to any other version of the framework present on your system. Can you get py2app to pull required frameworks in to the final bundle to avoid any versioning issues?
Salvor Hardin at Ask.Metafilter.Com Visit the source
Other answers
*nix systems are absolutely insane about compatibility and dependencies. You'd think that one version of software from the next would be more or less compatible, but they aren't. In the Linux world, most of the package managers have a way for software to specify what its dependancies are. In Fedora, if I do "yum install package" it figures out what other software the new package depends on and asks if it can install those for you. I would expect that a .app would have a similar function, but how it works I don't know. Short of that, you have to just document what versions people have and make them install what is required.
gjc
Have you thought about using Cocoa if it's for macs?
empath
You could use an application like http://s.sudre.free.fr/Software/Packages/about.html (easy, free, GUI) or Apple's http://stackoverflow.com/questions/11487596/making-os-x-installer-packages-like-a-pro-xcode4-developer-id-mountain-lion-re/11487658#11487658 (more difficult, also free, CLI) to bundle your scripts together with Tcl/Tk .framework files that match your version requirements. Your installer places the frameworks in a folder of your choice (e.g., in /Library/Frameworks or ~/Library/Frameworks) where your Python scripts are directed to import them.
Blazecock Pileon
If OSX ships with a version of Tcl/Tk/Tkinter you should develop with that one. And the best you can hope for is that if a machine has a newer version that the newer version has kept backwards compatibility with the older version. With the X.Y.Z http://semver.org/ you could hope that something built against X.Y.Z would work with X.Y.Z-1 or X.Y.Z+1 apart from any minor bugs you run into. In theory the API should stay the same across X.Y.*. If you're lucky a program built against X.Y.Z will work with X.Y+1.Z because X.Y+1 kept support for the older X.Y API. If you build against X.Y and try to run against X.Y-1, it will probably fail miserably. You may be able to build the GUI modules statically or somehow have your libraries packaged up with your app, but that sometimes leads to even more pain. Your Tcl/Tk/Tkinter build may need a certain version of some PNG or JPG or other library that is on your system and then that library will happen to be the one that the target system has a different version of. Does Python not have some sort of module dependency/packaging thing where you build your app and just have it declare that it needs the Tk modules and let the package manager install the appropriate Tk modules before installing your app? If you do it that way won't your app install the same on OSX/Windows/Linux without you having to worry about which versions of libraries are installed?
zengargoyle
Definitely try to include any frameworks within your app bundle. You may also benefit from building your app on an older version of OS Xâforwards compatibility tends to be a lot better than backwards. Feel free to add more details, or to memail me. I have quite a bit of experience building things on OS X, and wouldn't mind helping.
vasi
Thank you all for the advice - when I get a chance, I'll be looking into how to include the Tcl/Tk framework in the app bundle. If that doesn't work, I'll try using Packages. I'll report back. empath - Thanks for pointing out PyObjC. I didn't do a very good job keeping the backend and frontend separate in this project, so it would be a significant undertaking to pull out the Tkinter and replace it with Cocoa, but I should probably start with Cocoa for the next project. Thank you!
Salvor Hardin
Related Q & A:
- How to update a python package?Best solution by Stack Overflow
- how to call a function in Python in another function?Best solution by Yahoo! Answers
- How do I transfer my iTunes library from one computer to another?Best solution by Yahoo! Answers
- How do I forward my Yahoo! messages from one account to another?Best solution by Yahoo! Answers
- How to connect a printer to more then one computer?Best solution by Yahoo! Answers
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.