Search code examples
pythontkintergeometrypack

How do I overlap widgets with the Tkinter pack geometry manager?


I want to put a Canvas with an image in my window, and then I want to pack widgets on top of it, so the Canvas acts as a background.

Is it possible to have two states for the pack manager: one for one set of widgets and another for another set?


Solution

  • The answer to your specific question is no. You can't have two states or otherwise use pack two different ways in the same parent.

    However, what I think you want to accomplish is simple. Use the built-in features of the canvas to create an image item that is part of the canvas, then pack things into the canvas as if it were a frame.

    You can accomplish a similar thing by creating a label widget with an image, then pack your other widgets into the label.

    One advantage to using a canvas is you can easily tile an image to fill the whole canvas with a repeating background image so as the window grows the image will continue to fill the window (of course you can just use a sufficiently large original image...)