Resizing widgets in text windows

deacon.sweeney at deacon.sweeney at
Tue Jan 30 23:13:07 CET 2007

On Jan 29, 3:33 am, "Eric Brunel" <eric_bru... at> wrote:
> On Fri, 26 Jan 2007 22:35:20 +0100, <deacon.swee... at> wrote:
> > Hi, I've been searching for a .resize()-like function to overload much
> > like can be done for the delete window protocol as follows:
> > toplevel.protocol("WM_DELETE_WINDOW", callback)
> > I realize that the pack manager usually handles all of the resize
> > stuff, but I've found an arrangement that the pack manager fails for.
> > That is, if one embeds a canvas into a window created inside a text
> > widget, then resize the text widget (via its container), the canvas and
> > its container windows do not resize.
> Supposing you call "embedding" inserting a widget in the text via the
> window_create method, why should they? Embedding a window in a Text is
> used to put some arbitrary widget in the middle of the text it contains.
> So the embedded widget has no reason to grow or shrink with the parent
> Text widget: it just moves with the text.
> > So I need to resize the window
> > that the canvas is embedded in. The most obvious way of doing this
> > would be as above, but there does not seem to be an equivalent to the
> > "WM_DELETE_WINDOW" protocol for resizing.
> As James said, the <Configure> event is your friend. But I'm not sure I
> understand your use case...
> --
> python -c "print ''.join([chr(154 - ord(c)) for c in
> 'U(17zX(%,5.zmz5(17l8(%,5.Z*(93-965$l7+-'])"

I'm using a text widget to hold a set of plots, one plot per line, 
such that the scrolling capability of the text widget can be taken 
advantage of to display only a subset of the plots at any given time. 
In the analyses my program automates, there are at least several plots 
are typically loaded into the text widget. This works out splendidly, 
but the width of the plots has thus far been a static thing. Now, I'll 
be able to adjust the plots widths so that when the owner window is 
resized, the width of each plot in the text widget is adjusted and the 
plot continues to occupy the entire text widget but no more, making 
for a much more professional looking product.

I didn't mean to imply that create_window widgets should automatically 
resize with the toplevel... I just couldn't find any way to force it.

Muchas gracias.


More information about the Python-list mailing list