fork download
  1. from tkinter import *
  2.  
  3. class MyApp(Tk):
  4.  
  5. def __init__ (self):
  6. Tk. __init__ (self)
  7. self.title('factorial (x)')
  8. self.geometry('250x100')
  9. self.resizable(0,0)
  10. self.number = Entry(self, width=32)
  11. self.solve = Button(self, text= '!', fg = 'blue', height=1, width=3, command = lambda event='<Button-1>' : MyApp.fctr(self))
  12. self.out = Label(self, text = '', fg = 'green', font = 16)
  13. self.number.bind('<Return>', lambda event= '<Return>' : MyApp.fctr(self))
  14. self.number.place(x=25,y=5)
  15. self.solve.place(x= 105, y = 30)
  16. self.out.place(x=25, y = 65)
  17. self.mainloop()
  18.  
  19. def fctr(self):
  20. self.out.configure(text = '',fg='green')
  21. try:
  22. x = int(self.number.get())
  23. y = 1
  24. for elem in range(1, x+1):
  25. y*=elem
  26. self.out.configure(text = y)
  27. except:
  28. self.out.configure(text = 'ERROR',fg='red')
  29.  
  30. app = MyApp()
Runtime error #stdin #stdout #stderr 0.04s 25664KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
Traceback (most recent call last):
  File "./prog.py", line 30, in <module>
  File "./prog.py", line 6, in __init__
  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