Cadastro
Cadastro simples com nome e idade.import customtkinter as ctk def register(): try: nome = field_nome.get() idade = int(field_idade.get()) text_2.configure(text=f'Você cadastrou {nome} com a idade {idade}.') except ValueError: text_2.configure(text='Por favor, digite valores válidos') ctk.set_appearance_mode('dark') window = ctk.CTk() window.geometry('300x300') window.minsize(250, 250) window.title('Tela de Cadastro') text_1 = ctk.CTkLabel(window, text='CADASTRO DE USUÁRIO') text_1.pack(pady=10) text_nome = ctk.CTkLabel(window, text='Nome:') text_nome.pack(pady=5) field_nome = ctk.CTkEntry(window, placeholder_text='Digite o nome', placeholder_text_color='green') field_nome.pack(pady=5) text_idade = ctk.CTkLabel(window, text='Idade:') text_idade.pack(pady=5) field_idade = ctk.CTkEntry(window, placeholder_text='Ditite a idade', placeholder_text_color='green') field_idade.pack(pady=5) button_register = ctk.CTkButton(window, text='Calcular', command=register) button_register.pack(pady=20) text_2 = ctk.CTkLabel(window, text='', text_color='green') text_2.pack(pady=5) window.mainloop()
Leave a Comment