Mundo em Python

Contador

from tkinter import *

root = Tk()

numero = 0

root.geometry("500x300")
root.resizable(0, 0)
root.title("Contador")
root.config(bg="#033b39") texto = Label(root, text="Contador", font=("Arial", "35", "bold"), bg="#033b39", fg="#72e0dc")
texto.place(relx=0.25, rely=0.05) contador = Label(root, text=numero, font=("Arial", "70", "bold"), bg="#033b39", fg="#72e0dc")
contador.place(relx=0.4, rely=0.35) def somar():
global numero
numero += 1
contador.config(text=numero) def Subtrair():
global numero
numero -= 1
contador.config(text=numero) but1 = Button(text="Somar", bd=2, bg='#107db2', fg='white',
font=('verdana', 12, 'bold'), command=somar)
but1.place(relx=0.15, rely=0.7, relwidth=0.25, relheight=0.1)
but2 = Button(text="Subtrair", bd=2, bg='#107db2', fg='white',
font=('verdana', 12, 'bold'), command=Subtrair)
but2.place(relx=0.55, rely=0.7, relwidth=0.25, relheight=0.1) root.mainloop()
0