Change Tkinter Frame Title [duplicate] Change Tkinter Frame Title [duplicate] tkinter tkinter

Change Tkinter Frame Title [duplicate]


Try this:

if __name__ == '__main__':    root = Tk()    root.title("My Database")    root.geometry("500x400")    app = start_window(root)    root.mainloop()


I generally start my tkinter apps with

#!/usr/local/bin/python3import Tkinter as tkroot = Tk() root.title('The name of my app')root.minsize(300,300)root.geometry("800x800")root.mainloop()


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