def load_zad(self, file_path, fit=True):
img = wx.Image(file_path, wx.BITMAP_TYPE_ANY)
if fit:
w, h = img.GetWidth(), img.GetHeight()
max_w, max_h = self.images_panel.GetSize()
target_ratio = min(max_w / float(w), max_h / float(h))
new_w, new_h = [int(x * target_ratio) for x in (w, h)]
img = img.Scale(new_w, new_h, wx.IMAGE_QUALITY_HIGH)
self.images_panel.drawable_bitmap = wx.Bitmap(img)
self.images_panel.Refresh()
评论列表
文章目录