Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from tkinter import *
- from tkinter.messagebox import *
- def close_win(): #Функция выхода
- if askyesno("Exit", "What is output?"):
- root.destroy()
- def edit_click(): #Писаник
- def insertText():
- label = Label(text="1", bg="black",fg='green',font='Arial 14')#1
- text.window_create(INSERT, window=label)
- def insertText4():
- label = Label(text="4", bg="black",fg='green',font='Arial 14')#4
- text.window_create(INSERT, window=label)
- def insertText7():
- label = Label(text="7", bg="black",fg='green',font='Arial 14')#7
- text.window_create(INSERT, window=label)
- def insertText2():
- label = Label(text="2", bg="black",fg='green',font='Arial 14')#2
- text.window_create(INSERT, window=label)
- def insertText5():
- label = Label(text="5", bg="black",fg='green',font='Arial 14')#5
- text.window_create(INSERT, window=label)
- def insertText8():
- label = Label(text="8", bg="black",fg='green',font='Arial 14')#8
- text.window_create(INSERT, window=label)
- def insertText3():
- label = Label(text="3", bg="black",fg='green',font='Arial 14')#3
- text.window_create(INSERT, window=label)
- def insertText6():
- label = Label(text="6", bg="black",fg='green',font='Arial 14')#6
- text.window_create(INSERT, window=label)
- def insertText9():
- label = Label(text="9", bg="black",fg='green',font='Arial 14')#9
- text.window_create(INSERT, window=label)
- def insertText0():
- label = Label(text="0", bg="black",fg='green',font='Arial 14')#0
- text.window_create(INSERT, window=label)
- def insertText11():
- label = Label(text="+", bg="black",fg='green',font='Arial 14')# +
- text.window_create(INSERT, window=label)
- def insertText12():
- label = Label(text="=", bg="black",fg='green',font='Arial 14')# =
- text.window_create(INSERT, window=label)
- def insertText13():
- label = Label(text="-", bg="black",fg='green',font='Arial 14')# -
- text.window_create(INSERT, window=label)
- def insertText14():
- label = Label(text="/", bg="black",fg='green',font='Arial 14')# /
- text.window_create(INSERT, window=label)
- def insertText15():
- label = Label(text="*", bg="black",fg='green',font='Arial 14')# *
- text.window_create(INSERT, window=label)
- btn1 = Button(text="1", background="#001d18", foreground="#1e90ff", padx="10", pady="6", font="5",command=insertText)
- btn1.place(x=10, y=250)
- btn2 = Button(text="4", background="#001d18", foreground="#1e90ff", padx="10", pady="6", font="5",command=insertText4)
- btn2.place(x=10, y=300)
- btn3 = Button(text="7", background="#001d18", foreground="#1e90ff", padx="10", pady="6", font="5",command=insertText7)
- btn3.place(x=10, y=350)
- btn4 = Button(text="2", background="#001d18", foreground="#1e90ff", padx="10", pady="6", font="5",command=insertText2)
- btn4.place(x=60, y=250)
- btn5 = Button(text="5", background="#001d18", foreground="#1e90ff", padx="10", pady="6", font="5",command=insertText5)
- btn5.place(x=60, y=300)
- btn6 = Button(text="8", background="#001d18", foreground="#1e90ff", padx="10", pady="6", font="5",command=insertText8)
- btn6.place(x=60, y=350)
- btn7 = Button(text="3", background="#001d18", foreground="#1e90ff", padx="10", pady="6", font="5",command=insertText3)
- btn7.place(x=110, y=250)
- btn8 = Button(text="6", background="#001d18", foreground="#1e90ff", padx="10", pady="6", font="5",command=insertText6)
- btn8.place(x=110, y=300)
- btn9 = Button(text="9", background="#001d18", foreground="#1e90ff", padx="10", pady="6", font="5",command=insertText9)
- btn9.place(x=110, y=350)
- btn11 = Button(text="0", background="#001d18", foreground="#1e90ff", padx="10", pady="6", font="5",command=insertText0)
- btn11.place(x=10, y=200)
- btn10 = Button(text="+", background="#555", foreground="#000000", padx="10", pady="6", font="5",command=insertText11) # +
- btn10.place(x=160, y=250)
- btn12 = Button(text="=", background="#e28b00", foreground="#000000", padx="10", pady="31", font="5",command=insertText12)# =
- btn12.place(x=160, y=301)
- btn13 = Button(text="-", background="#555", foreground="#000000", padx="12", pady="6", font="5",command=insertText13)# -
- btn13.place(x=160, y=200)
- btn14 = Button(text="/", background="#555", foreground="#000000", padx="13", pady="6", font="5",command=insertText14)# /
- btn14.place(x=110, y=200)
- btn15 = Button(text="*", background="#555", foreground="#000000", padx="12", pady="6", font="5",command=insertText15)# *
- btn15.place(x=60, y=200)
- text=Text(root,height=7,width=15,font='Arial 14',bg="black", fg='green',wrap=WORD) # текст
- text.pack()
- root.mainloop()
- #Родилка тут
- root = Tk()
- root.title("Calculator")
- root.geometry("210x400")# размер окна
- label = Label()
- label.pack()
- main_menu = Menu()
- file_menu = Menu()
- file_menu.add_command(label="Calculator", command=edit_click) #Сверху виджет
- main_menu.add_cascade(label="New", menu=file_menu) #Сверху виджет
- main_menu.add_command(label="Exit",command = close_win) #Сверху виджет
- root.config(menu=main_menu)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement