Python Tkinter Prompt

2020-07-09 10:01发布

I am trying to prompt the user to enter a string of text. Is there available with python tkinter a Javascript like prompt?

5条回答
做个烂人
2楼-- · 2020-07-09 10:18

try this:

import tkinter
x = tkinter.tkSimpleDialog.askstring
查看更多
欢心
3楼-- · 2020-07-09 10:25

You can ask a yes/no question with

from tkinter import *
answer = tkinter.messagebox.askquestion
查看更多
▲ chillily
4楼-- · 2020-07-09 10:29

Yes, use tkSimpleDialog.askstring. Unfortunately this isn't in the main Python docs, so it's a bit hard to find.

查看更多
孤傲高冷的网名
5楼-- · 2020-07-09 10:31

I think this is what you might want

for python 2.7:

from Tkinter import *
root = Tk()
E = Entry(root)
E.pack()
root.mainloop()

for python 3:

from tkinter import *
root = Tk()
e = Entry(root)
e.pack()
root.mainloop()
查看更多
Evening l夕情丶
6楼-- · 2020-07-09 10:33

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.

查看更多
登录 后发表回答