Reputation: 620
is there any way to use same label multiple times? what I have is:
emptyRow = Label(frame)
and when I want use that empty row I call it like this:
emptyRow.grid(row=0)
emptyRow.grid(row=3)
i can only have latest call on that grid so row=0 will be ignored and row=3 will be used, any way to reuse it so I dont have to create another emptyRow3 = Label(frame)
?
Upvotes: 4
Views: 3157
Reputation: 865
You may define your element as a function which returns element. It'll create a new object each time you call it:
emptyRow = lambda:Label(frame)
emptyRow().grid(row=0)
emptyRow().grid(row=3)
Upvotes: 1
Reputation: 21453
short answer: no you can't display a widget in multiple places/ create several empty labels without calling Label(frame)
for each one.
if creating an empty label is something you do often you can make a short function to do it:
def fill_empty(parent,row,column):
empty = Label(parent)
empty.grid(row=row,column=column)
return empty
but I'd highly recommend using padding instead of dummy widgets to space things out, see this documentation for details.
Upvotes: 4