Change Tkinter Frame Title [duplicate]
First, you should be explicitly creating the main window by creating an instance of Tk
. When you do, you can use the reference to this window to change the title.
I also recommend not using a global import. Instead, import tkinter by name,and prefix your tkinter commands with the module name. I use the name tk
to cut down on typing:
import Tkinter as tkclass start_window(tk.Frame): def __init__(self, parent=None): tk.Frame.__init__(self, parent) tk.Frame.pack(self) tk.Label(self, text = 'Test', width=30).pack()if __name__ == '__main__': root = tk.Tk() root.wm_title("This is my title") start_window(root) root.mainloop()
Finally, to make your code easier to read I suggest giving your class name an uppercase first letter to be consistent with almost all python programmers everywhere:
class StartWindow(...):
By using the same conventions as everyone else, it makes it easier for us to understand your code.
For more information about naming conventions used by the tkinter community, see PEP8