Python tkinter same Label called multiple times

Viewed 2611

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) ?

2 Answers

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)
Related