ARTICLE AD BOX
I'm trying to have an IntVar object move from one script to another via a function that calls the second script when the toplevel window created in the second script is destroyed
main script:
from tkinter import * import project2 root = Tk() def openbutton(): global points points = project2.OpenWindow(root) points = points.get() print(points) OpenButton = Button(root, text = "open window", command = openbutton) OpenButton.pack() root.mainloop()Part of the second script that returns the IntVar object:
from tkinter import * def OpenWindow(root): if done == True: return IntVar(root, score) window = Toplevel(root) def end(event): global done if event.widget == window: done = True OpenWindow(root) window.bind('<Destroy>', end) window.mainloop() #score comes from other code within the OpenWindow function so just #pretend that it has some integer value assigned to it.I run into three probelms, however:
the openbutton function should continue after the toplevel window is destroyed, printing the points value, however, it doesn't and I have to press its asocciated button again to get it continue the fucntion and print the value.
pressing the button again after the toplevel window has been closed will not open up the second window and will instead only print the points value
the points variable doesnt exist until the toplevel window is closed and the OpenButton button is pressed for a second time; creating another button to print it points will cause an error unless that criteria is fufilled. (I think this is an effect of the openbutton() function not continuing until the toplevel window is closed and the button is pressed for a second time)
the points variable doesnt have any value assinged to it after the root window is closed and will return None when printed in the terminal (I don't know how important this is, as the entire project should be within tkinter, but I would like to be able print it out in the terminal)
any help would be appreciated, this whole project has driven me insane.
