Python Tkinter - Close dialog without closing main window -


i'm trying make text entry dialog tkinter (python 3.5) i'm having problems. code:

class textentrydialog:     def __init__(self, master):         self.top = toplevel(master)         self.textfield = entry()         self.textfield.pack()  root = tk() ted = textentrydialog(root) root.mainloop() 

when run dialog , main window want, problem when close dialog main window closes well. main window stay open when dialog closes, can me this?

add titles windows , see

enter image description here

you add entry mainwindow.
, close mainwindow think textentrydialog.

you have add self.top (toplevel) parent in entry put in correct window.

self.textfield = entry(self.top) 

.

from tkinter import *  class textentrydialog:     def __init__(self, master):         self.top = toplevel(master)         self.top.title("textentrydialog")          self.textfield = entry(self.top) # parent         self.textfield.pack()  root = tk() root.title("mainwindow") ted = textentrydialog(root) root.mainloop() 

Comments