from Tkinter import *
def config_open():
wdw = Toplevel()
wdw.geometry('+400+400')
# Makes window modal
wdw.grab_set()
# Variable to store entry value
user_input = StringVar()
Label(wdw, text="Parameter 1", justify=RIGHT).grid(row=1, column=0)
e = Entry(wdw, textvariable=user_input)
e.grid(row=1, column=1)
e.focus_set()
Button(wdw, text='Ok', command=wdw.destroy).grid(row=2, column=1)
# Show the window and wait for it to close
wdw.wait_window(wdw)
# Window has been closed
data = {'user_input': user_input.get().strip(),
'another-option': 'value of another-option'}
return data
class App:
def __init__(self):
self.root = Tk()
self.root.geometry('+200+200')
self.label_var = StringVar()
self.user_input = None
Button(self.root, text='Configure', command=self.get_options).place(relx=0.5, rely=0.5, anchor=CENTER)
Label(self.root, textvariable=self.label_var).place(relx=0.5, rely=0.3, anchor=CENTER)
self.root.mainloop()
def get_options(self):
options = config_open()
self.user_input = options['user_input']
self.label_var.set(self.user_input)
App()