Question

Python

Consider the GUI below (3 Labels and 3 Radiobuttons) which has been produced with a Python program using the Tkinter library.  

Attached is an incomplete Python template file radio_label changer Qpy. Download this file and complete it to solve the follo

× | ロ × Label Ch Label Changer × Label Ch anger _ anger _ Ready Set. GO GUI after interaction

You are required to write a Python program to produce this interactive GUI.

Your GUI must replicate the example above as closely as possible, including the same widgets displayed in the sample positions on the GUI, using the same colours, shapes and relative sizes. (Note that the GUI border in the sample output does not need to be replicated as this is an operating system environment setting.)

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 Labels are grey and display no text.
  • Whenever Radiobutton 1 is selected by the user, the first Label changes colour and displays the text "Ready..."
  • Whenever Radiobutton 2 is selected by the user, the second Label changes colour and displays the text "Set..."
  • Whenever Radiobutton 3 is selected by the user, the third Label changes colour and displays the text "...GO!"

THE FOLLOWING IS THE START OF THE PYTHON CODE:

#----------------------------------------------------------------
#
# 3 labels, 3 radiobuttons (as per diagram)
# Initially, the Labels are grey and display no text.
# When Radiobutton 1 is selected by the user, the first Label
# changes colour and displays the text "Ready..."
# When Radiobutton 2 is selected by the user, the second Label
# changes colour and displays the text "Set..."
# When Radiobutton 3 is selected by the user, the third Label
# changes colour and displays the text "...GO!"
#----------------------------------------------------------------

# Import the Tkinter functions
from tkinter import *

# Create a window
the_window = Tk()

# Give the window a title
the_window.title('Label Changer')

# PUT YOUR CODE HERE-------------------------------------------------#


# -------------------------------------------------------------------#

# Start the event loop
the_window.mainloop()

Attached is an incomplete Python template file radio_label changer Qpy. Download this file and complete it to solve the following problem. Consider the GUI below (3 Labels and 3 Radiobuttons) which has been produced with a Python program using the Tkinter library Label Changer × - 12 3 Initial GUI
× | ロ × Label Ch Label Changer × Label Ch anger _ anger _ Ready Set. GO GUI after interaction
0 0
Add a comment Improve this question Transcribed image text
Answer #1

import tkinter as tk
from tkinter import *

root = tk.Tk() # making window
root.title('Label Changer') # giving title to window

# making a list for storing object of labels for each row
labels = []
# making 3 labels and making their default color gray
for i in range(3):
    labels.append(tk.Label(relief=tk.RIDGE,bg='gray', width=35,height=3))
    labels[i].pack(padx=2, pady=3)

# function that will respond as per the selected radio button
def sel():
    selection = v.get()
    if selection == 1: # true if first radio button was selected
        labels[0].config(bg='red',text='Ready...')
        labels[1].config(bg='gray',text='')
        labels[2].config(bg='gray',text='')
      
    elif selection == 2: # true if second radio button was selected
        labels[0].config(bg='gray',text='')
        labels[1].config(bg='yellow',text='Set...')
        labels[2].config(bg='gray',text='')
          
    elif selection == 3:# true if thrid radio button was selected
        labels[0].config(bg='gray',text='')
        labels[1].config(bg='gray',text='')
        labels[2].config(bg='green',text='...Go!')

    else:
        root.quit()

v = IntVar()
# making radio buttons
r1 = Radiobutton(root, text="1", variable=v, value=1,command = sel)
r1.pack(side = LEFT,padx=25)
r2 = Radiobutton(root, text="2", variable=v, value=2,command = sel)
r2.pack(side = LEFT,padx=25)
r3 = Radiobutton(root, text="3", variable=v, value=3,command = sel)
r3.pack(side = LEFT,padx=25)

tk.mainloop()# run endless

import tkinter as tk from tkinter import root = tk.Tk() # making window root . title (Label Changer) # giving title to wind

elif selecti n-= 2: # true if second radio button was selected labels [0].config (bg-gray, text-) labels [1] . config (bg=

Sample Output:

Label Changer

Label Changer Ready..

Label Changer Set...

φ Label Changer

Add a comment
Know the answer?
Add Answer to:
Python Consider the GUI below (3 Labels and 3 Radiobuttons) which has been produced with a Python program using the Tkinter library.   You are required to write a Python program to produce this inte...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • C+ HelloVisualWorld, pages 121-125 (in the 3-6 Deciding Which Interface to Use Section) We were unable...

    C+ HelloVisualWorld, pages 121-125 (in the 3-6 Deciding Which Interface to Use Section) We were unable to transcribe this imageCHAPTER 3 Using Guy Objects and the Visual Studio IDE Using Gul Objects (continued) Forn click the Form, its Properties window appears in the lower right portion of the screen, and you can see that the Text property for the Form IS set to Forml. Take a moment to scroll through the list in the Properties Window, examining the values of...

  • could you please help me with this problem, also I need a little text so I...

    could you please help me with this problem, also I need a little text so I can understand how you solved the problem? import java.io.File; import java.util.Scanner; /** * This program lists the files in a directory specified by * the user. The user is asked to type in a directory name. * If the name entered by the user is not a directory, a * message is printed and the program ends. */ public class DirectoryList { public static...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT