How to Change Tkinter Frame Title?

TkinterServer Side ProgrammingProgramming

Tkinter window is the native component of tkinter application that contains some frames, a group of widgets, and some other elements. A Tkinter frame has a group of too many widgets.

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.


In this example, we will create an application that will contain an entry widget and a button. The button is used to rename the title of the window. Initially, we will create an instance of StringVar() and this can be used to capture the user input in the Entry widget. Then, by using the set() method, we will pass the captured variable to set the title of the frame.

#Import tkinter library
from tkinter import *
#Create an instance of tkinter frame
win= Tk()
#Set the Geometry
#Define a Variable to accept the input
var= StringVar()
#Define a function to change the title
def change_title():
#Create an Entry widget
#Pass the title in the function
#Create a Button
Button(win, text= "Change", command= change_title).pack(pady=20)


By running the above code, we can display a window that contains a button and the frame object. Now, whenever we write some title in the entry widget and click the “Change” button, it will change the title of the frame.

Now, change the title of the frame by writing some text in the Entry widget and click the “Change” to display the reflected output.

Published on 15-Apr-2021 14:20:07