我刚开始使用Tkinter并试图在python中创建一个简单的弹出框。我已经复制粘贴简单的代码从网站:在Jupyter Notebook中使用Tkinter
from Tkinter import *
master = Tk()
Label(master, text="First Name").grid(row=0)
Label(master, text="Last Name").grid(row=1)
e1 = Entry(master)
e2 = Entry(master)
e1.grid(row=0, column=1)
e2.grid(row=1, column=1)
mainloop()
此代码正在很长一段时间的运行,它已经将近5分钟! 是不是可以运行这个代码片段? 任何人都可以告诉我如何使用Tkinter?
我使用jupyter笔记本和python版本2.7。我只会要求为此版本提供解决方案。
问题是什么画面?你的代码对我来说运行良好。如预期的那样,它立即显示带有两个字段的表单。 –
脚本中没有错误。它工作正常。你想知道如何运行这段代码吗?复制粘贴代码到你的编辑器,保存它(sample.py),在终端中使用python3 sample.py运行它。你想从tkinter master或tkinter中的2个文本框中弹出吗? –
@ DeathJack2.0只是一点点更正:python2 **或'从tkinter导入*' – Lafexlos