Будь ласка допоможіть СРОЧНО! Програмування Python
Ви повинні створити одну програму в Python з текстовими полями, надписами, кнопками, перемикачами та прапорцями на тему "Україна" (наприклад: забарвлення вікон блакитно-жовте, текст-про Україну)
def update_text(): global rad_var, result_label if rad_var.get() == 0: result_label.configure(text = 'Ukraine, is Europe coutry') elif rad_var.get() == 1: result_label.configure(text = 'Kiev is the centre of the Ukraine') elif rad_var.get() == 2: result_label.configure(text = 'Odessa place on S arrow')
Answers & Comments
Verified answer
from tkinter import *def update_text():
global rad_var, result_label
if rad_var.get() == 0: result_label.configure(text = 'Ukraine, is Europe coutry')
elif rad_var.get() == 1: result_label.configure(text = 'Kiev is the centre of the Ukraine')
elif rad_var.get() == 2: result_label.configure(text = 'Odessa place on S arrow')
root = Tk()
root.columnconfigure(0, weight = 1)
root.rowconfigure((0, 1), weight = 1)
blue_frame = Frame(master = root, bg = 'blue')
blue_frame.grid(column = 0, row = 0, sticky = 'NSWE')
blue_frame.grid_propagate(0)
yellow_frame = Frame(master = root, bg = 'yellow')
yellow_frame.grid(column = 0, row = 1, sticky = 'NSWE')
yellow_frame.grid_propagate(0)
title_label = Label(master = blue_frame, text = "Ukraine!", fg = 'white', bg = 'blue', font = ('Consolas', 9), pady = 10)
title_label.pack(fill="x")
rad_frame = Frame(master = blue_frame, bg = 'blue')
rad_frame.pack(fill = 'x', pady = 10)
rad_var = IntVar()
rad_text = ["Ukraine", "Kiev", "Odessa"]
for num in range(3):
rb = Radiobutton(master = rad_frame, text = rad_text[num], value = num, variable = rad_var, bg = 'blue', border = 0, fg = 'white', command = update_text)
rb.pack()
def set_color():
global chb_var, yellow_frame, blue_frame
if chb_var.get() == True:
yellow_frame.configure(bg = 'yellow')
blue_frame.configure(bg = 'blue')
else:
yellow_frame.configure(bg = 'gray')
blue_frame.configure(bg = 'gray')
chb_var = BooleanVar()
color_chb = Checkbutton(master = blue_frame, text = 'Color', onvalue = True, offvalue = False, variable = chb_var, command = set_color)
color_chb.pack()
exit_button = Button(master = blue_frame, text = 'Exit', command = lambda: exit())
exit_button.pack(pady = 10)
result_label = Label(master = yellow_frame, text = '', bg = 'yellow', fg = 'black')
result_label.pack(pady = 20)
root.mainloop()