Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/316.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 输入框不出现在tkinter窗口中_Python_Tkinter - Fatal编程技术网

Python 输入框不出现在tkinter窗口中

Python 输入框不出现在tkinter窗口中,python,tkinter,Python,Tkinter,我对特金特有意见。基本上,当我试图创建一个输入框时,窗口只打开标题 from tkinter import * window = Tk() window.title("name generator") def openInterface(): inputLabel = Label(window, text="Enter your name") inputLabel.grid(row=0, column=2) print(inputLabel) 我错过什么了吗?我事先为这是

我对特金特有意见。基本上,当我试图创建一个输入框时,窗口只打开标题

 from tkinter import *
 window = Tk()
 window.title("name generator")

 def openInterface():
  inputLabel = Label(window, text="Enter your name")
  inputLabel.grid(row=0, column=2)
  print(inputLabel)

我错过什么了吗?我事先为这是一个没有问题而道歉

您从未调用您的
openInterface
函数。函数与全局范围中的代码不同,因为它们只在调用时执行,而不是在定义时执行

from tkinter import *
window = Tk()
window.title("name generator")
openInterface()

def openInterface():
    inputLabel = Label(window, text="Enter your name")
    inputLabel.grid(row=0, column=2)
    print(inputLabel)

我想你错过了两件事,你还没打电话 功能,你也需要使用

window.mainloop()

这是你所有的代码吗?首先你必须理解。通读hey@chuck2002,感谢您的回复和澄清。