fork(1) download
  1. from tkinter import *
  2.  
  3. def foo(text):
  4. if text == 'qwer':
  5. print('first button clicked')
  6. elif text == 'asdf':
  7. print('second button clicked')
  8.  
  9. win = Tk()
  10. b = Button(win, text='click here', command=lambda event='<Button-1>' : foo('qwer'))
  11. b1 = Button(win, text='click me', command=lambda event='<Button-1>' : foo('asdf'))
  12. b.grid()
  13. b1.grid()
  14.  
  15. win.mainloop()
Runtime error #stdin #stdout #stderr 0.04s 25704KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
Traceback (most recent call last):
  File "./prog.py", line 9, in <module>
  File "/usr/lib/python3.4/tkinter/__init__.py", line 1854, in __init__
    self.tk = _tkinter.create(screenName, baseName, className, interactive, wantobjects, useTk, sync, use)
_tkinter.TclError: no display name and no $DISPLAY environment variable