You can place any Tkinter widget onto a canvas by using a canvas window object. A window is a rectangular area that can hold one Tkinter widget. The widget must be the child of the same top-level window as the canvas, or the child of some widget located in the same top-level window.
If you want to put complex multi-widget objects on a canvas, you can use this method to place a Frame widget on the canvas, and then place other widgets inside that frame.
To create a new canvas window object on a canvas : C
id=C.create_window(x,y,option, ...)
This returns the object ID for the window object. Options include:
Table 15. Canvas window options
anchor | The default is anchor=tk.CENTER, meaning that the window is centered on the (, ) position. See Section 5.5, “Anchors” for the possible values. For example, if you specify anchor=tk.E, the window will be positioned so that point (, ) is on the midpoint of its right-hand (east) edge. |
height | The height of the area reserved for the window. If omitted, the window will be sized to fit the height of the contained widget. See Section 5.1, “Dimensions” for possible values. |
state | By default, window items are in the tk.NORMAL state. Set this option to tk.DISABLED to make the window unresponsive to mouse input, or to tk.HIDDEN to make it invisible. |
tags | If a single string, the window is tagged with that string. Use a tuple of strings to tag the window with multiple tags. See Section 8.4, “Canvas tags”. |
width | The width of the area reserved for the window. If omitted, the window will be sized to fit the width of the contained widget. |
window | Use window= where is the widget you want to place onto the canvas. If this is omitted initially, you can later call to place the widget onto the canvas, where is the window's object ID.. |