Створіть проект «Сторони горизонту».
Проект містить 4 кнопки, окрашує форму у певний кольор і виводить назву сторони горизонту англійською мовою.
мова програмування:PYTHON
Ответы на вопрос
import tkinter
# Create the main window
main_window = tkinter.Tk()
# Create the buttons
north_button = tkinter.Button(main_window, text = "North", bg = "red")
east_button = tkinter.Button(main_window, text = "East", bg = "blue")
south_button = tkinter.Button(main_window, text = "South", bg = "green")
west_button = tkinter.Button(main_window, text = "West", bg = "yellow")
# Place the buttons in the main window
north_button.pack()
east_button.pack()
south_button.pack()
west_button.pack()
# Create a function to print the direction when a button is clicked
def print_direction(direction):
print(direction)
# Connect the buttons to the function
north_button.configure(command = lambda: print_direction("North"))
east_button.configure(command = lambda: print_direction("East"))
south_button.configure(command = lambda: print_direction("South"))
west_button.configure(command = lambda: print_direction("West"))
# Run the main loop
main_window.mainloop()