1

In Tkinter, resizing a canvas and/or frame can be done using

canvas.pack(fill="both", expand=True)

This way I can drag the tkinter window with the mouse and the canvas and frames within will adapt to the new size.

However I have not found a solution for applying this to images within the canvas. Only solutions so far are to independently change the size of the images through event actions.

Is there any way to make images within a canvas to resize dynamically, just like the canvas does with the one-liner above?

hirschme
  • 774
  • 2
  • 11
  • 40
  • Possible duplicate of [Tkinter resize background image to window size (Python 3.4)](https://stackoverflow.com/questions/24061099/tkinter-resize-background-image-to-window-size-python-3-4) – Mike - SMT Nov 15 '18 at 17:27
  • I would say that your question can be answered by this post: [Tkinter resize background image to window size (Python 3.4)](https://stackoverflow.com/questions/24061099/tkinter-resize-background-image-to-window-size-python-3-4). There you can use the Frame class to do what you need. – Mike - SMT Nov 15 '18 at 17:28

1 Answers1

3

Is there any way to make images within a canvas to resize dynamically, just like the canvas does with the one-liner above?

No, there is no way to do what you want. Images aren't like widgets which can automatically grow and shrink. You will need to set up a binding on the <Configure> event of the containing widget, and in the bound function you will have to convert the image to the desired size.

Bryan Oakley
  • 370,779
  • 53
  • 539
  • 685
  • OK but how do you do that? I'm 90% there but am missing the final steps: https://stackoverflow.com/questions/59340051/python-cannot-resize-list-of-images-on-canvas#59340051 – WinEunuuchs2Unix Dec 15 '19 at 02:34