Python Tkinter 提示
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1685020/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Python Tkinter Prompt
提问by MitMaro
I am trying to prompt the user to enter a string of text. Is there available with python tkinter a Javascript like prompt?
我试图提示用户输入一串文本。python tkinter 是否有类似 Javascript 的提示?
回答by Nicholas Riley
Yes, use tkSimpleDialog.askstring. Unfortunately this isn't in the main Python docs, so it's a bit hard to find.
是的,使用tkSimpleDialog.askstring。不幸的是,这不在主要的 Python 文档中,所以很难找到。
回答by MitMaro
try this:
试试这个:
import tkinter
x = tkinter.tkSimpleDialog.askstring
回答by Mike - SMT
You can ask a yes/no question with
你可以问是/否问题
from tkinter import *
answer = tkinter.messagebox.askquestion
回答by MitMaro
One of those situations where I find it after the question has been posted and since I had trouble finding the answer I will keep the question up.
我在问题发布后找到它的一种情况,因为我找不到答案,所以我会继续提出这个问题。
You can use a tkSimpleDialog.
您可以使用tkSimpleDialog。
回答by user1497423
I think this is what you might want
我想这就是你可能想要的
for python 2.7:
对于python 2.7:
from Tkinter import *
root = Tk()
E = Entry(root)
E.pack()
root.mainloop()
for python 3:
对于蟒蛇 3:
from tkinter import *
root = Tk()
e = Entry(root)
e.pack()
root.mainloop()