0

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()
SuperKogito
  • 2,998
  • 3
  • 16
  • 37
  • 1
    you can't. you have to create your own dialog box. – Bryan Oakley Oct 05 '17 at 20:53
  • 1
    check the following link on how to create your own dialog box https://stackoverflow.com/questions/10057672/correct-way-to-implement-a-custom-popup-tkinter-dialog-box – SuperKogito Oct 05 '17 at 22:28
  • Possible duplicate of [Correct way to implement a custom popup tkinter dialog box](https://stackoverflow.com/questions/10057672/correct-way-to-implement-a-custom-popup-tkinter-dialog-box) – eyllanesc Oct 06 '17 at 03:07

1 Answers1

0

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()
Ethan Field
  • 4,646
  • 3
  • 22
  • 43