Mailing List Archive

Tkinter Question
Greetings ---

I have an alarm display that consists of a Frame that contains multiple
frames within it, stacked one above the other. When a user clicks on one
of the subframes to acknowledge it, I want the subframe to disappear and
the parent frame to resize itself to remove the gap.

Getting the subframe to remove itself is no problem. I bound the
<Button-1> event to a method and had the frame destroy itself. Life is
good.

On the other hand, I can't figure out how to make the parent frame resize
itself.

Suggestions will be greatly appreciated.

--- Robert

--------------------------------
Robert Meegan
MCIWorldCom - Cedar Rapids, Iowa
319.375.2416
Tkinter Question [ In reply to ]
This is a multi-part message in MIME format.
--------------8C915F230320873A83ABA52D
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

Robert Meegan wrote:
>
> Greetings ---
>
> I have an alarm display that consists of a Frame that contains multiple
> frames within it, stacked one above the other. When a user clicks on one
> of the subframes to acknowledge it, I want the subframe to disappear and
> the parent frame to resize itself to remove the gap.
>
> Getting the subframe to remove itself is no problem. I bound the
> <Button-1> event to a method and had the frame destroy itself. Life is
> good.
>
> On the other hand, I can't figure out how to make the parent frame resize
> itself.
>
> Suggestions will be greatly appreciated.
>
> --- Robert
>
> --------------------------------
> Robert Meegan
> MCIWorldCom - Cedar Rapids, Iowa
> 319.375.2416

You probably used `pack' to put each subframe into the main frame, so
you should use its inverse operation `forget' to take it out. Then the
parent frame resizes automatically.

Here is a very small example: poke any of the buttons and watch it
disappear and the frame resize around the remaining buttons.

--
Dr. Gary Herron <gherron@aw.sgi.com>
206-287-5616
Alias | Wavefront
1218 3rd Ave, Suite 800, Seattle WA 98101
--------------8C915F230320873A83ABA52D
Content-Type: text/plain; charset=us-ascii;
name="forgetIt.py"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="forgetIt.py"

#!/usr/bin/env python

from Tkinter import *

root = Tk()

for i in range(10):
f = Frame(root)
b = Button(f, text='%s'%i,
command=lambda f=f: f.forget())
b.pack()
f.pack()

root.mainloop()

--------------8C915F230320873A83ABA52D--