<p>Python works on multiple platforms and can be used for desktop and web applications, thus I conclude that there is some way to compile it into an executable for Mac, Windows and Linux.</p>

<p>The problem being I have no idea where to start or how to write a GUI with it, can anybody shed some light on this and point me in the right direction please?</p>

[{'answer_id': 2937, 'author': 'lubos hasko', 'author_id': 275, 'author_profile': 'https://Stackoverflow.com/users/275', 'pm_score': 9, 'selected': True, 'text': '<p>First you will need some GUI library with Python bindings and then (if you want) some program that will convert your python scripts into standalone executables.</p>\n\n<p><strong>Cross-platform GUI libraries with Python bindings (Windows, Linux, Mac)</strong></p>\n\n<p>Of course, there are many, but the most popular that I\'ve seen in wild are:</p>\n\n<ul>\n<li><a href="http://wiki.python.org/moin/TkInter" rel="noreferrer">Tkinter</a>  - based on <a href="http://www.tcl.tk/" rel="noreferrer">Tk GUI toolkit</a> (de-facto standard GUI library for python, free for commercial projects)</li>\n<li><a href="http://www.wxpython.org/" rel="noreferrer">WxPython</a> - based on <a href="http://www.wxwidgets.org/" rel="noreferrer">WxWidgets</a> (popular, free for commercial projects)</li>\n<li><a href="https://www.qt.io" rel="noreferrer">Qt</a> using the <a href="https://riverbankcomputing.com/software/pyqt/intro" rel="noreferrer">PyQt bindings</a> or <a href="https://www.qt.io/qt-for-python" rel="noreferrer">Qt for Python</a>. The former is not free for commercial projects. The latter is less mature, but can be used for free.</li>\n</ul>\n\n<p>Complete list is at <a href="http://wiki.python.org/moin/GuiProgramming" rel="noreferrer">http://wiki.python.org/moin/GuiProgramming</a></p>\n\n<p><strong>Single executable (all platforms)</strong></p>\n\n<ul>\n<li><a href="https://www.pyinstaller.org/" rel="noreferrer">PyInstaller</a> - the most active(Could also be used with <code>PyQt</code>)</li>\n<li><a href="https://build-system.fman.io" rel="noreferrer">fbs</a> - if you chose Qt above</li>\n</ul>\n\n<p><strong>Single executable (Windows)</strong></p>\n\n<ul>\n<li><a href="http://www.py2exe.org/" rel="noreferrer">py2exe</a> - used to be the most popular</li>\n</ul>\n\n<p><strong>Single executable (Linux)</strong></p>\n\n<ul>\n<li><a href="http://wiki.python.org/moin/Freeze" rel="noreferrer">Freeze</a> - works the same way like py2exe but targets Linux platform</li>\n</ul>\n\n<p><strong>Single executable (Mac)</strong></p>\n\n<ul>\n<li><a href="https://pythonhosted.org/py2app/" rel="noreferrer">py2app</a> - again, works like py2exe but targets Mac OS</li>\n</ul>\n'}, {'answer_id': 2941, 'author': 'Justin Standard', 'author_id': 92, 'author_profile': 'https://Stackoverflow.com/users/92', 'pm_score': 1, 'selected': False, 'text': '<p>You don\'t need to <em>compile</em> python for Mac/Windows/Linux.  It is an interpreted language, so you simply need to have the Python interpreter installed on the system of your choice (it is available for all three platforms).</p>\n\n<p>As for a GUI library that works cross platform, Python\'s <a href="http://www.tcl.tk/" rel="nofollow noreferrer">Tk/Tcl</a> widget library works very well, and I believe is sufficiently cross platform.</p>\n\n<p><a href="http://docs.python.org/lib/module-Tkinter.html" rel="nofollow noreferrer">Tkinter</a> is the python interface to Tk/Tcl</p>\n\n<p>From the python project webpage: </p>\n\n<blockquote>\n  <p>Tkinter is not the only GuiProgramming\n  toolkit for Python.  It is however the\n  most commonly used one, and almost the\n  only  one that is portable between\n  Unix, Mac and Windows</p>\n</blockquote>\n'}, {'answer_id': 2980, 'author': 'Matthew Schinckel', 'author_id': 188, 'author_profile': 'https://Stackoverflow.com/users/188', 'pm_score': 3, 'selected': False, 'text': '<p>Since python is installed on nearly every non-Windows OS by default now, the only thing you really need to make sure of is that all of the non-standard libraries you use are installed.</p>\n\n<p>Having said that, it is possible to build executables that include the python interpreter, and any libraries you use.  This is likely to create a large executable, however.</p>\n\n<p>MacOS X even includes support in the Xcode IDE for creating full standalone GUI apps.  These can be run by any user running OS X.</p>\n'}, {'answer_id': 12166, 'author': 'Michael Twomey', 'author_id': 995, 'author_profile': 'https://Stackoverflow.com/users/995', 'pm_score': 4, 'selected': False, 'text': '<p>An alternative tool to py2exe is <a href="http://pypi.python.org/pypi/bbfreeze/" rel="noreferrer">bbfreeze</a> which generates executables for windows and linux. It\'s newer than py2exe and handles eggs quite well. I\'ve found it magically works better without configuration for a wide variety of applications.</p>\n'}, {'answer_id': 12167, 'author': 'Brian Warshaw', 'author_id': 1344, 'author_profile': 'https://Stackoverflow.com/users/1344', 'pm_score': 2, 'selected': False, 'text': '<p>I\'m not sure that this is the best way to do it, but when I\'m deploying Ruby GUI apps (not Python, but has the same "problem" as far as .exe\'s are concerned) on Windows, I just write a short launcher in C# that calls on my main script. It compiles to an executable, and I then have an application executable.</p>\n'}, {'answer_id': 15938, 'author': 'fulmicoton', 'author_id': 446497, 'author_profile': 'https://Stackoverflow.com/users/446497', 'pm_score': 3, 'selected': False, 'text': '<p>For the GUI itself:</p>\n\n<p><a href="http://wiki.python.org/moin/PyQt" rel="noreferrer">PyQT</a> is pretty much the reference.</p>\n\n<p>Another way to develop a rapid user interface is to write a web app,\nhave it run locally and display the app in the browser.</p>\n\n<p>Plus, if you go for the Tkinter option suggested by lubos hasko\nyou may want to try portablepy to have your app run on Windows environment\nwithout Python.</p>\n'}, {'answer_id': 31859, 'author': 'Jamie', 'author_id': 3363, 'author_profile': 'https://Stackoverflow.com/users/3363', 'pm_score': 6, 'selected': False, 'text': '<p>Another system (not mentioned in the accepted answer yet) is PyInstaller, which worked for a PyQt project of mine when py2exe would not. I found it easier to use.</p>\n\n<p><a href="http://www.pyinstaller.org/" rel="noreferrer">http://www.pyinstaller.org/</a></p>\n\n<p>Pyinstaller is based on Gordon McMillan\'s Python Installer. Which is no longer available.</p>\n'}, {'answer_id': 265570, 'author': 'Tofystedeth', 'author_id': 31801, 'author_profile': 'https://Stackoverflow.com/users/31801', 'pm_score': 4, 'selected': False, 'text': '<p>There\'s also <a href="http://pygtk.org/" rel="noreferrer">PyGTK</a>, which is basically a Python wrapper for the Gnome Toolkit.  I\'ve found it easier to wrap my mind around than Tkinter, coming from pretty much no knowledge of GUI programming previously.  It works pretty well and has some good tutorials.  Unfortunately there isn\'t an installer for Python 2.6 for Windows yet, and may not be for a while.</p>\n'}, {'answer_id': 41966334, 'author': 'PythonProgrammi', 'author_id': 6464947, 'author_profile': 'https://Stackoverflow.com/users/6464947', 'pm_score': 2, 'selected': False, 'text': '<pre><code># I\'d use tkinter for python 3\n\nimport tkinter\n\ntk = tkinter.Tk()\ntk.geometry(&quot;400x300+500+300&quot;)\nl = Label(tk,text=&quot;&quot;)\nl.pack()\ne = Entry(tk)\ne.pack()\n\ndef click():\n    e[\'text\'] = \'You clicked the button\'\n\nb = Button(tk,text=&quot;Click me&quot;,command=click)\nb.pack()\n\ntk.mainloop()\n\n# After this I would you py2exe\n# search for the use of this module on stakoverflow\n# otherwise I could edit this to let you know how to do it\n</code></pre>\n<h1>py2exe</h1>\nThen you should use py2exe, for example, to bring in one folder all the files needed to run the app, even if the user has not python on his pc (I am talking of windows... for the apple os there is no need of an executable file, I think, as it come with python in it without any need of installing it.\n<h1>Create this file</h1>\n<ol>\n<li>Create a setup.py</li>\n</ol>\n<hr />\n<p>with this code:</p>\n<pre><code>from distutils.core import setup\nimport py2exe\n\nsetup(console=[\'l4h.py\'])\n</code></pre>\n<h2>save it in a folder</h2>\n<ol start="2">\n<li>Put your program in the same folder of setup.py\nput in this folder the program you want to make it distribuitable:\nes: l4h.py</li>\n</ol>\n<h2>ps: change the name of the file (from l4h to anything you want, that is an example)</h2>\n<ol start="3">\n<li>Run cmd from that folder (on the folder, right click + shift and choose start cmd here)</li>\n<li>write in cmd:&gt;python setup.py py2exe</li>\n<li>in the dist folder there are all the files you need</li>\n<li>you can zip it and distribute it</li>\n</ol>\n<h2>Pyinstaller</h2>\n<h3> Install it from cmd</h3>\n<p>**</p>\n<blockquote>\n<p>pip install pyinstaller</p>\n</blockquote>\n<p>**</p>\n<h3>Run it from the cmd from the folder where the file is</h3>\n**\n<blockquote>\n<p>pyinstaller file.py</p>\n</blockquote>\n<p>**</p>\n<h1>Update</h1>\n<p>Read this post to make an exe on windows with pyinstaller the proper way and with one file and images in it <a href="https://pythonprogramming.altervista.org/auto-py-to-exe-only-one-file-with-images-for-our-python-apps/" rel="nofollow noreferrer">https://pythonprogramming.altervista.org/auto-py-to-exe-only-one-file-with-images-for-our-python-apps/</a></p>\n'}, {'answer_id': 44433045, 'author': 'shahar_m', 'author_id': 662770, 'author_profile': 'https://Stackoverflow.com/users/662770', 'pm_score': 1, 'selected': False, 'text': '<p>You can use <code>appJar</code> for basic GUI development.</p>\n\n<pre><code>from appJar import gui\n\nnum=1\n\ndef myfcn(btnName):   \n    global num\n    num +=1\n    win.setLabel("mylabel", num)\n\nwin = gui(\'Test\')\n\nwin.addButtons(["Set"],  [myfcn])\nwin.addLabel("mylabel", "Press the Button")\n\nwin.go()\n</code></pre>\n\n<p><a href="https://i.stack.imgur.com/yin42.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/yin42.jpg" alt="GUI when running"></a></p>\n\n<p>See documentation at <a href="http://appjar.info" rel="nofollow noreferrer">appJar site</a>.</p>\n\n<p>Installation is made with <code>pip install appjar</code> from command line.</p>\n'}, {'answer_id': 52721116, 'author': 'Mike from PSG', 'author_id': 8743099, 'author_profile': 'https://Stackoverflow.com/users/8743099', 'pm_score': 2, 'selected': False, 'text': '<p>PySimpleGUI wraps tkinter and works on Python 3 and 2.7. It also runs on Qt, WxPython and in a web browser, using the same source code for all platforms.  </p>\n\n<p>You can make custom GUIs that utilize all of the same widgets that you find in tkinter (sliders, checkboxes, radio buttons, ...).  The code tends to be very compact and readable.</p>\n\n<pre><code>#!/usr/bin/env python\nimport sys\nif sys.version_info[0] &gt;= 3:\n    import PySimpleGUI as sg\nelse:\n    import PySimpleGUI27 as sg\n\nlayout = [[ sg.Text(\'My Window\') ],\n          [ sg.Button(\'OK\')]]\n\nwindow = sg.Window(\'My window\').Layout(layout)\nbutton, value = window.Read()\n</code></pre>\n\n<p><a href="https://i.stack.imgur.com/VCegl.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/VCegl.jpg" alt="Image created from posted PySimpleGUI code"></a></p>\n\n<p>As explained in the <a href="http://www.PySimpleGUI.org" rel="nofollow noreferrer">PySimpleGUI Documentation</a>, to <a href="https://pysimplegui.readthedocs.io/#creating-a-windows-exe-file" rel="nofollow noreferrer">build the .EXE file</a> you run:</p>\n\n<blockquote>\n  <p>pyinstaller -wF MyGUIProgram.py</p>\n</blockquote>\n'}, {'answer_id': 59677113, 'author': 'Ritveak', 'author_id': 9928994, 'author_profile': 'https://Stackoverflow.com/users/9928994', 'pm_score': 2, 'selected': False, 'text': '<blockquote>\n  <p><strong>!!! KIVY !!!</strong></p>\n</blockquote>\n\n<p>I was amazed seeing that no one mentioned Kivy!!!</p>\n\n<p>I have once done a project using Tkinter, although they do advocate that it has improved a lot, it still gives me a feel of windows 98, so I switched to <a href="https://kivy.org/#home" rel="nofollow noreferrer">Kivy</a>.</p>\n\n<p>I have been following a <a href="https://www.youtube.com/playlist?list=PLzMcBGfZo4-kSJVMyYeOQ8CXJ3z1k7gHn" rel="nofollow noreferrer">tutorial series</a> if it helps...</p>\n\n<p>Just to give an idea of how kivy looks, see this (The project I am working on):</p>\n\n<p><a href="https://i.stack.imgur.com/IMl67.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/IMl67.png" alt="The Project that I am working on"></a></p>\n\n<p>And I have been working on it for barely a week now !\nThe benefits for Kivy you ask? Check <a href="https://www.reddit.com/r/kivy/comments/4omhca/what_exactly_are_the_benefits_of_kivy/" rel="nofollow noreferrer">this</a></p>\n\n<p>The reason why I chose this is, its look and that it can be used in mobile as well.</p>\n'}, {'answer_id': 67035173, 'author': 'AnthonySimons', 'author_id': 15379031, 'author_profile': 'https://Stackoverflow.com/users/15379031', 'pm_score': 1, 'selected': False, 'text': '<p>There\'s three things you could do:</p>\n<p>The first thing is to find a GUI Designer that can launch its code as standalone applications like .exe files. I use a version of MatDeck (for people using GUI Designers I recommend <a href="https://labdeck.com/python-designer/" rel="nofollow noreferrer">MD Python Designer</a>) as I believe(I use another version so I\'m not too sure.) it allows me to convert the code to a standalone applications and by having it as such, there is no need to install the software on every PC that\'s going to run the program.</p>\n<p>The second option is partially bypassing the problem, launch the GUI as a web page. This would give you the most compatibility as most if not all OS can utilize it. Once again, you would need a GUI Designer that can convert its components into a web compatible format, I\'ve done it once and I used the same version of MatDeck(<a href="https://labdeck.com/visionary-deck/" rel="nofollow noreferrer">Visionary Deck</a>), I would not recommend MD Python Designer this time as I don\'t know if it can turn its GUIs into websites using web assembly whereas Visionary Deck I\'ve tried and tested. As with all things there are most likely other software this is just one I use frequently because I work a lot with Mathematics and Physics.</p>\n<p>The third option is also kind of bypassing the problem but do it in Tkinter and just ensure you have a Python IDE or just plain old Python and run the code, this will launch the GUI. This is a good solution and maybe the simplest but I wouldn\'t class it as the shortest or the best. If you only plan to switch between a few operating systems and computers this will probably be your best bet.</p>\n'}]
['https://Stackoverflow.com/questions/2933', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1384652/']