March 12th, 2017, 07:50 AM
update a variable in parent window after closing its toplevel window
i want to update my variable in parent window when i close its toplevel window.
i cretaed a function "new_window"...this function creates a new window(Demo2 class) ...demo2 is a sample of Demo2 class...the "demo2.destroyed" is a variable for understanding whether the toplevel window was closed or not....
i recieved this error " 'int' object is not iterable"
my code is:
demo2 = Demo2(self.master, self.var_sent)
counter += fasele
March 12th, 2017, 01:59 PM
Not enough info. Include the complete error message. The odds are good that the error is not even in the code you posted.
I assume all code is in one class because of the use of self. So use self.demo2 and declare it as none at the beginning so you have a variable even if it no window has been opened yet. You can then test for self.demo2.
And Why Are You Using Globals In A Class??? But instead of checking if the Toplevel is active, why not do whatever it is when the button is pressed to destroy it?
self.demo2 = Demo2(self.master, self.var_sent)
if not self.demo2:
Last edited by dwblas; March 12th, 2017 at 02:06 PM.
March 13th, 2017, 04:12 AM
what's the meaning of the "if not self.demo2" ?
Originally Posted by dwblas
i use from "global", because these variables are from another class
i used a button for closing the toplevel as you say
March 13th, 2017, 12:10 PM
This is not a good way to do this. You can use instance variables or class variables but there is not enough info here to decide, and that is not part of the question that created this thread so we can leave that as it is.
March 13th, 2017, 05:40 PM
None tests as False, as does 0 and do empty containers.
[/code] are essential for python code and Makefiles!