Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't get tkinter window title to change from 'tk'

I thought the line to change the title of a window was:

tk=Tk()

tk.title="my title"

But I can't get the title to change in my code:

def welcome_screen():
    #creates the login window
    window = Tk()
    window.title = "Login Screen"
    window.geometry("960x540+450+250")
    canvas = Canvas(window, width=960, height=540, bd=10, bg='#494949')
    canvas.pack()
    window.mainloop()

welcome_screen()

The title should change to "login screen" but when run it just says 'tk'. everything else works as expected.

like image 830
Tom bass Avatar asked Oct 22 '25 14:10

Tom bass


1 Answers

title is a function. Use it like:

root.title("My new title")

Example:

root = Tk()
root.title("my title")
root.mainloop()
like image 137
Black Thunder Avatar answered Oct 24 '25 03:10

Black Thunder



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!