[Tkinter-discuss] add/remove button in runtime
Michael Lange
klappnase at web.de
Sun Jul 25 20:44:11 CEST 2010
Hi,
On Sat, 24 Jul 2010 03:41:21 -0700 (PDT)
petroff <petr0ff at seznam.cz> wrote:
>
> I want to allow changing in (sorted) list of buttons:
> self.ADRbuttons=[B1,B2...]
> REMOVE => button.destroy (it works correctly)
> ADD is a problem; I don't know how to insert button on correct
> location in button panel (pack method)
This sounds like the grid() geometry manager is the perfect tool for
you, is there any special reason why you want to use pack() instead?
With grid() you could easily do something like:
for i in range(len(self.datADR)):
new = Button(self)
new.grid(row=0, column=i)
self.ADRbuttons.append(new)
If you want to change the location of a button later, simply call grid()
again with the new row and column.
I hope this helps
Michael
More information about the Tkinter-discuss
mailing list