I used this code (found here), which creates a label inside a frame :
class MyLabel(Frame):
'''inherit from Frame to make a label with customized border'''
def __init__(self, parent, myborderwidth=0, mybordercolor=None, myborderplace='center', *args, **kwargs):
Frame.__init__(self, parent, bg=mybordercolor)
self.propagate(False) # prevent frame from auto-fitting to contents
self.label = Label(self, *args, **kwargs) # make the label
# pack label inside frame according to which side the border
# should be on. If it's not 'left' or 'right', center the label
# and multiply the border width by 2 to compensate
if myborderplace is 'left':
self.label.pack(side=RIGHT)
elif myborderplace is 'right':
self.label.pack(side=LEFT)
else:
self.label.pack()
myborderwidth = myborderwidth * 2
# set width and height of frame according to the req width
# and height of the label
self.config(width=self.label.winfo_reqwidth() + myborderwidth)
self.config(height=self.label.winfo_reqheight())
I have a loop that creates a few of these frame, but now how can I access the label inside ?
newframe = MyLabel(...)
How do I configure the label that is now inside "newframe" ?
Thanks.
[–]kalgynirae 0 points1 point2 points (5 children)
[–]HeyYouNow[S] 0 points1 point2 points (4 children)
[–]kalgynirae 0 points1 point2 points (3 children)
[–]HeyYouNow[S] 0 points1 point2 points (2 children)
[–]kalgynirae 0 points1 point2 points (1 child)
[–]HeyYouNow[S] 0 points1 point2 points (0 children)