Question

Hello I just need the code for this GUI thanks

Also computer screenshot of the code will be helpful

Attached is an incomplete Python template file. button_multi_colour_changer_Q.py Download this file and complete it to solve

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Detailed input (Source code) screenshots and output screenshots have been provided for user convenience please go through it and modify any thing if required.

Thank You.

source code:

import tkinter as tk
class gui:
def __init__(self,m):
self.m= m #Creates window
m.title("MULTI Button Colour") #sets window title

#Creates four label and arraged them using grid
self.l1 = tk.Label(m,text="",bg="grey",width=10)
self.l1.grid(row=0,column=0, padx=5, pady=5)
self.l2 = tk.Label(m,text="",bg="grey",width=10)
self.l2.grid(row=0,column=1,padx=5, pady=5)
self.l3 = tk.Label(m,text="",bg="grey",width=10)
self.l3.grid(row=0,column=2,padx=5, pady=5)
self.l4 = tk.Label(m,text="",bg="grey",width=10)
self.l4.grid(row=0,column=3,padx=5, pady=5)
#created four buttons and arranged them using grid
self.b1=tk.Button(m,text="Violet",command=self.b1c,width=10)
self.b1.grid(row=1,column=0,padx=5, pady=5)
self.b2=tk.Button(m,text="Purple",command=self.b2c,width=10)
self.b2.grid(row=1,column=1,padx=5, pady=5)
self.b3=tk.Button(m,text="Blue",command=self.b3c,width=10)
self.b3.grid(row=1,column=2,padx=5, pady=5)
self.b4=tk.Button(m,text="Green",command=self.b4c,width=10)
self.b4.grid(row=1,column=3,padx=5, pady=5)
#One more button for reset option
self.b5=tk.Button(m,text="Reset",command=self.reset,width=10)
self.b5.grid(row=2,column=0,columnspan=4,padx=5, pady=5)
#five functions for five buttons
def b1c(self):
self.l1.config(bg="violet")
def b2c(self):
self.l2.config(bg="purple")
def b3c(self):
self.l3.config(bg="blue")
def b4c(self):
self.l4.config(bg="green")
def reset(self):
self.l1.config(bg="grey")
self.l2.config(bg="grey")
self.l3.config(bg="grey")
self.l4.config(bg="grey")

root=tk.Tk()
gui = gui(root)
root.mainloop()

import tkinter as tk class gui def init (self,m) self.m m #Creates window m. title (MULTI Button Colour) #sets window title

root- tk. Tk ) gui gui (root) = root.mainloop (

output:

MULTI Button Colour X Violet Purple Blue Green Reset

MULTI Button Colour X Violet Purple Blue Green Reset

Add a comment
Know the answer?
Add Answer to:
Hello I just need the code for this GUI thanks Also computer screenshot of the code...
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
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