it doesnt look like the problem is with GUI, it looks like your problem is with your programming.
Every time you hit the button you execute start(). This function sets the string var (v) to every 100K (0-900000) in a split second. The last value 900000 gets seen as the label because its the last iteration and the completion of the function. Thus you will not see any other number in the label like you would with the print function...assuming this is what you wanted to do?
EDIT:
Do you mean something like this? I would suggest to use classes instead of global keywords.
Quote:def start(): for n in range(1000000): if n%100000 == 0: v.set(str(n))
Every time you hit the button you execute start(). This function sets the string var (v) to every 100K (0-900000) in a split second. The last value 900000 gets seen as the label because its the last iteration and the completion of the function. Thus you will not see any other number in the label like you would with the print function...assuming this is what you wanted to do?
EDIT:
Do you mean something like this? I would suggest to use classes instead of global keywords.
from tkinter import * class Values: def __init__(self): self.vals = [] self.index = 0 self.assign() def assign(self): '''get our values''' for n in range(1000000): if n%100000 == 0: self.vals.append(n) def reset(self): '''what do we do when we iterate all values? Start at 0''' if self.index > len(self.vals)-1: self.index = 0 def callback(self): '''execute when button gets pressed''' self.reset() v.set(self.vals[self.index]) self.index += 1 win = Tk() v = StringVar() obj = Values() frame1 = Frame(win) frame1.pack() Label(frame1, text="Number").grid(row=0, column=0, sticky=W) m = Label(frame1, textvariable=v) m.grid(row=0, column=1, sticky=W) frame2 = Frame(win) frame2.pack() b1 = Button(frame2,text=" Start ",command=obj.callback) b1.pack(side=LEFT) #win = makeWindow() win.mainloop()
Recommended Tutorials: