Mensagens

A mostrar mensagens de dezembro, 2024

Fogos de Artifício

import tkinter as tk import random class Firework: def __init__ ( self , canvas , x , y): self .canvas = canvas self .x = x self .y = y self .particles = [] self .create_firework() def create_firework ( self ): # Criar uma explosão de partículas for _ in range ( 50 ): # Número de partículas angle = random.uniform( 0 , 2 * 3.14159 ) # Ângulo aleatório speed = random.uniform( 1 , 5 ) # Velocidade aleatória particle = { 'x' : self .x , 'y' : self .y , 'dx' : speed * random.uniform(- 1 , 1 ) , # Movimento em X 'dy' : speed * random.uniform(- 1 , - 3 ) , # Movimento em Y 'color' : random.choice([ 'red' , 'blue' , 'green' , 'yellow' , 'purple' , 'orange' ]) , 'size' : random.randint( 5 , 10 ) ...

Feriados Nacionais em Portugal

from datetime import datetime , timedelta root = Tk() root.geometry( "700x600" ) root.resizable( 0 , 0 ) root.config( bg = "#103030" ) feriados_nacionais = { "Ano Novo" : "2025-01-01" , "Sexta-feira Santa" : "2025-04-18" , "Dia da Liberdade" : "2025-04-25" , "Dia do Trabalhador" : "2025-05-01" , "Corpo de Deus" : "2025-06-19" , "Dia de Portugal" : "2025-06-10" , "Assunção de Nossa Senhora" : "2025-08-15" , "Implantação da República" : "2025-10-05" , "Dia de Todos os Santos" : "2025-11-01" , "Restauração da Independência" : "2025-12-01" , "Imaculada Conceição" : "2025-12-08" , "Natal" : "2025-12-25" , } dias_semana_portugues = { "Monday" : "Segunda-feira" , ...

Teste de idade futura

from datetime import datetime from tkinter import * from tkinter import ttk , messagebox root = Tk() root.geometry( "600x450" ) root.resizable( 0 , 0 ) root.config( bg = "#103030" ) root.title( "Teste de idade futura" ) titulo = Label(root , text = "Teste de idade futura" , font =( "Arial" , "28" , "bold" ) , bg = "#103030" , fg = "#49e3e3" ) titulo.place( relx = 0.15 , rely = 0.05 ) texto_sub1 = Label(root , text = "Nome :" , font =( "Arial" , "18" , "bold" ) , bg = "#103030" , fg = "#49e3e3" ) texto_sub1.place( relx = 0.32 , rely = 0.2 ) texto_sub2 = Label(root , text = "Quantos anos tem? :" , font =( "Arial" , "18" , "bold" ) , bg = "#103030" , fg = "#49e3e3" ) texto_sub2.place( relx = 0.1 , rely = 0.35 ) texto_sub3 = Label(root , text = "Ano quer saber sua...

Contagem Regressiva para o Ano Novo de 2025

from tkinter import * from datetime import datetime def update_countdown (): now = datetime.now() next_new_year = datetime(now.year + 1 , 1 , 1 ) time_left = next_new_year - now seconds_left = int (time_left.total_seconds()) if seconds_left == 0 : countdown_label.config( text = "Feliz Ano Novo! \n Feliz Ano de 2025!" ) elif seconds_left <= 5 and seconds_left > 0 : countdown_label.config( text = f" { seconds_left } " , font =( "Helvetica" , 32 ) , fg = "red" ) else : countdown_label.config( text = f"Faltam { seconds_left } segundos para 2025" , font =( "Helvetica" , 20 , "bold" ) , fg = "blue" ) root.after( 1000 , update_countdown) root = Tk() root.title( "Contagem Regressiva para o Ano Novo" ) root.geometry( "700x200" ) root.resizable( 0 , 0 ) countdown_label = Label(root , font =( "Helveti...

Radar de Velocidade

from tkinter import * import emoji root = Tk() root.geometry( "300x300" ) root.resizable( 0 , 0 ) root.config( bg = "#103030" ) root.title( "Radar de Velocidade" ) titulo = Label( text = "Radar de Velocidade" , font =( "Arial" , "20" , "bold" ) , bg = "#103030" , fg = "#49e3e3" ) titulo.place( relx = 0.03 , rely = 0.05 ) sub1 = Label( text = "Velocidade" , font =( "Arial" , "16" , "bold" ) , bg = "#103030" , fg = "#49e3e3" ) sub1.place( relx = 0.35 , rely = 0.25 ) Velocidade = StringVar() Velocidade_entrada = Entry( textvariable =Velocidade , font =( "Arial" , "12" , "bold" ) , bg = "white" , fg = "blue" , justify = 'center' ) Velocidade_entrada.place( relx = 0.3 , rely = 0.35 , relwidth = 0.45 ) Velo...

Contagem de Palavras de um Texto

from tkinter import * root = Tk() root.geometry( "700x400" ) root.resizable( 0 , 0 ) root.config( bg = "#103030" ) root.title( "Contagem de Palavras de um Texto" ) # Título titulo = Label( text = "Contagem de Palavras de um Texto" , font =( "Arial" , "28" , "bold" ) , bg = "#103030" , fg = "#49e3e3" ) titulo.place( relx = 0.06 , rely = 0.05 ) texto_sub1 = Label( text = "Texto" , font =( "Arial" , "20" , "bold" ) , bg = "#103030" , fg = "#49e3e3" ) texto_sub1.place( relx = 0.45 , rely = 0.25 ) Texto_entrada = Text(root , font =( "Arial" , "12" , "bold" ) , bg = "white" , fg = "blue" , wrap = "word" , height = 6 , width = 70 ) Texto_entrada.place( relx = 0.15 , rely = 0.33 , relwidth = 0.7 , relheight = 0.2 ) scrollbar_entrada = Scrollbar(root , or...

Área de uma coroa circular

from tkinter import * import math # Configuração da janela root = Tk() root.geometry( "600x400" ) root.resizable( 0 , 0 ) root.config( bg = "#103030" ) root.title( "Área de uma coroa circular" ) # Título titulo = Label( text = "Área de uma coroa circular" , font =( "Arial" , "28" , "bold" ) , bg = "#103030" , fg = "#49e3e3" ) titulo.place( relx = 0.1 , rely = 0.05 ) # Subtítulos texto_sub1 = Label( text = "Raio maior:" , font =( "Arial" , "18" , "bold" ) , bg = "#103030" , fg = "#49e3e3" ) texto_sub1.place( relx = 0.2 , rely = 0.25 ) texto_sub2 = Label( text = "Raio menor:" , font =( "Arial" , "18" , "bold" ) , bg = "#103030" , fg = "#49e3e3" ) texto_sub2.place( relx = 0.2 , rely = 0.45 ) # Entradas Raio_maior = StringVar() Rai...

Converter Nota

from tkinter import * root = Tk() root.geometry( "400x400" ) root.resizable( 0 , 0 ) root.config( bg = "#103030" ) root.title( "Converter Nota" ) titulo = Label( text = "Converter Nota" , font =( "Arial" , "28" , "bold" ) , bg = "#103030" , fg = "#49e3e3" ) titulo.place( relx = 0.13 , rely = 0.05 ) texto_sub1 = Label( text = "Nota (de 0-100) : " , font =( "Arial" , "18" , "bold" ) , bg = "#103030" , fg = "#49e3e3" ) texto_sub1.place( relx = 0.1 , rely = 0.32 ) Nota = StringVar() Nota_entrada = Entry( textvariable =Nota , font =( "Arial" , "12" , "bold" ) , bg = "white" , fg = "blue" , justify = 'center' ) Nota_entrada.place( relx = 0.6 , rely = 0.33 , relwidth = 0.3 ) def limpar (): Nota_entrada.delet...

Desejos para o Ano Novo

rom tkinter import * import random from tkinter.ttk import Progressbar root = Tk() root.geometry( "700x500" ) root.resizable( 0 , 0 ) root.config( bg = "#103030" ) root.title( "Desejos para o Ano Novo" ) titulo = Label(root , text = "FELIZ ANO NOVO 2025!" , font =( "Arial" , 28 , "bold" ) , bg = "#103030" , fg = "#49e3e3" ) titulo.place( relx = 0.18 , rely = 0.05 ) desejos = [ "Muita saúde e felicidade!" , "Que os seus sonhos se concretizem!" , "Amor e união com a família e amigos!" , "Que este ano seja repleto de conquistas!" , "Boas energias e muitos sorrisos!" , "Paz, prosperidade e harmonia todos os dias!" , "Viagens, aventuras e memórias inesquecíveis!" , "Tempo de qualidade com os que ama!" , "Muito sucesso pessoal e profissional!" , "Que a alegria acomp...