RLAI Reinforcement Learning and Artificial Intelligence (RLAI)
RL Graphics tools  using Python and Tk Graphics

The ambition of this page is to explain some of the important details for using the graphics packages G and Quickgraph, and any GUI demos in the RL toolkit. These details are not necessarily obvious to all users, so it is hoped that this page will help. If you have additional questions that are not answered by the documentation or this page, please let us know.

How do I tell if I am in a windowing environment?
If you are using a Mac or Windows, you are automatically in a windowing environment. If you are on the console of a machine (before doing an Xinit, for example), you are NOT in a windowing environment. If you are running on a remote machine, you may have to set display variables before your windows will appear (we have not tested this).

What platforms will G and Quickgraph run on?
We have tested G and Graph on Macintosh OS X (panther), Windows XP, and Linux Redhat 9. There is no reason it shouldn't work on other platforms as long as they have Python, Tk and Tkinter installed, but we haven't tested on any others.

How do I run python with the graphics routines?
You can use most of the standard methods for running Python. You can have your program in a file and run Python with it from a shell window, or run interactively with prompts from a shell window. Some IDE's will have trouble with Tkinter. We have had success using IDLE, the standard IDE for Python. It has the added advantage of letting us have the best of both worlds - interactive command execution from a python command line, as well as interactive windows. Clues for setting up IDLE to do this are here.

On the macintosh, things are slightly more complicated. You must use pythonw, not python, to run your programs. The Python IDE that comes with the mac will not work with these graphics routines. IDLE will, if you modify it to use pythonw (see here for details).

How do I get Python? Tkinter?
There is a page of Python resources here. There are links for getting and installing Python, Tkinter and IDLE (the standard IDE), as well as documentation and tutorials.

What is this gStartEventLoop (formerly gMainloop) thing?
starts up an event based loop which catches things like button pushes, menu selections, mouse clicks, resizing or closing windows, and handles them as your program has specified. It also notes changes to your windows and redraws them. This must always be the LAST line of your program as it transfers control from your program to the event manager. No program commands after gStartEventLoop() will be executed until the loop ends - which is when the windows are destroyed or a quit is issued by some event. If you wish to manipulate your windows from a python command line, as well as having the windows themselves interactive, you need to use the IDLE IDE for Python, with the modifications suggested here.

If you run from the command line, sometimes your changes may show up without starting the event loop. If you really only want to see the window changes and are not using buttons and menus, the command gMakeVisible might work well enough for you. It displays the window changes and then returns control to your program.

If you use IDLE and gStartEventLoop(), a second python application will be started distinct from the IDLE process.  Your graphics windows will be part of that process and thus may be obscured by windows in the IDLE process.  This is all ok, but be aware of it.

Extend this Page   How to edit   Style   Subscribe   Notify   Suggest   Help   This open web page hosted at the University of Alberta.   Terms of use  2129/2