How do ask a string and a integer question in a single simpledialogbox in tkinter without opening another simpledialogbox
from tkinter import *
from tkinter import simpledialog
simpledialog. askstring("name", "what is your name ")
Mainloop()
How do ask a string and a integer question in a single simpledialogbox in tkinter without opening another simpledialogbox
from tkinter import *
from tkinter import simpledialog
simpledialog. askstring("name", "what is your name ")
Mainloop()
You could use Toplevel()
to create your own version of a simpledialog
, something like the below:
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()