from Tkinter import *
class Window(Tk):
def __init__(self, parent):
Tk.__init__(self, parent)
self.parent = parent
self.initialize()
def initialize(self):
self.geometry("600x400+30+30")
wButton = Button(self, text='text', command = self.OnButtonClick())
wButton.pack()
def OnButtonClick(self):
top = Toplevel()
top.title("title")
top.geometry("300x150+30+30")
topButton = Button(top, text="CLOSE", command = self.destroy)
topButton.pack()
if __name__ == "__main__":
window = Window(None)
window.title("title")
window.mainloop()
# top.lift(aboveThis=self)
#self.configure(state=DISABLED) - unknown option "-state"
#ss = self.state()
#self["state"] = "disabled" - unknown option "-state"
#ws = window.state() # >>> ws outputs: 'normal'
# varname.unbind("<Button-1>", OnButtonClick)
#self.unbind("<Button-1>", OnButtonClick)
#window.unbind("<Button-1>")
###if window.OnButtonClick == True:
### window.unbind("<Button-1>", OnButtonClick)
The Python ver2.7.3 code above, when ran in IDLE ver2.7.3, using
Tkver8.5: displays the smaller top=Toplevel() window first for a
second, before displaying one instance of the window=Window(Tk) above
it. This is before any buttons are clicked or anything.
All of the comments underneath the above code are just notes to myself of things that I've tried and ideas to try next (idk - maybe unhelpful stuff).
How do I change the above code to: Make the instance of window=Window(Tk) the parent window and the the top=Toplevel() window the child. Then, when I run the program, only the parent window should display; and then when I click on 'wButton', the child window should appear on top of the parent window, with the parent window being disabled - its button inoperable and the user unable to make the window lift to the forefront by clicking on it?