fork(1) download
  1. from tkinter import *
  2.  
  3. class MainWnd:
  4. def __init__(self,Frame):
  5. self.SelectName = StringVar()
  6. self.Names = ["aa","bb"]
  7. self.OptModuleName = OptionMenu(app,self.SelectName,*self.Names,command=self.SelectModule)
  8. self.OptModuleName.pack()
  9. self.BtnUpdate = Button(app, text="Update",command=self.Update)
  10. self.BtnUpdate.pack()
  11. def SelectModule(self,value):
  12. print("choose",value)
  13. def Update(self):
  14. print("Update Obtion Menu")
  15. self.OptModuleName['menu'].delete(0,'end')
  16. self.Names.clear()
  17. self.Names = ["cc","dd"]
  18. for Item in self.Names:
  19. self.OptModuleName['menu'].add_command(label=Item,command=self.SelectModule)
  20. app = Tk()
  21. app.geometry('300x200')
  22. MainWindows = MainWnd(app)
  23. app.mainloop()
  24.  
Runtime error #stdin #stdout #stderr 0.05s 76608KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
Traceback (most recent call last):
  File "./prog.py", line 20, in <module>
  File "/usr/lib/python3.5/tkinter/__init__.py", line 1880, in __init__
    self.tk = _tkinter.create(screenName, baseName, className, interactive, wantobjects, useTk, sync, use)
_tkinter.TclError: no display name and no $DISPLAY environment variable