Guest User

Untitled

a guest
Dec 28th, 2021
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.42 KB | None | 0 0
  1. from tkinter import *
  2. root = Tk()
  3. root['bg'] = 'White'
  4. root.geometry('350x450')
  5. root.title('Калькулятор')
  6. root.resizable(width=False, height=False)
  7. #Поле для ввода
  8. task = Entry(root, bg='LightGray')
  9. task.place(x=0, y=0, width = 350, height=66)
  10. #(Кнопка деления
  11. def numDiv():
  12. task.insert(0, ':')
  13. btnDiv = Button(root, text='/', bg = 'LightGrey', command=numDiv)
  14. btnDiv.place(x=276, y=385, height=70, width=75)
  15. #(Кнопка умножения
  16. def numMult():
  17. task.insert(0, '×')
  18. btnMult = Button(root, text='×', bg='LightGrey', command=numMult)
  19. btnMult.place(x=276, y=315, height=70, width=75)
  20. #(Кнопка суммы
  21. def numSun():
  22. task.insert(0, '+')
  23. btnSum = Button(root, text='+', bg='LightGrey', command=numSun)
  24. btnSum.place(x=276, y=247, height=70, width=75)
  25. #Кнопка -
  26. def numSub():
  27. task.insert(0, '-')
  28. btnSub = Button(root, text='-', bg='LightGrey', command=numSub)
  29. btnSub.place(x=276, y=178, height=70, width=75)
  30. #Кнопка х²
  31. btnSq = Button(root, text='х²', bg='LightGrey')
  32. btnSq.place(x=276, y=110, height=70, width=75)
  33. #Кнопка =
  34. btnRav = Button(root, text='=', bg='Gainsboro')
  35. btnRav.place(x=0,y=65, height=50, width=75)
  36. #Кнопка -x
  37. def num_X():
  38. task.insert(0, '-')
  39. btn_X = Button(root, text='-x', bg='LightGrey', command=num_X)
  40. btn_X.place(x=0, y=382, height=70, width=92)
  41. #Поле вывода
  42. btnConc = Canvas(root, width=350, height=49, bg='LightGray')
  43. btnConc.place(x=75,y=65)
  44. #Кнопка 0
  45. def num0():
  46. task.insert(0, '0')
  47. btn0 = Button(root, text='0', bg='DarkGray', command=num0)
  48. btn0.place(x=90, y=382, height=70, width=92)
  49. #Кнопка корня
  50. def numRoot():
  51. task.insert(0, '√')
  52. btnRoot = Button(root, text='√', bg='LightGrey', command=numRoot)
  53. btnRoot.place(x=180, y=382, height=70, width=96)
  54. #Кнопка 9
  55. def num9():
  56. task.insert(0, '9')
  57. btn9 = Button(root, text='9', bg='DarkGray', command=num9)
  58. btn9.place(x=180, y=313, height=70, width=96)
  59. #Кнопка 8
  60. def num8():
  61. task.insert(0,'8')
  62. btn8 = Button(root, text='8', bg='DarkGray', command=num8)
  63. btn8.place(x=89, y=313, height=70, width=92)
  64. #Кнопка 7
  65. def num7():
  66. task.insert(0, '7')
  67. btn7 = Button(root, text='7', bg='DarkGray', command=num7)
  68. btn7.place(x=0, y=313, height=70, width=92)
  69. #Кнопка 6
  70. def num6():
  71. task.insert(0, '6')
  72. btn6 = Button(root, text='6', bg='DarkGray', command=num6)
  73. btn6.place(x=180, y=243, height=70, width=96)
  74. #Кнопка 5
  75. def num5():
  76. task.insert(0, '5')
  77. btn5 = Button(root, text='5', bg='DarkGray', command=num5)
  78. btn5.place(x=89, y=243, height=70, width=92)
  79. #Кнопка 4
  80. def num4():
  81. task.insert(0, '4')
  82. btn4 = Button(root, text='4', bg='DarkGray', command=num4)
  83. btn4.place(x=0, y=243, height=70, width=92)
  84. #Кнопка 3
  85. def num3():
  86. task.insert(0, '3')
  87. btn3 = Button(root, text='3', bg='DarkGray', command=num3)
  88. btn3.place(x=180, y=173, height=70, width=96)
  89. #Кнопка 2
  90. def num2():
  91. task.insert(0, '2')
  92. btn2 = Button(root, text='2', bg='DarkGray', command=num2)
  93. btn2.place(x=89, y=173, height=70, width=92)
  94. #Кнопка 1
  95. def num1():
  96. task.insert(0,'1')
  97. btn1 = Button(root, text='1', bg='DarkGray', command=num1)
  98. btn1.place(x=0, y=173, height=70, width=92)
  99. #Кнопка clear
  100. def clear():
  101. task.delete(0, END)
  102.  
  103. btnClear = Button(root, text='CLEAR', bg='DarkGray', command=clear)
  104. btnClear.place(x=0,y=114, height=60, width=276)
Advertisement
Add Comment
Please, Sign In to add comment