图像太大时意外的窗口最大化,Debian buster,Python3,tkinter

问题描述

我正在开发一个用于操作图像的 python3 应用程序。调整图像大小是其中一项功能。当我加载接近占据总屏幕区域(总屏幕区域的 5/6 部分)的图像时,包含的顶部窗口“跳转”到右侧和底部的屏幕边框(带有日期/时间的顶部系统栏,左侧任务栏保持不变)。一旦发生这种情况,即使我将图像调整为更小的尺寸,窗口也会粘在屏幕边框上。为了查明问题,我使我的程序尽可能简单,撤消了所有图像处理和大多数小部件,但问题仍然存在。在我最基本的程序中,我可以将图像加载到特定大小,而不会因为窗口的内容(图像)变得太大而表现出奇怪的行为。但是在高度或宽度上增加一个像素,窗口会跳转到所述屏幕边框。查看程序代码和屏幕副本以更好地了解问题。由于这可能是系统配置的问题,这些是我的设置:操作系统:Linux Debian Buster、Python 3.7.3、Pillow 8.2.0

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,image=photo,anchor="nw")

window.mainloop()

Screenshot of max image size (window behaving as expected and desired)

Screenshot of too big image size

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)