Python Tkinter CGI Tutorial

Python Tkinter CGI Tutorial  (try twirling around bottom of image for a synopsis ... 'do the twirl now')

Python Tkinter CGI Tutorial (try twirling round bottom of image for a synopsis ... 'do the twirl now')

Have you heard of Python?

Python is a programming language that lets you work more quickly and integrate your systems more effectively. You can learn to use Python and see almost immediate gains in productivity and lower maintenance costs.

Check

How about Tkinter (the Tcl/TK GUI interface for Python)?

Tkinter is a Python binding to the Tk GUI toolkit, as we showed you below with previous relevant Python Tkinter Primer Tutorial. It is the standard Python interface to the Tk GUI toolkit[1] and is Python’s de facto standard GUI,[2] and is included with the standard Windows and Mac OS X install of Python.

So today (with an Apache/PHP/MySql local MAMP web server environment) we work off the install issues presented at Python Tkinter Install Tutorial and the advice at Apache WebServer on Mac and The Three P’s Primer Tutorial regarding the co-existance PHP (server-side HTML creation) can have with Python (as executable CGI program) that, now, can use Tkinter GUI functionality … yayyyyyyyyyyyyyyyyyyy! … to be able to run a Python Tkinter web application webpage.

By the way, the tkinter_filebrowser_test.cgi programming Python code used is the same as tkinter_filebrowser_test.py, as for the previous tutorial. Curiously, it may not run for you in Python 3.3(?!)


Previous relevant Python Tkinter Install Tutorial is shown below.

Python Tkinter Install Tutorial  (try twirling around bottom of image for a synopsis ... 'do the twirl now')

Python Tkinter Install Tutorial (try twirling round bottom of image for a synopsis ... 'do the twirl now')

Have you heard of Python?

Python is a programming language that lets you work more quickly and integrate your systems more effectively. You can learn to use Python and see almost immediate gains in productivity and lower maintenance costs.

Check

How about Tkinter (the Tcl/TK GUI interface for Python)?

Tkinter is a Python binding to the Tk GUI toolkit, as we showed you below with previous relevant Python Tkinter Primer Tutorial. It is the standard Python interface to the Tk GUI toolkit[1] and is Python’s de facto standard GUI,[2] and is included with the standard Windows and Mac OS X install of Python.

But what if you have Python installed but no Tkinter (GUI)? … to test for this … see … TkInter – Python Wiki, as is often the case on Apache/PHP web server setups.

If you get stuck at the import line of code with an error message you don’t have a compiled version of Python where a Tkinter module has been compiled into it. Before you panic, another check is, do you have two versions of Python co-existing, the more recent of which is not the default … try the same thing at the command line with python2.7 or python3.3, rather than python … Murphy’s law being what it is … a plot by Murphy’s enemies … it is unlikely this simple thought resolves your Tkinter usage issue.

You may get errors that talk about the environment variable DISPLAY … well, this means you have no GUI framework on which Tkinter can play? How could you? So part of what you will need is Xterm, or the more modern replacement Xquartz, or the more elaborate GNOME Desktop suite of software.

The findings for me were that both were needed … a sad scenario indeed, if you want to develop some interesting graphical Python software.

From here, the (Linux, in our case) environment becomes important (as you learn the more you get into the OpenSource world) … and the idea that you should not proceed if you are happy with your current Python, for what you aim to achieve … but … when looking for solutions to this problem on the Internet add your environment “word” to the search words … eg. (for me) … “Python Tkinter install” “CentOS”

Now will show you some useful links (thanks, OpenSource community) that may help point you in the right direction (environmental issues preclude me from giving more precise exact advice):

By the way, the test.py programming Python code used is the same as tkinter_filebrowser_test.py, as for the previous tutorial. Curiously, it may not run for you in Python 3.3(?!)

Will leave with a general Python Tcl/Tk reference link here.


Previous relevant Python Tkinter Primer Tutorial is shown below.

Python Tkinter Primer Tutorial  (try twirling round bottom of image for a synopsis ... 'do the twirl now')

Python Tkinter Primer Tutorial (try twirling round bottom of image for a synopsis ... 'do the twirl now')

Have you heard of Python?

Python is a programming language that lets you work more quickly and integrate your systems more effectively. You can learn to use Python and see almost immediate gains in productivity and lower maintenance costs.

Check

How about Tkinter (the Tcl/TK GUI interface for Python)?

Tkinter is a Python binding to the Tk GUI toolkit. It is the standard Python interface to the Tk GUI toolkit[1] and is Python’s de facto standard GUI,[2] and is included with the standard Windows and Mac OS X install of Python.

Check (we hope)

Have used it for Games Programming and it is great at parsing XML via the SAX API.

Python has some really interesting data structures such as tuples, lists, sets, dictionaries for instance … read more here.

In this primer tutorial you can see Tkinter being used by Python to display a file browser dialog, from which you can select a jpeg file to display with the default operating system image application (in our case, on a Mac laptop, this is Preview).

Here is another Python tutorial called Python Processing Directory Filespec Primer Tutorial.

Useful tutorials helping with this tutorial were

Link to Python information … from Wikipedia … where quote up the top resides.
Link to Tkinter information … from Wikipedia … where quote up the top resides.

Link to some Python downloadable programming source code which you could rename to tkinter_filebrowser_test.py

Link to Python website … Home of Python … where quote up the top resides
Link to Python jobs done … Python jobs done … personal experience
And yes, it’s true … the language name is a fond reference to Monty Python

If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.

This entry was posted in eLearning, GUI, Tutorials and tagged , , , , , , , , , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>