当我运行此代码时,出现空白的Tkinter窗口,没有按钮

时间:2020-07-10 06:38:05

标签: python tkinter

from tkinter import *

root = Tk()

def printName(event):
    name = input("what is your name?")
    print("My name is" + name)


    printButton = Button(root,text = "Cliek Me")
    printButton.bind("<Button-1>",printNme)
    printButton.pack()

    root.mainloop()

1 个答案:

答案 0 :(得分:0)

以下代码可以解决您的问题。根据您的代码要求,在引号内填空。

from tkinter import *

root = Tk()


def printName():
    name = input("what is your name?")
    print("My name is" + "")

    printButton = Button(root, text="Cliek Me")
    printButton.bind("<Button-1>", "")
    printButton.pack()

    root.mainloop()
printName()