如何从输入框tkinter更改窗口标题

时间:2016-11-09 06:44:19

标签: tkinter python-3.5

我想要做的是制作一个程序,当您在输入框中按Enter键时,它会更改窗口标题

import tkinter

window = tkinter.Tk()
title = window.title("1")

def name(event):
    title.configure("2")

Name = tkinter.Entry(window)
Name.bind("<Return>", name)
Name.pack()
window.mainloop()

非常欢迎任何帮助!

2 个答案:

答案 0 :(得分:0)

import tkinter

window = tkinter.Tk()
title = window.title("1")

def name(event):
    window.title("2")

Name = tkinter.Entry(window)
Name.bind("<Return>", name)
Name.pack()
window.mainloop()

答案 1 :(得分:0)

Change the window title with Tk.title function.

window.title("TITLE")

This will change the title.

def name(event=None):
    window.title("Hello, %s!"%Name.get())