Suggest a feature
×

Welcome to TagMyCode

Please login or create account to add a snippet.
0
0
 
0
Language: Python
Posted by: Jacob Mahto
Added: Jul 3, 2018 6:02 PM
Modified: Jul 3, 2018 6:42 PM
Views: 5
Tags: no tags
  1. from tkinter import*
  2. obj=Tk()
  3. obj.geometry("400x180+200+200")
  4. global operation
  5. global result
  6. result=0
  7. operation=""
  8. s1=StringVar()
  9. s2=StringVar()  
  10.  
  11. def f1():
  12.     operation="Addition is : "
  13.     value1=int(s1.get())
  14.    
  15.     value2=int(s2.get())
  16.    
  17.     result=value1+value2
  18.     print(operation , result)
  19.     srishti.configure(text=operation+str(result),bg="skyblue")
  20.    
  21.    
  22.        
  23. def f2():
  24.     operation="Difference is : "
  25.     value1=int(s1.get())    
  26.    
  27.     value2=int(s2.get())    
  28.    
  29.     result=value1-value2
  30.     print(operation,result)
  31.     srishti.configure(bg="skyblue")
  32.     srishti.configure(text=operation+str(result),bg="skyblue")
  33.    
  34. def f3():
  35.     operation="Product is : "
  36.     value1=int(s1.get())
  37.    
  38.     value2=int(s2.get())
  39.      
  40.     result=value1*value2
  41.     print(operation,result)
  42.     srishti.configure(text=operation+str(result),bg="skyblue")
  43.    
  44. def f4():
  45.     operation="Divison is : "
  46.     value1=int(s1.get())
  47.    
  48.     value2=int(s2.get())
  49.    
  50.     result=value1/value2
  51.     print(operation,result)
  52.     srishti.configure(text=operation+str(result),bg="skyblue")
  53.    
  54.    
  55. Label(text="Srishti Calculator App",bg="skyblue",fg="white",font=70).place(x=130,y=5)
  56.    
  57.    
  58. jacb=Label(text="Enter First Number",bg="blue",fg="white",font=60)
  59. jacb.place(x=30,y=35)
  60.  
  61. e1=Entry(textvariable=s1)
  62. e1.place(x=30,y=75)
  63.          
  64. srt=Label(text="Enter Second Number",bg="blue",fg="white",font=60)
  65. srt.place(x=220,y=35)
  66.          
  67. e2=Entry(textvariable=s2)
  68. e2.place(x=220,y=75)
  69.  
  70. srishti=Label(fg="white",font=50)
  71. srishti.place(x=130,y=150)
  72.          
  73. b1=Button(text="+",bg="skyblue",width=5,command=f1)
  74. b2=Button(text="-",bg="skyblue",width=5,command=f2)
  75. b3=Button(text="*",bg="skyblue",width=5,command=f3)
  76. b4=Button(text="/",bg="skyblue",width=5,command=f4)
  77.          
  78. b1.place(x=30,y=110)
  79. b2.place(x=130,y=110)
  80. b3.place(x=230,y=110)
  81. b4.place(x=330,y=110)
  82.  
  83.  
  84.  
  85.          
  86. obj.mainloop()
  87.  
  88.    
  89.  
  90. print("end of programme")