tkinter toplevel widget
Matthew Dixon Cowles
matt at mondoinfo.com
Sun Oct 1 15:25:46 EDT 2000
On 1 Oct 2000 16:29:37 GMT, Anders Olme <anders.olme at gavle.to> wrote:
>Hello is it possible to change root window title after the mainloop()
>is entered?
Yes, it is. Since the top level mainloop() only returns when the root
window is closed, you need to change the title it in a callback that's
called in response to some event. I'll append a simple example.
Regards,
Matt
from Tkinter import *
class mainWin:
def __init__(self,root):
self.root=root
self.createWidgets()
return None
def createWidgets(self):
b=Button(self.root,text="Change title",command=self.changeTitle)
b.pack(side=TOP)
spacer=Frame(self.root,width=200)
spacer.pack(side=TOP)
self.root.title("Test")
return None
def changeTitle(self):
self.root.title("Different title")
return None
def main():
root=Tk()
mainWin(root)
root.mainloop()
if __name__=='__main__':
main()
More information about the Python-list
mailing list