только главный мозг или професеор помогите пожалуйста очень важно
с делать 3 кнопки - ÷×
from tkinter import *
vikno=Tk()
vikno.title('Калькулятор')
vikno.geometry("380x200")
def plus():
a=int(entry1.get())
b=int(entry2.get())
c=a+b
entry3['state']="normal"
entry3.insert(0, c)
#Функція для кнопки "-"
#Функція для кнопки "*"
#Функція для кнопки "/"
def clear():
entry1.delete(0)
entry2.delete(0)
entry3.delete(0)
entry3['state']='readonly'
label1=Label(vikno, text="Перше число", font="Arial 16 italic").grid(row=0, column=0, columnspan=2, padx=10, pady=10)
label2=Label(vikno, text="Друге число", font="Arial 16 italic").grid(row=0, column=3, columnspan=2, padx=10, pady=10)
entry1=Entry(vikno)
entry1.grid(row=1, column=0, columnspan=2, padx=10, pady=10)
entry2=Entry(vikno)
entry2.grid(row=1, column=3, columnspan=2, padx=10, pady=10)
button1=Button(vikno, text="+", font="Arial 16 bold", command=plus)
button1.grid(row=2, column=0, padx=10, pady=10)
entry3=Entry(vikno, state='readonly')
entry3.grid(row=3, column=1, columnspan=3, padx=10, pady=10)
button5=Button(vikno, text="С", font="Arial 16 bold", command=clear)
button5.grid(row=3, column=4, padx=10, pady=10)
vikno.mainloop()
Answers & Comments
Не профессор но стремлюсь к нему.
from tkinter import *
vikno = Tk()
vikno.title('Калькулятор')
vikno.geometry("380x200")
def plus():
a = int(entry1.get())
b = int(entry2.get())
c = a + b
entry3['state'] = "normal"
entry3.delete(0, END)
entry3.insert(0, c)
entry3['state'] = "readonly"
def minus():
a = int(entry1.get())
b = int(entry2.get())
c = a - b
entry3['state'] = "normal"
entry3.delete(0, END)
entry3.insert(0, c)
entry3['state'] = "readonly"
def multiply():
a = int(entry1.get())
b = int(entry2.get())
c = a * b
entry3['state'] = "normal"
entry3.delete(0, END)
entry3.insert(0, c)
entry3['state'] = "readonly"
def divide():
a = int(entry1.get())
b = int(entry2.get())
c = a / b
entry3['state'] = "normal"
entry3.delete(0, END)
entry3.insert(0, c)
entry3['state'] = "readonly"
def clear():
entry1.delete(0, END)
entry2.delete(0, END)
entry3.delete(0, END)
entry3['state'] = 'readonly'
label1 = Label(vikno, text="Перше число", font="Arial 16 italic")
label1.grid(row=0, column=0, columnspan=2, padx=10, pady=10)
label2 = Label(vikno, text="Друге число", font="Arial 16 italic")
label2.grid(row=0, column=3, columnspan=2, padx=10, pady=10)
entry1 = Entry(vikno)
entry1.grid(row=1, column=0, columnspan=2, padx=10, pady=10)
entry2 = Entry(vikno)
entry2.grid(row=1, column=3, columnspan=2, padx=10, pady=10)
button1 = Button(vikno, text="+", font="Arial 16 bold", command=plus)
button1.grid(row=2, column=0, padx=10, pady=10)
button2 = Button(vikno, text="-", font="Arial 16 bold", command=minus)
button2.grid(row=2, column=1, padx=10, pady=10)
button3 = Button(vikno, text="*", font="Arial 16 bold", command=multiply)
button3.grid(row=2, column=2, padx=10, pady=10)
button4 = Button(vikno, text="/", font="Arial 16 bold", command=divide)
button4.grid(row=2, column=3, padx=10