How to make a simple calculator in python (code in desc.) #shorts #code #vscode #python

preview_player
Показать описание
Here is the python script!:

import tkinter as tk

def on_click(button_text):

def on_clear():

def on_equal():
try:
except Exception as e:

window = tk.Tk()

entry = tk.Entry(window, width=20, font=("Arial", 28), borderwidth=2, relief="solid", justify="right", bd=10)

button_style = {
"font": ("Arial", 18),
"width": 5,
"height": 2,
"bd": 5,
"relief": "raised",
"bg": "#4C5C68",
"fg": "#fff",
"activebackground": "#2C3E50",
"activeforeground": "#fff"
}

buttons = [
('7', 1, 0), ('8', 1, 1), ('9', 1, 2), ('/', 1, 3),
('4', 2, 0), ('5', 2, 1), ('6', 2, 2), ('*', 2, 3),
('1', 3, 0), ('2', 3, 1), ('3', 3, 2), ('-', 3, 3),
('0', 4, 0), ('.', 4, 1), ('=', 4, 2), ('+', 4, 3),
('C', 5, 0)
]

for (text, row, col) in buttons:
if text == '=':
button = tk.Button(window, text=text, **button_style, command=on_equal)
elif text == 'C':
button = tk.Button(window, text=text, **button_style, command=on_clear)
else:
button = tk.Button(window, text=text, **button_style, command=lambda t=text: on_click(t))

Рекомендации по теме
Комментарии
Автор

Damn bro... Amazing script! Keep up the good work!!

BS_Krik
visit shbcf.ru