Hola a todos aquí les dejo una calculadora sin funcionalidad.
Espero les guste o puede que no
Código
from tkinter import Tk from tkinter import ttk from math import floor class App(ttk.Frame): def __init__(self, master): super().__init__(master) self.pack() # Variables self.screen = None # Metodos de clase self.style_widgets() self.create_widgets() # Estilos de los componentes del Frame def style_widgets(self): # estilos generales ttk.Style().configure("TEntry", foreground="#00000a9") ttk.Style().configure("TButton", width=10, padding=( 15, 10), relief=ttk.tkinter.FLAT) ttk.Style().configure("E.TButton", background="#709234") ttk.Style().configure("OP.TButton", background="#cccccc") def create_widgets(self): self.screen = ttk.Entry(self) self.screen.config(justify=ttk.tkinter.RIGHT) self.screen.grid(row=1, column=1, ipady=20, columnspan=4, sticky="NSWE") # Crear botones dic_buttons = {} # diccionario de botones for i in range(1, 13): dic_buttons[f"btn{i}"] = ttk.Button(self, text=f"{i}") dic_buttons.update([("btnmul", ttk.Button(self, text="x")), ("btndif", ttk.Button(self, text="-")), ("btnplus", ttk.Button(self, text="+")), ("btnmod", ttk.Button(self, text="/"))]) dic_buttons["btn9"].grid(row=2, column=1) dic_buttons["btn8"].grid(row=2, column=2) dic_buttons["btn7"].grid(row=2, column=3) dic_buttons["btnmul"].grid(row=2, column=4) dic_buttons["btn6"].grid(row=3, column=1) dic_buttons["btn5"].grid(row=3, column=2) dic_buttons["btn4"].grid(row=3, column=3) dic_buttons["btndif"].grid(row=3, column=4) dic_buttons["btn3"].grid(row=4, column=1) dic_buttons["btn2"].grid(row=4, column=2) dic_buttons["btn1"].grid(row=4, column=3) dic_buttons["btnplus"].grid(row=4, column=4) dic_buttons["btn10"].grid(row=5, column=1) dic_buttons["btn11"].grid(row=5, column=2) dic_buttons["btn12"].grid(row=5, column=3) dic_buttons["btnmod"].grid(row=5, column=4) dic_buttons["btn10"].config(text=",") dic_buttons["btn11"].config(text="0") dic_buttons["btn12"].config(text="=", style="E.TButton") # print(dic_buttons.keys()) dic_buttons["btnmul"].config(style="OP.TButton") dic_buttons["btndif"].config(style="OP.TButton") dic_buttons["btnplus"].config(style="OP.TButton") dic_buttons["btnmod"].config(style="OP.TButton") if __name__ == "__main__": root = Tk() root.resizable(False, False) root.title("ttk Example") app = App(root) app.mainloop()