2: Modify the Sign() class to take in an optional parameter of type list that ha
ID: 3711356 • Letter: 2
Question
2: Modify the Sign() class to take in an optional parameter of type list that has 3 sentences that can be displayed on the screen. If there aren’t three items in the list, then the default message as shown in problem 1 will be displayed.from tkinter import Label,Tk class Sign(Tk): def __init__(self,parent=None): Tk.__init__(self, parent) self.make_widgets()
def make_widgets(self): pass
Sign().mainloop() 2: Modify the Sign() class to take in an optional parameter of type list that has 3 sentences that can be displayed on the screen. If there aren’t three items in the list, then the default message as shown in problem 1 will be displayed.
from tkinter import Label,Tk class Sign(Tk): def __init__(self,parent=None): Tk.__init__(self, parent) self.make_widgets()
def make_widgets(self): pass
Sign().mainloop()
Explanation / Answer
from tkinter import Label,Tk, StringVar, RAISED, Text
class Sign(Tk):
def __init__(self,parent=None, label=['GREAT DEAL!', 'Android 1.0 Phones for $10!', 'Security vulnerabilities included!']):
root = Tk.__init__(self, parent)
for line in label:
var = StringVar()
var.set(line)
text1 = Label( root, textvariable=var, relief=RAISED )
text1.pack()
self.make_widgets()
def make_widgets(self):
pass
Sign().mainloop()
# copy pastable code link: https://paste.ee/p/5Wi8h
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.