from tkinter import *
window = Tk()
window .geometry('450x700')
window .title("Навчаємося від простого")
# Функція для виділення заголовка
def highlight_title(event):
a.config(bg="yellow")
# Функція для вставки даних в поле примітки
def insert_data(event):
note_text.delete(1.0, END) # Очищення вмісту поля примітки
note_text.insert(END, f"Ім'я: {first_name_entry.get()} {second_name_entry.get()}\n")
if sex_male.get():
note_text.insert(END, "Стать: Чоловік\n")
elif sex_female.get():
note_text.insert(END, "Стать: Жінка\n")
a = Label(window , text="Анкета з даними")
a.pack()
first_name_label = Label(window , text="Введіть ваше ім'я")
first_name_label.pack()
first_name_entry = Entry(window )
first_name_entry.pack()
second_name_label = Label(window , text="Введіть ваше прізвище")
second_name_label.pack()
second_name_entry = Entry(window )
second_name_entry.pack()
sex_label = Label(window , text="Оберіть вашу стать")
sex_label.pack()
sex_male = BooleanVar()
male_checkbutton = Checkbutton(window , text="Чоловік", variable=sex_male)
male_checkbutton.pack()
sex_female = BooleanVar()
female_checkbutton = Checkbutton(window , text="Жінка", variable=sex_female)
female_checkbutton.pack()
light_button = Button(window , text="Виділити заголовок")
light_button.bind("<Button-1>", highlight_title)
light_button.pack()
default_button = Button(window , text="Очистити поля")
default_button.bind("<Button-1>", lambda event: [first_name_entry.delete(0, END),
second_name_entry.delete(0, END),
sex_male.set(True)])
default_button.pack()
note_text = Text(window , height=8, width=40)
note_text.pack()
insert_data_button = Button(window , text="Отримати дані")
insert_data_button.bind("<Button-1>", insert_data)
insert_data_button.pack()
window .mainloop()