I am working on a python3 application to manipulate images. Resizing images is one of the functions. When I load an image that comes close to occupying the total screen area (somewhere to 5/6 part of total screen area) the encompassing top window “jumps/snaps” to the screen borders to the right and bottom (top system bar with date/time, and left taskbar are left alone). Once this happens the window will stick to the screen borders even when I resize the image to smaller dimensions. To pinpoint the problem I made my program as simple as possible, withdrawing all image manipulation and most widgets, and the problem still persists. In my most basic program I can load an image to a particular size without the window behaving strangely by becoming too big for its content (the image). But one pixel extra in height or width and the window jumps to the said screen borders. See program code and screen copies to better understand the problem. As this might be a problem of system configuration, these are my settings: OS: Linux Debian Buster, Python 3.7.3, Pillow 8.2.0
To be honest I asked this very same question on Stackoverflow but this has not produced any answer. So trying my luck with you guys.
py3 import tkinter as tk from PIL import Image,ImageTk window = tk.Tk() im = Image.open('./images/maxinput1092-846.jpg') #im = Image.open('./images/badinput1092-847.jpg') #im = Image.open('./images/badinput1093-846.jpg') photo = ImageTk.PhotoImage(image = im) canvas = tk.Canvas(window, width = photo.width(),height = photo.height()) canvas.pack(expand = 0, fill = tk.BOTH, side = tk.BOTTOM) canvas.create_image(0,0,image=photo,anchor="nw") window.mainloop()
Screenshot of too big image size