
Створіть новий файл Python та нове вікно із кнопкою. Розміри вікна 500х800, заголовок “Вікно 3”.
Кнопка розміщена в 200 пікселях від лівого краю та в 390 пікселях від верхнього краю, текст кнопка “Ок”. Колір кнопки та тексту довільний. При натисканні правою клавішею миші на кнопку колір фону вікна стане фіолетовим а кнопки жовтим та створиться вікно із повідомленням із заголовком “Завдання № 3” та текстом “Завдання

Ответы на вопрос

import tkinter
from tkinter import messagebox
def func(event=None):
root['bg'] = 'purple'
btn['bg'] = 'yellow'
messagebox.showinfo('Завдання № 3', 'Завдання')
root = tkinter.Tk()
root.title('Вікно 3')
root.geometry('500x800')
btn = tkinter.Button(text='Oк')
btn.bind('<Button-3>', func)
btn.place(x=200, y=390)
root.mainloop()



To create a new Python file with a new window and a button, you can use the Tkinter library in Python. Tkinter provides a set of tools for creating graphical user interfaces (GUIs). Here's an example of how you can create a new window with a button using Tkinter:
```python import tkinter as tk
def change_colors(event): window.configure(bg='purple') button.configure(bg='yellow')
def show_message(): message_window = tk.Toplevel(window) message_window.title("Завдання № 3") message_label = tk.Label(message_window, text="Завдання виконано!") message_label.pack()
window = tk.Tk() window.title("Вікно 3") window.geometry("500x800")
button = tk.Button(window, text="Ок")
button.place(x=200, y=390)
button.bind("
window.mainloop() ```
Let's break down the code:
1. We import the `tkinter` module and alias it as `tk` for convenience. 2. We define a function `change_colors` that will be called when the right mouse button is pressed on the button. This function changes the background color of the window to purple and the button to yellow. 3. We define another function `show_message` that will be called when the button is clicked. This function creates a new window (`Toplevel`) with the title "Завдання № 3" and a label with the text "Завдання виконано!". 4. We create the main window using `tk.Tk()` and set its title to "Вікно 3" and its size to 500x800 pixels. 5. We create a button using `tk.Button` and set its text to "Ок". We use the `place` method to position the button


Похожие вопросы
Топ вопросов за вчера в категории Информатика
Последние заданные вопросы в категории Информатика
-
Математика
-
Литература
-
Алгебра
-
Русский язык
-
Геометрия
-
Английский язык
-
Химия
-
Физика
-
Биология
-
Другие предметы
-
История
-
Обществознание
-
Окружающий мир
-
География
-
Українська мова
-
Информатика
-
Українська література
-
Қазақ тiлi
-
Экономика
-
Музыка
-
Право
-
Беларуская мова
-
Французский язык
-
Немецкий язык
-
МХК
-
ОБЖ
-
Психология
-
Физкультура и спорт
-
Астрономия
-
Кыргыз тили
-
Оʻzbek tili