Advertisement
Guest User

Untitled

a guest
Mar 25th, 2020
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.58 KB | None | 0 0
  1. #!/usr/bin/env python3
  2.  
  3. import tkinter as tk
  4.  
  5. root = tk.Tk()
  6. root.title('Calculatov v2.0')
  7.  
  8. num = 0
  9.  
  10.  
  11. def insert_nums(num):
  12. entry1.insert(tk.END, num)
  13.  
  14.  
  15.  
  16. buttons = [
  17. '7', '4', '1', '0',
  18. '8', '5', '2', '.',
  19. '9', '6', '3', '=',
  20. '<<<', '/', '*', '-', '+',
  21. ]
  22.  
  23. frame0 = tk.Frame(root)
  24. frame0.pack(expand=tk.YES, fill=tk.BOTH)
  25. frame1 = tk.Frame(root)
  26. frame1.pack(side=tk.LEFT, expand=tk.YES, fill=tk.BOTH)
  27. frame2 = tk.Frame(root)
  28. frame2.pack(side=tk.LEFT, expand=tk.YES, fill=tk.BOTH)
  29. frame3 = tk.Frame(root)
  30. frame3.pack(side=tk.LEFT, expand=tk.YES, fill=tk.BOTH)
  31. frame4 = tk.Frame(root)
  32. frame4.pack(side=tk.LEFT, expand=tk.YES, fill=tk.BOTH)
  33.  
  34. entry1 = tk.Entry(frame0, bg='#2C3033', fg='#FFFFFF', font='Helvetica 18 bold', bd='10')
  35. entry1.pack(expand=tk.YES, fill=tk.BOTH)
  36.  
  37. for button in buttons[0:4]:
  38. Button = tk.Button(frame1, text=button, width=5, heigh=2, bg='#202125', fg='#FFFFFF', font='Helvetica 18 bold', command=insert_nums(num=button))
  39. Button.pack(expand=tk.YES, fill=tk.BOTH)
  40.  
  41. for button in buttons[4:8]:
  42. Button = tk.Button(frame2, text=button, width=5, heigh=2, bg='#202125', fg='#FFFFFF', font='Helvetica 18 bold')
  43. Button.pack(expand=tk.YES, fill=tk.BOTH)
  44.  
  45. for button in buttons[8:12]:
  46. Button = tk.Button(frame3, text=button, width=5, heigh=2, bg='#202125', fg='#FFFFFF', font='Helvetica 18 bold')
  47. Button.pack(expand=tk.YES, fill=tk.BOTH)
  48.  
  49. for button in buttons[12:17]:
  50. Button = tk.Button(frame4, text=button, width=5, heigh=1, bg='#202125', fg='#174FA6', font='Helvetica 18 bold')
  51. Button.pack(expand=tk.YES, fill=tk.BOTH)
  52.  
  53. root.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement