Advertisement
Guest User

Untitled

a guest
Nov 11th, 2019
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.73 KB | None | 0 0
  1. from tkinter import *
  2. from tkinter import ttk
  3. main = Tk()
  4. note = ttk.Notebook(main)
  5.  
  6. main.title("Multi Tools")
  7. main.geometry("360x100")
  8.  
  9. ############-WEIGHTCONVERT-###################(1.0)
  10. ###################################################
  11.  
  12. #Function
  13. def mult():
  14. if v.get() == 1 :
  15. blank.delete(0, END)
  16. ans = int(weight1.get()) * 0.45
  17. blank.insert(0, ans)
  18.  
  19. else:
  20. blank.delete(0, END)
  21. ans = int(weight1.get()) / 0.45
  22. blank.insert(0, ans)
  23.  
  24.  
  25. def clear():
  26. weight1.delete(0, END)
  27. blank.delete(0, END)
  28.  
  29.  
  30. #Tab(1.0)
  31. tab1 = ttk.Frame(note)
  32. tab2 = ttk.Frame(note)
  33. tab3 = ttk.Frame(note)
  34. tab4 = ttk.Frame(note)
  35.  
  36. #TAB(1.1)
  37. note.add(tab1, text = "Weight",compound=TOP)
  38. #note.add(tab1, text = "Tab One", compound=TOP)
  39. note.add(tab2, text = "Calculator")
  40. note.add(tab3, text = "Temperature")
  41. note.add(tab4, text= "Lenght")
  42. note.grid()
  43.  
  44. #Text(1.0)
  45. Label(tab1, text="Enter Amount: ").grid(row=0, column=0)
  46. Label(tab1, text="Weight: ").grid(row=1, column=0)
  47.  
  48. #EntryCase(1.0)
  49. weight1= Entry(tab1)
  50. blank = Entry(tab1)
  51.  
  52. weight1.grid(row=0, column=1)
  53. blank.grid(row=1, column=1)
  54.  
  55. #Checkbutton(1.0)
  56. v = IntVar()
  57. v1 = IntVar()
  58.  
  59. Checkbutton(tab1, text="Lbs to Kg", variable=v, onvalue=1, offvalue=0).grid(row=0, column=5)
  60. Checkbutton(tab1, text="Kg to Lbs", variable=v1, onvalue=1, offvalue=0).grid(row=1, column=5)
  61.  
  62. #Button(1.0)
  63.  
  64. Button(tab1, text="Calculate", command=mult).grid(row=4, column=1)
  65. Button(tab1, text="Clear", command=clear).grid(row=4, column=2)
  66.  
  67. ###########-CALCULATOR-###################(2.0)
  68. ###############################################
  69.  
  70. #Function
  71. def clear():
  72. first.delete(0, END)
  73. second.delete(0, END)
  74. result.delete(0, END)
  75.  
  76. def add():
  77. result.delete(0, END)
  78. ans = int(first.get()) + int(second.get())
  79. result.insert(0, ans)
  80.  
  81. def sub():
  82. result.delete(0, END)
  83. ans = int(first.get()) - int(second.get())
  84. result.insert(0, ans)
  85.  
  86. def mult():
  87. result.delete(0, END)
  88. ans = int(first.get()) * int(second.get())
  89. result.insert(0, ans)
  90.  
  91. def div():
  92. result.delete(0, END)
  93. ans = int(first.get()) / int(second.get())
  94. result.insert(0, ans)
  95.  
  96.  
  97. #Text(2.0)
  98. Label(tab2, text="Enter first number:").grid(row=0, column=0)
  99. Label(tab2, text="Enter second number:").grid(row=1, column=0)
  100. Label(tab2, text=" Result:").grid(row=2, column=0)
  101.  
  102. #EntryCase(2.0)
  103. first = Entry(tab2)
  104. second = Entry(tab2)
  105. result = Entry(tab2)
  106.  
  107. first.grid(row=0, column=1)
  108. second.grid(row=1, column=1)
  109. result.grid(row=2, column=1)
  110.  
  111. #Button
  112.  
  113. Button(tab2, text="ADD(+)", command=add).grid(row=0, column=2)
  114. Button(tab2, text="SUB(-)", command=sub).grid(row=0, column=3)
  115. Button(tab2, text="MULT(*)", command=mult).grid(row=1, column=2)
  116. Button(tab2, text="DIV(/)", command=div).grid(row=1, column=3)
  117. Button(tab2, text="Calculate").grid(row=2, column=2)
  118. Button(tab2, text="Clear", command=clear).grid(row=2, column=3)
  119.  
  120.  
  121. ###########-TEMPERATURE-###################(3.0)
  122. ###############################################
  123.  
  124. #Function
  125. def ctof():
  126. if not cel.get():
  127. ans = int(fah.get()) - 32
  128. ans1 = ans * 0.55
  129. cel.insert(0, ans1)
  130.  
  131. else:
  132. ans3 = int(cel.get()) * 1.8 + 32
  133. fah.insert(0, ans3)
  134.  
  135. def clear():
  136. cel.delete(0, END)
  137. fah.delete(0, END)
  138.  
  139.  
  140. #Text(3.0)
  141. Label(tab3, text="Celcius:").grid(row=0, column=0)
  142. Label(tab3, text="Fahrenheit:").grid(row=1, column=0)
  143.  
  144. #EntryCase(3.0)
  145. cel = Entry(tab3)
  146. fah = Entry(tab3)
  147.  
  148. cel.grid(row=0, column=1)
  149. fah.grid(row=1, column=1)
  150.  
  151. #Button(3.0)
  152. Button(tab3, text="Convert", command=ctof).grid(row=2, column=1)
  153. Button(tab3, text="Clear", command=clear).grid(row=2, column=2)
  154.  
  155. main.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement