scrollbar dependencies

Eric Brunel eric_brunel at despammed.com
Thu Mar 24 07:05:45 EST 2005


On 24 Mar 2005 03:24:34 -0800, Marion <supermarion3 at gmail.com> wrote:

> Next mystery :
> a picture drawn in the canvas c1 is scrollable.
> a picture-containing canvas "grided" in the canvas c1 is not.
>
> so why ???
> Marion
> ---------------------------------------------------------------
[snip]
> #-------------------------------#
> # this is not ! :
> #-------------------------------#
>         canvas=Canvas(self.c1,background="WHITE")
>         image  =Image.new("RGB",(100,100))
>         dessin = ImageDraw.Draw(image)
>         dessin.rectangle([(10,10),(50,50)],fill="rgb(255,0,0)")
>         photo=ImageTk.PhotoImage(image)
>         item = canvas.create_image(0,0,anchor=NW,image=photo)
>         canvas.grid()

You don't want to do that. Canvases are not meant to be containers where you can pack or grid items. They strangely accept it, but it will never do what you want. If you want to pack or grid items in a container, use a Frame. If you want to include a widget in a Canvas, use a canvas window:

>>> c1 = Canvas(root)
>>> c1.pack()
>>> c2 = Canvas(c1, bd=2, relief=SUNKEN, width=50, height=50)
>>> c1.create_window(20, 20, window=c2, anchor=NW)

Canvas windows are scollable; widgets packed or gridded in Canvases are not. So this really seems to be your problem here.

HTH
-- 
python -c 'print "".join([chr(154 - ord(c)) for c in "U(17zX(%,5.z^5(17l8(%,5.Z*(93-965$l7+-"])'



More information about the Python-list mailing list