0
如何讓在Tkinter的一個simpledialogbox一個字符串和一個整數的問題,而無需打開另一個simpledialogbox簡單的對話框多任務
from tkinter import *
from tkinter import simpledialog
simpledialog. askstring("name", "what is your name ")
Mainloop()
如何讓在Tkinter的一個simpledialogbox一個字符串和一個整數的問題,而無需打開另一個simpledialogbox簡單的對話框多任務
from tkinter import *
from tkinter import simpledialog
simpledialog. askstring("name", "what is your name ")
Mainloop()
你可以使用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()
你不能。你必須創建你自己的對話框。 –
檢查以下鏈接如何創建自己的對話框https://stackoverflow.com/questions/10057672/correct-way-to-implement-a-custom-popup-tkinter-dialog-box – kogito
可能重複的[正確方式來實現自定義彈出式tkinter對話框](https://stackoverflow.com/questions/10057672/correct-way-to-implement-a-custom-popup-tkinter-dialog-box) – eyllanesc