Hello guest, if you read this it means you are not registered. Click here to register in a few simple steps, you will enjoy all features of our Forum.
Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
update a variable in parent window after closing its toplevel window
#1
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"
why????
please help

my code is:
def new_window(self):
        
        demo2 = Demo2(self.master, self.var_sent)
        
        def check_demo2():
            if demo2.destroyed:
                
                global fasele
                global counter
                counter += fasele
        
                self.tyLabel.config(text=str(counter))
                
            else:
                self.master.after(100, check_demo2)

        check_demo2()]
Moderator:
added opening python code tag :-)
Quote
#2
You could also consider to use the module 'Publisher'. Prepare a publisher in the toplevel window that sends a message in case of being destroyed (or a publisher at the same point where you give the command to destroy, if this is elsewhere) and a listener in your demo2. This will 'eavesdrop' continually.
Quote
#3
(Mar-12-2017, 05:10 PM)merlem Wrote: You could also consider to use the module 'Publisher'. Prepare a publisher in the toplevel window that sends a message in case of being destroyed (or a publisher at the same point where you give the command to destroy, if this is elsewhere) and a listener in your demo2. This will 'eavesdrop' continually.

this program understand when the toplevel window is closed...but the parent window (that is a class) can not update the value of the variable that gets from the toplevel window
Quote
#4
I'm not sure whether I really understand this problem.
However, if the publisher is not a solution, it would be helpful to know in which line of your code the error occurs. I can't assing that until now.
Quote
#5
If the window has a parent, then it isn't the toplevel window.
It's dangerous to go alone!  Take this: https://docs.python.org/3/library/index.html
HackerRank seems neat: https://www.hackerrank.com/nilamo
Quote
#6
Quote:If the window has a parent, then it isn't the toplevel window

This is true logically, but tkinter has a Toplevel window which can have a parent

Toplevel(master=None, **options)
(class) [#]
example
>>> zz = tk.Tk()
>>> f1 = tk.Frame(zz)
>>> t1 = tk.Toplevel(f1)
>>> zz.mainloop()
So here, the frame f1 is the parent of Toplevel t1
Quote

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  How to stop a tkinter function, without closing the window? keakins 4 35 Jun-27-2017, 07:28 PM
Last Post: nilamo
  Cancel update of text of QPlainTextEdit if terms not satisfied panoss 0 122 May-24-2017, 05:11 PM
Last Post: panoss
  PyGtk3, How to Create “title-changed” signal for Gtk.Window Widget? harun2525 2 224 May-01-2017, 07:59 AM
Last Post: harun2525
  [PyQt] how to dynamically add objects to pyqt window LavaCreeperKing 1 227 Apr-26-2017, 09:15 PM
Last Post: joe_anonimist
  set default font main window pyside Gigux 0 130 Apr-23-2017, 01:13 PM
Last Post: Gigux
  Closing Modal Window in QT nieselfriem 0 139 Apr-19-2017, 03:32 PM
Last Post: nieselfriem
  [Tkinter] Update value in Entry widget dannyH 7 386 Apr-02-2017, 10:12 AM
Last Post: dannyH
  How to fork a process, kill the child and not kill the parent? neXussT 3 275 Mar-04-2017, 09:35 PM
Last Post: neXussT
  pygtk2, how to disconnect all callback of widget or window event ? harun2525 1 231 Feb-19-2017, 11:44 PM
Last Post: Larz60+
  Show second window using classes iFunKtion 2 294 Feb-10-2017, 12:50 PM
Last Post: iFunKtion

Forum Jump:


Users browsing this thread: 1 Guest(s)