Tkinter: How to remove stacking order of a widget in grid manager

Bernie bernie at pacific.net.hk
Wed Feb 7 12:46:31 EST 2001


Hi Fredrik,

Have you try to <tab> around the widget (using the
<tab> key on keybroad).  If you just call grid again,
the tab order (or stacking order) of the widgets will
stays the same as you first created.

I use grid_forget() before grid() because I thought
grid_forget() should help me to solve the stacking
order problem as well.  I don't know if it is a bug
with the TK grid manager or I misunderstood the
documentation.  The bottom line is I am looking
for a solution to reorder the widgets, as well as it's
stacking order.

Any idea how can that be done?

Thanks in advance!


Bernie

Fredrik Lundh wrote:

> Bernie wrote:
> > I have an application which requires reordering the widgets during
> > runtime.  I am using the grid manager and found two functions
> > grid_remove() and grid_forget().  I thought grid_remove() should
> > does the job, it doesn't, neither do grid_forget().
> >
> > How can that be done?
>
> just calling "grid" again (with or without grid_remove
> or grid_forget) works fine for me.  try this:
>
> # a simple regridding test
>
> from Tkinter import *
>
> root = Tk()
>
> def flip():
>     buttons.reverse()
>     for i in range(10):
>         buttons[i].grid(column=0, row=i)
>
> buttons = []
> for i in range(10):
>     b = Button(root, text=i, width=20, command=flip)
>     b.grid(column=0, row=i)
>     buttons.append(b)
>
> mainloop()
>
> (just click on any of the buttons to move them around)
>
> Cheers /F

----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------




More information about the Python-list mailing list