Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change Tkinter Frame Title [duplicate]

I am trying to figure out how to change the title of a Tkinter Frame. Below is simplified code that mimics the portion of my program where I am trying to change the title:

from Tkinter import *

class start_window(Frame):
    def __init__(self, parent=None):
        Frame.__init__(self, parent)
        Frame.pack(self)
        Label(self, text = 'Test', width=30).pack()

if __name__ == '__main__':
    start_window().mainloop()

With this sample code the Frame has the standard "tk" title but I would like to change it to something like "My Database". I've tried everything I can think of with no success. Any help would be appreciated.

like image 681
user3798654 Avatar asked Nov 10 '15 18:11

user3798654


People also ask

How do I change my Tk title?

Use the title() method to change the title of the window. Use the geometry() method to change the size and location of the window. Use the resizable() method to specify whether a window can be resizable horizontally or vertically. Use the window.

How do you name a frame in tkinter?

Build A Paint Program With TKinter and Python Let us suppose that we have created a frame with some widgets and now we want to rename the title of the application. Frame titles are a necessary part of any application. We can change the title of the frame using the title("title") method.

How do you change a frame in Python?

One way to achieve this is to create separate frames that lie inside the main window. A-Frame widget is used to group too many widgets in the application. We can add separate widgets in two different frames. The user can switch to the frame from one to another by clicking the button.

What is the use of title () in tkinter?

The title in tkinter refers to a name assigned to the application window. It is mostly found on the top of the application. For this, we can use the title() function. We create a widget object using the Tk() function and use the title() function to add a title to this window.


1 Answers

Try this:

if __name__ == '__main__':
    root = Tk()
    root.title("My Database")
    root.geometry("500x400")
    app = start_window(root)
    root.mainloop()
like image 99
letsc Avatar answered Oct 08 '22 04:10

letsc