from tkinter import *
class MyApp( Tk) :
def __init__ ( self ) :
Tk. __init__ ( self )
self .title ( 'factorial (x)' )
self .geometry ( '250x100' )
self .resizable ( 0 , 0 )
self .number = Entry( self , width= 32 )
self .solve = Button( self , text= '!' , fg = 'blue' , height= 1 , width= 3 , command = lambda event= '<Button-1>' : MyApp.fctr ( self ) )
self .out = Label( self , text = '' , fg = 'green' , font = 16 )
self .number .bind ( '<Return>' , lambda event= '<Return>' : MyApp.fctr ( self ) )
self .number .place ( x= 25 , y= 5 )
self .solve .place ( x= 105 , y = 30 )
self .out .place ( x= 25 , y = 65 )
self .mainloop ( )
def fctr( self ) :
self .out .configure ( text = '' , fg= 'green' )
try :
x = int ( self .number .get ( ) )
y = 1
for elem in range ( 1 , x+1 ) :
y*= elem
self .out .configure ( text = y)
except :
self .out .configure ( text = 'ERROR' , fg= 'red' )
app = MyApp( )
ZnJvbSB0a2ludGVyIGltcG9ydCAqCgpjbGFzcyBNeUFwcChUayk6CgogICAgZGVmIF9faW5pdF9fIChzZWxmKToKICAgICAgICBUay4gX19pbml0X18gKHNlbGYpCiAgICAgICAgc2VsZi50aXRsZSgnZmFjdG9yaWFsICh4KScpCiAgICAgICAgc2VsZi5nZW9tZXRyeSgnMjUweDEwMCcpCiAgICAgICAgc2VsZi5yZXNpemFibGUoMCwwKQogICAgICAgIHNlbGYubnVtYmVyID0gRW50cnkoc2VsZiwgd2lkdGg9MzIpCiAgICAgICAgc2VsZi5zb2x2ZSA9IEJ1dHRvbihzZWxmLCB0ZXh0PSAnIScsIGZnID0gJ2JsdWUnLCBoZWlnaHQ9MSwgd2lkdGg9MywgY29tbWFuZCA9IGxhbWJkYSBldmVudD0nPEJ1dHRvbi0xPicgOiBNeUFwcC5mY3RyKHNlbGYpKQogICAgICAgIHNlbGYub3V0ID0gTGFiZWwoc2VsZiwgdGV4dCA9ICcnLCBmZyA9ICdncmVlbicsIGZvbnQgPSAxNikKICAgICAgICBzZWxmLm51bWJlci5iaW5kKCc8UmV0dXJuPicsIGxhbWJkYSBldmVudD0gJzxSZXR1cm4+JyA6IE15QXBwLmZjdHIoc2VsZikpCiAgICAgICAgc2VsZi5udW1iZXIucGxhY2UoeD0yNSx5PTUpCiAgICAgICAgc2VsZi5zb2x2ZS5wbGFjZSh4PSAxMDUsIHkgPSAzMCkKICAgICAgICBzZWxmLm91dC5wbGFjZSh4PTI1LCB5ID0gNjUpCiAgICAgICAgc2VsZi5tYWlubG9vcCgpCiAgICAgICAgCiAgICBkZWYgZmN0cihzZWxmKToKICAgICAgICBzZWxmLm91dC5jb25maWd1cmUodGV4dCA9ICcnLGZnPSdncmVlbicpCiAgICAgICAgdHJ5OgogICAgICAgICAgICB4ID0gaW50KHNlbGYubnVtYmVyLmdldCgpKQogICAgICAgICAgICB5ID0gMQogICAgICAgICAgICBmb3IgZWxlbSBpbiByYW5nZSgxLCB4KzEpOgogICAgICAgICAgICAgICAgeSo9ZWxlbQogICAgICAgICAgICBzZWxmLm91dC5jb25maWd1cmUodGV4dCA9IHkpCiAgICAgICAgZXhjZXB0OgogICAgICAgICAgICBzZWxmLm91dC5jb25maWd1cmUodGV4dCA9ICdFUlJPUicsZmc9J3JlZCcpCiAgICAgICAgICAgIAphcHAgPSBNeUFwcCgp
stdout
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