Resizing widgets in text windows

deacon.sweeney at gmail.com deacon.sweeney at gmail.com
Tue Jan 30 17:02:11 EST 2007


On Jan 26, 10:52 pm, James Stroud <jstr... at mbi.ucla.edu> wrote:
> deacon.swee... at gmail.com 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,
>
> Your meaning here is unclear. How is it possible to have "a window
> created inside a text widget"?

using the create_window function, as below.

>
> > then resize the text widget (via its container), the canvas and
> > its container windows do not resize. So I need to resize the window
> > that the canvas is embedded in.
>
> Try the Toplevel.wm_geometry() function.
>
> > 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.
>
> Do you want to detect when a window is resized or do you want to resize
> a window programatically.
>
> If the former, bind the Toplevel to '<Configure>'.
>
> E.g.
>
> from Tkinter import *
>
> def config(t):
>    def _r(e, t=t):
>      geom = e.widget.wm_geometry()
>      geom = geom.split('+')[0]
>      t.wm_geometry(geom)
>      print 'resized %s to %s' % (t, geom)
>    return _r
>
> tk = Tk()
> tk.title('resize me')
> t2 = Toplevel(tk)
> t2.title('I get resized')
> tk.bind('<Configure>', config(t2))
>
> Is that cool or what?
>

Yes, this is exactly what I was looking for. Thanks.

> James
>
> > Any help would be greatly appreciated.
>
> >DeaconSweeney








More information about the Python-list mailing list