I have a program that needs to open Toplevel windows except the main Tk() window in tkinter. In the main window I have a Scale widget which is updated every 100 miliseconds with the after call. However in a state where the Toplevel window is open and the scale is updated when I press down the 'X' button in the Toplevel window the Scale stops moving.
This is my code:
from tkinter import Tk, Toplevel, Scale
root = Tk()
slider = Scale(root, orient='horizontal')
slider.pack()
num = 0
def main():
global num
slider.set(num)
num += 1
slider.after(500, main)
def toplevel():
win = Toplevel()
root.bind('<space>', lambda x: [main(), toplevel()])
root.mainloop()
When I stop pressing the 'X' button the Scale jumps to the point it should be 
How can I keep the slider/scale flowing normally even when I hold down the 'X' button?
And also why does this happen?
Thanks in advance!
from Why does holding down the 'X' button in a toplevel stop execution of main window in tkinter?

No comments:
Post a Comment