[Tkinter-discuss] Swap position of 2 widgets positioned in parent container via pack() or grid()?

Wayne Werner waynejwerner at gmail.com
Mon Nov 15 19:47:34 CET 2010


On Mon, Nov 15, 2010 at 12:30 PM, <python at bdurham.com> wrote:

> Any tips on how I can swap the position of 2 widgets who have been
> positioned in a parent container via pack() or grid()?
>

import Tkinter as tk
root = tk.Tk()
b1 = tk.Button(root, text='hi')
b2 = tk.Button(root, text='bye')

b1.pack()
b2.pack()

b1.pack_forget()
b1.pack()

------

As for grid I'm not sure how to do it unless you have placed them in
different row/column - then you just have to use widget.grid(row=widget2row,
column=widget2col)
widget2.grid(row=widget1col, column=widget1col)

Well, that pattern.

HTH,
Wayne
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tkinter-discuss/attachments/20101115/fc8e8a52/attachment.html>


More information about the Tkinter-discuss mailing list