コード例 #1
0
 def __init__(self, parent, files, icon_size=ICON_SIZE,
         checkboard=False, **keyw):
     super(ListCtrl, self).__init__(parent, -1,
         style=wx.LC_ICON | wx.LC_SINGLE_SEL, **keyw)
     #create image list
     self.image_list = wx.ImageList(*icon_size)
     self.icons = {}
     for file in files.values():
         self.icons[file] = self.image_list.Add(
             pil_wxBitmap(open_thumb(file, size=icon_size)))
     self.SetImageList(self.image_list, wx.IMAGE_LIST_NORMAL)
     #populate
     n = 10
     if type(files) is dict:
         labels_files = files.items()
         #labels_files = [(truncate(label,n),file)
          #   for label, file in files.items()]
     labels_files.sort()
     self._labels = [label for label, file in labels_files]
     self._files = [file for label, file in labels_files]
     self._files_to_labels = {}
     for label, file in labels_files:
         self._files_to_labels[file] = label
     for index, (label, file) in enumerate(labels_files):
         item = self.InsertImageStringItem(index, '', self.icons[file])
         self.SetItemData(item, index)
コード例 #2
0
 def __init__(self,
              parent,
              files,
              icon_size=ICON_SIZE,
              checkboard=False,
              **keyw):
     super(ListCtrl, self).__init__(parent,
                                    -1,
                                    style=wx.LC_ICON | wx.LC_SINGLE_SEL,
                                    **keyw)
     #create image list
     self.image_list = wx.ImageList(*icon_size)
     self.icons = {}
     for file in files.values():
         self.icons[file] = self.image_list.Add(
             pil_wxBitmap(open_thumb(file, size=icon_size)))
     self.SetImageList(self.image_list, wx.IMAGE_LIST_NORMAL)
     #populate
     n = 10
     if type(files) is dict:
         labels_files = files.items()
         #labels_files = [(truncate(label,n),file)
         #   for label, file in files.items()]
     labels_files.sort()
     self._labels = [label for label, file in labels_files]
     self._files = [file for label, file in labels_files]
     self._files_to_labels = {}
     for label, file in labels_files:
         self._files_to_labels[file] = label
     for index, (label, file) in enumerate(labels_files):
         item = self.InsertImageStringItem(index, '', self.icons[file])
         self.SetItemData(item, index)
コード例 #3
0
 def show_preview(self, filename):
     bitmap = pil_wxBitmap(open_thumb(filename, size=(128,128)))
     self.preview.SetBitmap(bitmap)
     size    = (bitmap.GetWidth(), bitmap.GetHeight())
     self.preview.SetSize(size)
     self.preview.SetMinSize(size)
     self.preview.Show()
     self.preview_sizer.Layout()
コード例 #4
0
 def UpdateThumbs(self, force_thumbs=False):
     if self.image_table.images:
         heights = []
         for image in self.image_table.images:
             if force_thumbs or not hasattr(image, 'thumb_wx'):
                 image.thumb_wx = wxPil.pil_wxBitmap(image.thumb)
             heights.append(image.thumb.size[1])
         self.SetColLabelSize(max(heights) + 2 * self.border)
コード例 #5
0
 def show_preview(self, filename):
     bitmap = pil_wxBitmap(open_thumb(filename, size=(128,128)))
     self.preview.SetBitmap(bitmap)
     size    = (bitmap.GetWidth(), bitmap.GetHeight())
     self.preview.SetSize(size)
     self.preview.SetMinSize(size)
     self.preview.Show()
     self.preview_sizer.Layout()
コード例 #6
0
 def UpdateThumbs(self, force_thumbs=False):
     if self.image_table.images:
         heights = []
         for image in self.image_table.images:
             if force_thumbs or not hasattr(image, 'thumb_wx'):
                 image.thumb_wx = wxPil.pil_wxBitmap(image.thumb)
             heights.append(image.thumb.size[1])
         self.SetColLabelSize(max(heights) + 2 * self.border)