【问题标题】:Simple dialogbox multitasking简单的对话框多任务处理
【发布时间】:2018-03-17 14:12:15
【问题描述】:

如何在 tkinter 的单个 simpledialogbox 中询问字符串和整数问题而不打开另一个 simpledialogbox

from tkinter import *
from tkinter import simpledialog

simpledialog. askstring("name", "what is your name ")
Mainloop()

【问题讨论】:

标签: python tkinter simpledialog


【解决方案1】:

您可以使用Toplevel() 创建您自己的simpledialog 版本,如下所示:

from tkinter import *

class App:
    def __init__(self, root):
        self.root = root
        self.button1 = Button(self.root, text="Ok", command=self.drawtop)
        self.button1.pack()
    def drawtop(self):
        self.top = Toplevel(root)
        self.entry1 = Entry(self.top)
        self.entry2 = Entry(self.top)
        self.button2 = Button(self.top, text="Done", command=self.printtop)
        self.entry1.pack()
        self.entry2.pack()
        self.button2.pack()
    def printtop(self):
        print(self.entry1.get())
        print(self.entry2.get())
        self.top.destroy()

root = Tk()
App(root)
root.mainloop()

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-02-07
    • 2012-12-05
    • 1970-01-01
    相关资源
    最近更新 更多