Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from tkinter import *
- root = Tk()
- root['bg'] = 'White'
- root.geometry('350x450')
- root.title('Калькулятор')
- root.resizable(width=False, height=False)
- #Поле для ввода
- task = Entry(root, bg='LightGray')
- task.place(x=0, y=0, width = 350, height=66)
- #(Кнопка деления
- def numDiv():
- task.insert(0, ':')
- btnDiv = Button(root, text='/', bg = 'LightGrey', command=numDiv)
- btnDiv.place(x=276, y=385, height=70, width=75)
- #(Кнопка умножения
- def numMult():
- task.insert(0, '×')
- btnMult = Button(root, text='×', bg='LightGrey', command=numMult)
- btnMult.place(x=276, y=315, height=70, width=75)
- #(Кнопка суммы
- def numSun():
- task.insert(0, '+')
- btnSum = Button(root, text='+', bg='LightGrey', command=numSun)
- btnSum.place(x=276, y=247, height=70, width=75)
- #Кнопка -
- def numSub():
- task.insert(0, '-')
- btnSub = Button(root, text='-', bg='LightGrey', command=numSub)
- btnSub.place(x=276, y=178, height=70, width=75)
- #Кнопка х²
- btnSq = Button(root, text='х²', bg='LightGrey')
- btnSq.place(x=276, y=110, height=70, width=75)
- #Кнопка =
- btnRav = Button(root, text='=', bg='Gainsboro')
- btnRav.place(x=0,y=65, height=50, width=75)
- #Кнопка -x
- def num_X():
- task.insert(0, '-')
- btn_X = Button(root, text='-x', bg='LightGrey', command=num_X)
- btn_X.place(x=0, y=382, height=70, width=92)
- #Поле вывода
- btnConc = Canvas(root, width=350, height=49, bg='LightGray')
- btnConc.place(x=75,y=65)
- #Кнопка 0
- def num0():
- task.insert(0, '0')
- btn0 = Button(root, text='0', bg='DarkGray', command=num0)
- btn0.place(x=90, y=382, height=70, width=92)
- #Кнопка корня
- def numRoot():
- task.insert(0, '√')
- btnRoot = Button(root, text='√', bg='LightGrey', command=numRoot)
- btnRoot.place(x=180, y=382, height=70, width=96)
- #Кнопка 9
- def num9():
- task.insert(0, '9')
- btn9 = Button(root, text='9', bg='DarkGray', command=num9)
- btn9.place(x=180, y=313, height=70, width=96)
- #Кнопка 8
- def num8():
- task.insert(0,'8')
- btn8 = Button(root, text='8', bg='DarkGray', command=num8)
- btn8.place(x=89, y=313, height=70, width=92)
- #Кнопка 7
- def num7():
- task.insert(0, '7')
- btn7 = Button(root, text='7', bg='DarkGray', command=num7)
- btn7.place(x=0, y=313, height=70, width=92)
- #Кнопка 6
- def num6():
- task.insert(0, '6')
- btn6 = Button(root, text='6', bg='DarkGray', command=num6)
- btn6.place(x=180, y=243, height=70, width=96)
- #Кнопка 5
- def num5():
- task.insert(0, '5')
- btn5 = Button(root, text='5', bg='DarkGray', command=num5)
- btn5.place(x=89, y=243, height=70, width=92)
- #Кнопка 4
- def num4():
- task.insert(0, '4')
- btn4 = Button(root, text='4', bg='DarkGray', command=num4)
- btn4.place(x=0, y=243, height=70, width=92)
- #Кнопка 3
- def num3():
- task.insert(0, '3')
- btn3 = Button(root, text='3', bg='DarkGray', command=num3)
- btn3.place(x=180, y=173, height=70, width=96)
- #Кнопка 2
- def num2():
- task.insert(0, '2')
- btn2 = Button(root, text='2', bg='DarkGray', command=num2)
- btn2.place(x=89, y=173, height=70, width=92)
- #Кнопка 1
- def num1():
- task.insert(0,'1')
- btn1 = Button(root, text='1', bg='DarkGray', command=num1)
- btn1.place(x=0, y=173, height=70, width=92)
- #Кнопка clear
- def clear():
- task.delete(0, END)
- btnClear = Button(root, text='CLEAR', bg='DarkGray', command=clear)
- btnClear.place(x=0,y=114, height=60, width=276)
Advertisement
Add Comment
Please, Sign In to add comment