Вопрос задан 13.12.2023 в 06:42. Предмет Информатика. Спрашивает Рысмаханова Зере.

Створити вікна для віджетів розміром 250*250 зеленого кольору. Додати кнопку червоного кольору

10*15 з текстом «Старт». При натисканні кнопки змінюється колір фону та колір тексту.
0 0
Перейти к ответам

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

Внимание! Ответы на вопросы дают живые люди. Они могут содержать ошибочную информацию, заблуждения, а также ответы могут быть сгенерированы нейросетями. Будьте внимательны. Если вы уверены, что ответ неверный, нажмите кнопку "Пожаловаться" под ответом.
Отвечает Кузьменко Аня.

Ответ:

from tkinter import *

root = Tk()

root.geometry('250x250')

root['bg']='green'

def i1():

   root.configure(bg='yellow')

   b1.config(fg='black')

b1 = Button(text='Старт', bg='red', fg='white', width=10, height=15, command=i1)

b1.pack()

root.mainloop()

Объяснение:

фото



0 0
Отвечает нейросеть ChatGpt. Будьте внимательны, ответы нейросети могут содержать ошибочные или выдуманные данные.

Creating Windows and Widgets with Color and Button

To create windows for widgets with a size of 250x250 and a green color, and to add a red-colored button with the text "Start" measuring 10x15, we can use the following code:

```python from tkinter import *

# Create the main window root = Tk() root.geometry('250x250') root.configure(bg='green')

# Function to change the colors on button click def change_colors(): if root.cget('bg') == 'green': root.configure(bg='blue') button.config(bg='yellow', fg='black') else: root.configure(bg='green') button.config(bg='red', fg='white')

# Create the button button = Button(root, text='Start', bg='red', fg='white', command=change_colors) button.place(x=10, y=15)

# Run the application root.mainloop() ```

When the button is pressed, the background color and text color of the window will change.

This code creates a window with the specified dimensions and color, and adds a button with the specified color and text. When the button is clicked, it toggles the background and text colors of the window.

Feel free to try out this code and let me know if you have any questions or need further assistance!

0 0

Похожие вопросы

Топ вопросов за вчера в категории Информатика

Последние заданные вопросы в категории Информатика

Задать вопрос