开发者

How to place a widget in a Canvas widget in Tkinter?

I want basically to be able to use a Canvas as a meta container for other widgets.

I want to divide my GUI into a left, center and middle section. Within each section I would like to be able to place widgets like: Checkbutton, Button, Label, etc.

How to place widgets开发者_如何学C in a Canvas widget?


Your choices depend on what you're really trying to accomplish. Why is using a canvas preferable to using a frame?

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜