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()
this sounds like a behavior of the window manager your system is using. It is the very same what happens, if you resize a window manually (with your mouse) - in some window managers.
Maybe you can have a look into the settings of your window manager - maybe you’ll find a belonging setting there and can switch that off?
hi Dominik, first of all: thanks for your willingness to help. What you say about the erratic behaviour possibly being the work of a window manager sounds plausible to me. So, I have been looking into this. Problem is that I am not very well versed in this area of OS. The file /etc/X11/default-display-manager gives me gdm3, so the gnome 3 display manager. And the command “update-alternatives --list x-window-manager” gives me “mutter” as the window-manager. When I log in I get to choose from 4 gnome environments, of which I always choose “system X11 default”. I tried the other options (like Gnome classical) but same “window snapping” behaviour. I tried to look for configuration files for mutter. But I cannot find info on them on the internet. I can tweak Gnome via Gnome-tweaks. There is a section on windows, with an option to attach modal dialogs. I tried that setting, but no success. There are really few options I can set with tweaks. I post you a screenshot of the window tweaks. If you know where to look, please direct me. If not, thanks for your help anyway.
This almost certainly is nothing to do with Python. It will be a
“feature” of your window manager. Unfortunately each window manager is
different, but in XFCE you can control this misfeature by going to:
Applications > Settings > Window Manager
then click the “Advanced” tab, where there is a checkbox for “Window
snapping”.