python - How to have function read another function -


i need done variable close window when finished with. menu function. have tried root1.destory done function can't see root1 inside function says root1 not defined. how have done function understand root1 , close it. both functions called elsewhere. using functions don't want them start straight away , being when called for. code is:

def edit_menu():       root1 = tk()     root1.title("edit menu")      menu = frame(root1)     menu.pack(pady = 5, padx = 50)     var = stringvar(root1)      options = [             "forename",             "surname",              "email",             "date of birth",             "home address",             "home phone number",             "gender",             "tutor group",  ]     option = optionmenu(menu, var, options[0], *options, command=edit_functions)       var.set('select')      option.grid(row = 1, column = 1)      root1.mainloop()     return edit_menu  def done():     print()     done = (input("if have finnished editing, type done: "))     if done == "done":         root1.destroy() 

it appears showed section of overall code answer may limited should easy integrate code.

we can put need in creation of tkinter window including done button.

i think looking have this:

from tkinter import *  def edit_menu():      root1 = tk()     root1.title("edit menu")      menu = frame(root1)     menu.pack(pady = 5, padx = 50)     var = stringvar(root1)      options = [             "forename",             "surname",              "email",             "date of birth",             "home address",             "home phone number",             "gender",             "tutor group",      ]     option = optionmenu(menu, var, options[0], *options)      var.set('select')     option.grid(row = 1, column = 1)      done_btn = button(root1, text = "done", command = lambda: root1.destroy())     done_btn.pack()       root1.mainloop()  edit_menu() 

Comments

Popular posts from this blog

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

python Tkinter Capturing keyboard events save as one single string -

sql server - Why does Linq-to-SQL add unnecessary COUNT()? -