def preloadImagePreview(self): size = [200, 200] if self.talk.image == None: self.frame.bitmapImage.Hide() self.frame.Layout() return else: self.frame.bitmapImage.Show() self.frame.Layout() self.frame.Layout() imgpath = os.path.join(self.project.image_folder, self.talk.image) if os.path.exists(imgpath): image = wx.Image(imgpath) if image.GetWidth() > size[0] or image.GetHeight() > size[1]: image = imagehelper.scalePropotional(image, size) image = image.ConvertToBitmap() self.frame.Refresh() self.frame.bitmapImage.SetBitmap(image) self.frame.bitmapImage.SetBitmap(image)
def onChangeImage(self, evt): size = [200,200] selection = self.frame.listItems.GetStringSelection() if not selection or selection not in self.items: return self.items[selection] self.items[selection].image = self.frame.choiceFile.GetStringSelection() if not self.items[selection].image or len(self.items[selection].image) < 1: self.frame.Refresh() self.frame.bitmapPreview.ClearBackground() return imgpath = os.path.join(self.project.image_folder, self.items[selection].image) if os.path.exists(imgpath): image = wx.Image(imgpath) if image.GetWidth() > size[0] or image.GetHeight() > size[1]: image = imagehelper.scalePropotional(image, size) image = image.ConvertToBitmap() self.frame.Refresh() self.frame.bitmapPreview.SetBitmap(image) self.frame.bitmapPreview.SetBitmap(image)