Hi Mick,

> I have never heard of packing widgets within a canvas. 

Here's the link that gave me that impression:
http://stackoverflow.com/questions/4080413/python-tkinter-place-a-widget-in-a-canvas-widget

<quote>
You can easily add widgets to a canvas just like you do any other
container, using pack or grid or place. when you do this, the items will
not scroll when you scroll the canvas because they aren't actually part
of the canvas.

The other choice is to create window objects on the canvas. You do this
with the create_window method of the canvas. The advantage is, this
window becomes part of the canvas and will scroll along with any other
objects on the canvas. The downside is, your only option is absolute
placement and you have to explicitly control the size of the widgets.
</quote>

BUT: In reviewing the documentation on this page, I see that there are
no pack and grid methods for the Canvas widget:
http://effbot.org/tkinterbook/canvas.htm

> Just use create_window, so there is no automatic placement, you need to 
> handle all placement.

OK. This makes sense. Does the following advice make sense:

The only time one should use a Canvas for a general purpose widget
container is when they need a container that scrolls.

To use a scrollable container one must be prepared to manually position
all widgets using the create_window() method call.

> Note with the following, packing a label within a canvas ... the Label widget 
> in fact REPLACES the canvas in the display rather than being packed within 
> it. I don't know why (try commenting out the d.pack() line) and see the 
> difference).

Interesting example. And I think this makes sense given the fact that
Canvas's don't support pack and grid layouts.

Thanks for your thoughts,

Malcolm
_______________________________________________
Tkinter-discuss mailing list
Tkinter-discuss@python.org
http://mail.python.org/mailman/listinfo/tkinter-discuss

Reply via email to