Lev*_*Lev 6 python user-input prompt python-3.x
我想创建一个用户可以与之交互的屏幕输入框.
用户可以看到一个带有输入字段的窗口,可以用鼠标单击它.用户可以在字段中键入或删除文本,然后在完成添加文本后按OK.最后,我的程序会存储此文本供以后使用.
如何在Python中创建允许用户输入的文本框?
Chr*_*ian 11
您可以尝试使用Tkinter模块:
from tkinter import *
master = Tk()
e = Entry(master)
e.pack()
e.focus_set()
def callback():
print e.get() # This is the text you may want to use later
b = Button(master, text = "OK", width = 10, command = callback)
b.pack()
mainloop()
Run Code Online (Sandbox Code Playgroud)
结果:

当然,您可能想阅读Tkinter教程.
| 归档时间: |
|
| 查看次数: |
62659 次 |
| 最近记录: |