A Tkinter status/information bar

Christian Tanzer tanzer at swing.co.at
Mon Oct 2 02:33:13 EDT 2000


Arild Hansen <arildh at stud.cs.uit.no> wrote:

> I have made a simple xclient using Tkinter gui. The xclient is a small
> application used to connect to a server and allows the user to modify
> various settings etc. all through Tkinter widgets. What I would like to
> implement is a status/information bar at the bottom of the main window.
> This information area (or whatever I should call it) should contain a
> few lines of text constantly updated. In my various modules I have
> statements like
> 
> print __name__,': Reading data from disk'
> print __name__,': Connecting to server'
> 
> This information is in other words currently being printed out to the
> terminal window. I want this information to be printed out in my main
> gui window. This feature will give the user a clue of what is going on
> as well as being COOL ;)

You need an object with a write function taking one string argument.
This function puts the passed argument into your status bar. The
simplest solution is to add this function to the class implementing
the status bar.

Then you simply say:

    sys.stdout = bar_object

From then on, standard output goes to the status bar until you change
sys.stdout again. 

-- 
Christian Tanzer                                         tanzer at swing.co.at
Glasauergasse 32                                       Tel: +43 1 876 62 36
A-1130 Vienna, Austria                                 Fax: +43 1 877 66 92





More information about the Python-list mailing list