Tkinter: How to remove stacking order of a widget in grid manager
Bernie
bernie at pacific.net.hk
Wed Feb 7 03:23:38 EST 2001
Hi David,
I've try your suggestion but it still doesn't work. Below
is the code I've used.
root = Tkinter.Tk()
frame = Tkinter.Frame( root)
frame.pack()
a = []
for i in range(10):
a.append( Tkinter.Button( frame, text=i))
a[i].grid( column = 0, row = i)
frame.grid_forget() # buttons did not
unmapped
a.reverse()
for i in range(10):
a[i].grid( column = 0, row = i)
# now the widgets are reordered but the stacking order did not
reverse
Bernie
David Allen wrote:
> In article <3A80712D.BAF8FC0D at pacific.net.hk>, "Bernie"
> <bernie at pacific.net.hk> wrote:
>
> > Below is the code fragment:
> >
> > # remove widget from Grid Display manager
> > for w in widget_list
> > w.grid_remove()
> >
> > # re-ordering the widget
> > widget_list.sort( mySort) # mySort() is not listed
>
> >
> > # display widgets in new orders
> > col = range(5) row = 0 for w in widget_list:
> > for i in col:
> > w.grid( column = i, row = row)
> > row = row + 1
>
> I think what the problem is that it has to be done
> in the parent, not the child. So if 5 things are
> grid() into a widget called wid, then
>
> wid.grid_forget() will ungrid all of the items.
> By calling grid_forget on the items you want to take
> out of the grid, you're unpacking their subitems
> but not them.
>
> Example:
>
> f = Frame(parent)
> b = Button(f, text="Foobar")
> b.grid(row=0, col=0)
>
> if you then want to get rid of b, you do
> f.grid_forget()
>
> NOT
> b.grid_forget()
>
> Hope this helps.
> --
> David Allen
> http://opop.nols.com/
> ----------------------------------------
> "I must say that I find television very educational. The minute
> somebody turns it on, I go to the library and read a book."
> --Groucho Marx
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
More information about the Python-list
mailing list