Tix Meter, erratic behavior

H

Hugo Gonz?lez

Hi, I'm doing a simple text with the Tix Meter widget, in a program as
follows

import Tix
import time

mainwin=Tix.Tk()
container=Frame(mainwin)

bar=Tix.Meter(container, value=0.0)

bar.pack()

for i in range(100)
time.sleep(1)
bar.configure(value=(i/100.0)

-------------

I'm doing this in the interactive editor and I'd expects this gives me
a progresss bar that advances a number every second. When I run this,
the script would become irresponsive, and after Ctl-C the widget will
display with the last value reached in the -for- loop.

Does anyone have a clue why it is not doing what I expect? Can you
give it a try in your interpreter? What am I doing wrong?

Thanks all in advance..

Hugo
 
K

klappnase

Hi, I'm doing a simple text with the Tix Meter widget, in a program as
follows

import Tix
import time

mainwin=Tix.Tk()
container=Frame(mainwin)

bar=Tix.Meter(container, value=0.0)

bar.pack()

for i in range(100)
time.sleep(1)
bar.configure(value=(i/100.0)

-------------

I'm doing this in the interactive editor and I'd expects this gives me
a progresss bar that advances a number every second. When I run this,
the script would become irresponsive, and after Ctl-C the widget will
display with the last value reached in the -for- loop.

Does anyone have a clue why it is not doing what I expect? Can you
give it a try in your interpreter? What am I doing wrong?

Thanks all in advance..

Hugo

There are a few simple mistakes you made,
mainwin=Tix.Tk()
container=Frame(mainwin)

results in the following error on my box:

Traceback (most recent call last):
File "<stdin>", line 1, in ?
NameError: name 'Frame' is not defined

so you either need to do a "from Tkinter import *" first or
simply use container=Tix.Frame(mainwin) instead.

Second you forgot to pack the container into the mainwindow.

The third problem is that inside your for loop the widgets on the
screen don't get updated, so you should add a call to update_idletasks()
to the iteration:
for i in range(100)
time.sleep(1)
bar.configure(value=(i/100.0)
bar.update_idletasks()

I hope this helps

Michael
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,567
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top