Advertisement
Guest User

Untitled

a guest
May 26th, 2018
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.33 KB | None | 0 0
  1. from tkinter import *
  2. from tkinter.messagebox import *
  3.  
  4.  
  5. def close_win(): #Функция выхода
  6. if askyesno("Exit", "What is output?"):
  7. root.destroy()
  8.  
  9. def edit_click(): #Писаник
  10.  
  11.  
  12. def insertText():
  13. label = Label(text="1", bg="black",fg='green',font='Arial 14')#1
  14. text.window_create(INSERT, window=label)
  15.  
  16. def insertText4():
  17. label = Label(text="4", bg="black",fg='green',font='Arial 14')#4
  18. text.window_create(INSERT, window=label)
  19.  
  20. def insertText7():
  21. label = Label(text="7", bg="black",fg='green',font='Arial 14')#7
  22. text.window_create(INSERT, window=label)
  23.  
  24. def insertText2():
  25. label = Label(text="2", bg="black",fg='green',font='Arial 14')#2
  26. text.window_create(INSERT, window=label)
  27.  
  28. def insertText5():
  29. label = Label(text="5", bg="black",fg='green',font='Arial 14')#5
  30. text.window_create(INSERT, window=label)
  31.  
  32. def insertText8():
  33. label = Label(text="8", bg="black",fg='green',font='Arial 14')#8
  34. text.window_create(INSERT, window=label)
  35.  
  36. def insertText3():
  37. label = Label(text="3", bg="black",fg='green',font='Arial 14')#3
  38. text.window_create(INSERT, window=label)
  39.  
  40. def insertText6():
  41. label = Label(text="6", bg="black",fg='green',font='Arial 14')#6
  42. text.window_create(INSERT, window=label)
  43.  
  44. def insertText9():
  45. label = Label(text="9", bg="black",fg='green',font='Arial 14')#9
  46. text.window_create(INSERT, window=label)
  47.  
  48. def insertText0():
  49. label = Label(text="0", bg="black",fg='green',font='Arial 14')#0
  50. text.window_create(INSERT, window=label)
  51.  
  52. def insertText11():
  53.  
  54. label = Label(text="+", bg="black",fg='green',font='Arial 14')# +
  55. text.window_create(INSERT, window=label)
  56.  
  57. def insertText12():
  58.  
  59. label = Label(text="=", bg="black",fg='green',font='Arial 14')# =
  60. text.window_create(INSERT, window=label)
  61.  
  62. def insertText13():
  63.  
  64. label = Label(text="-", bg="black",fg='green',font='Arial 14')# -
  65. text.window_create(INSERT, window=label)
  66.  
  67. def insertText14():
  68.  
  69. label = Label(text="/", bg="black",fg='green',font='Arial 14')# /
  70. text.window_create(INSERT, window=label)
  71.  
  72. def insertText15():
  73. label = Label(text="*", bg="black",fg='green',font='Arial 14')# *
  74. text.window_create(INSERT, window=label)
  75.  
  76. btn1 = Button(text="1", background="#001d18", foreground="#1e90ff", padx="10", pady="6", font="5",command=insertText)
  77. btn1.place(x=10, y=250)
  78.  
  79.  
  80.  
  81.  
  82.  
  83. btn2 = Button(text="4", background="#001d18", foreground="#1e90ff", padx="10", pady="6", font="5",command=insertText4)
  84. btn2.place(x=10, y=300)
  85.  
  86. btn3 = Button(text="7", background="#001d18", foreground="#1e90ff", padx="10", pady="6", font="5",command=insertText7)
  87. btn3.place(x=10, y=350)
  88.  
  89. btn4 = Button(text="2", background="#001d18", foreground="#1e90ff", padx="10", pady="6", font="5",command=insertText2)
  90. btn4.place(x=60, y=250)
  91.  
  92. btn5 = Button(text="5", background="#001d18", foreground="#1e90ff", padx="10", pady="6", font="5",command=insertText5)
  93. btn5.place(x=60, y=300)
  94.  
  95. btn6 = Button(text="8", background="#001d18", foreground="#1e90ff", padx="10", pady="6", font="5",command=insertText8)
  96. btn6.place(x=60, y=350)
  97.  
  98. btn7 = Button(text="3", background="#001d18", foreground="#1e90ff", padx="10", pady="6", font="5",command=insertText3)
  99. btn7.place(x=110, y=250)
  100.  
  101. btn8 = Button(text="6", background="#001d18", foreground="#1e90ff", padx="10", pady="6", font="5",command=insertText6)
  102. btn8.place(x=110, y=300)
  103.  
  104. btn9 = Button(text="9", background="#001d18", foreground="#1e90ff", padx="10", pady="6", font="5",command=insertText9)
  105. btn9.place(x=110, y=350)
  106.  
  107. btn11 = Button(text="0", background="#001d18", foreground="#1e90ff", padx="10", pady="6", font="5",command=insertText0)
  108. btn11.place(x=10, y=200)
  109.  
  110. btn10 = Button(text="+", background="#555", foreground="#000000", padx="10", pady="6", font="5",command=insertText11) # +
  111. btn10.place(x=160, y=250)
  112.  
  113. btn12 = Button(text="=", background="#e28b00", foreground="#000000", padx="10", pady="31", font="5",command=insertText12)# =
  114. btn12.place(x=160, y=301)
  115.  
  116. btn13 = Button(text="-", background="#555", foreground="#000000", padx="12", pady="6", font="5",command=insertText13)# -
  117. btn13.place(x=160, y=200)
  118.  
  119. btn14 = Button(text="/", background="#555", foreground="#000000", padx="13", pady="6", font="5",command=insertText14)# /
  120. btn14.place(x=110, y=200)
  121.  
  122. btn15 = Button(text="*", background="#555", foreground="#000000", padx="12", pady="6", font="5",command=insertText15)# *
  123. btn15.place(x=60, y=200)
  124.  
  125.  
  126.  
  127. text=Text(root,height=7,width=15,font='Arial 14',bg="black", fg='green',wrap=WORD) # текст
  128. text.pack()
  129. root.mainloop()
  130.  
  131.  
  132.  
  133. #Родилка тут
  134. root = Tk()
  135. root.title("Calculator")
  136. root.geometry("210x400")# размер окна
  137.  
  138. label = Label()
  139. label.pack()
  140.  
  141.  
  142. main_menu = Menu()
  143.  
  144. file_menu = Menu()
  145.  
  146.  
  147.  
  148. file_menu.add_command(label="Calculator", command=edit_click) #Сверху виджет
  149.  
  150.  
  151.  
  152. main_menu.add_cascade(label="New", menu=file_menu) #Сверху виджет
  153.  
  154. main_menu.add_command(label="Exit",command = close_win) #Сверху виджет
  155.  
  156.  
  157.  
  158.  
  159.  
  160.  
  161.  
  162. root.config(menu=main_menu)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement