QUESTION 1 Attached is an incomplete Consider the GUI below (1 Labe1,3 Buttons)
ID: 3748334 • Letter: Q
Question
QUESTION 1 Attached is an incomplete Consider the GUI below (1 Labe1,3 Buttons) which has been produced with a Python program using the Tkinter libeary Python template file. buton.colour,changer Opy Dowaload this tle and complete k to solve the following problem. Colourx Button Change Colourx Red Green Blue Red Green Blue Initial GUI GUI after interaction You are required to write a Python program to produce this interactive GUI including the same widgets displayed in the sample positions on the GUI, using the same colouns, shapes I bonder in the sample output does not need to be replicated as this is an operating system environment Your GUI must not contain any elements that are not in the example provided above, and must interact with the user as follows: Initially, the Labe1 is displayed in grey in default colour (which may look different on your machine, depending on your operating system.) e Whenever the user hits ose of the Buttons, the Label is displayed in the colour corresponding to the text shown on the Blutton Once complete, upload your Python file as your answer to this question. Make sure yow remember to complete your student number and name in the beginning of the template file.Explanation / Answer
#This is the program to design the above GUI before and after an interaction in Python.
from tkinter import *
window = Tk()
frame = Frame(window)
frame.grid()
# construct a label and attach it to the frame:
label = Label(frame, width = 40, bg="Grey")
label.grid(row =0, column=1, padx=5,pady=5)
# position it in the frame:
label.grid()
def button1call():
label["bg"]= "Blue"
# construct a button and attach it to the frame:
button1 = Button(frame, text = "Blue", command = button1call)
button1.grid(row=2, column=0, padx=60)
def button2call():
label["bg"]= "Red"
# again create a button:
button2 = Button(frame, text = "Red", command = button2call)
button2.grid(row=2, column=1,padx=60)
def button3call():
label["bg"]= "Grey"
button3 = Button(frame, text = "Grey", command = button3call)
button3.grid(row=2, column=2,padx=60)
# This command starts the window's controller function so that
# the window can respond to the user's interactions with it:
window.mainloop()
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.