Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python3
- import tkinter as tk
- root = tk.Tk()
- root.title('Calculatov v2.0')
- num = 0
- def insert_nums(num):
- entry1.insert(tk.END, num)
- buttons = [
- '7', '4', '1', '0',
- '8', '5', '2', '.',
- '9', '6', '3', '=',
- '<<<', '/', '*', '-', '+',
- ]
- frame0 = tk.Frame(root)
- frame0.pack(expand=tk.YES, fill=tk.BOTH)
- frame1 = tk.Frame(root)
- frame1.pack(side=tk.LEFT, expand=tk.YES, fill=tk.BOTH)
- frame2 = tk.Frame(root)
- frame2.pack(side=tk.LEFT, expand=tk.YES, fill=tk.BOTH)
- frame3 = tk.Frame(root)
- frame3.pack(side=tk.LEFT, expand=tk.YES, fill=tk.BOTH)
- frame4 = tk.Frame(root)
- frame4.pack(side=tk.LEFT, expand=tk.YES, fill=tk.BOTH)
- entry1 = tk.Entry(frame0, bg='#2C3033', fg='#FFFFFF', font='Helvetica 18 bold', bd='10')
- entry1.pack(expand=tk.YES, fill=tk.BOTH)
- for button in buttons[0:4]:
- Button = tk.Button(frame1, text=button, width=5, heigh=2, bg='#202125', fg='#FFFFFF', font='Helvetica 18 bold', command=insert_nums(num=button))
- Button.pack(expand=tk.YES, fill=tk.BOTH)
- for button in buttons[4:8]:
- Button = tk.Button(frame2, text=button, width=5, heigh=2, bg='#202125', fg='#FFFFFF', font='Helvetica 18 bold')
- Button.pack(expand=tk.YES, fill=tk.BOTH)
- for button in buttons[8:12]:
- Button = tk.Button(frame3, text=button, width=5, heigh=2, bg='#202125', fg='#FFFFFF', font='Helvetica 18 bold')
- Button.pack(expand=tk.YES, fill=tk.BOTH)
- for button in buttons[12:17]:
- Button = tk.Button(frame4, text=button, width=5, heigh=1, bg='#202125', fg='#174FA6', font='Helvetica 18 bold')
- Button.pack(expand=tk.YES, fill=tk.BOTH)
- root.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement