def __init_ctrls(self, prnt):
        wx.Panel.__init__(self, id=wxID_BOTTOM_WINDOW, name=u'Panel',
                          parent=prnt, style=wx.TAB_TRAVERSAL)


        self.display = ListCtrl(self, -1, size=wx.Size(520, -1))

        #self.display.Bind(wx.EVT_LIST_ITEM_FOCUSED, self.main.on_item_selected,
        #                  self.display)

        self.display.Bind(wx.EVT_LIST_ITEM_SELECTED, self.main.on_item_selected,
                          self.display)

        self.preview = buttons.GenBitmapTextButton(self, wxID_AUTOPREVIEW,
                                                   wx.Bitmap(utils.icon_path(u'preview.png'),
                                                   wx.BITMAP_TYPE_PNG), _(u"Preview"), size=(-1, 26))
        self.Bind(wx.EVT_BUTTON, self.main.on_preview_button,
                  id=wxID_AUTOPREVIEW)

        self.go = buttons.GenBitmapTextButton(self, wxID_GO,
                                              wx.Bitmap(utils.icon_path(u'go.png'), wx.BITMAP_TYPE_PNG),
                                              _(u"Go!"), size=(-1, 26))
        self.go.Enable(False)
        self.go.Bind(wx.EVT_BUTTON, self.main.rename_items, id=wxID_GO)

        self.imgPreview = wx.CheckBox(id=wxID_IMGPREVIEW,
                                      label=_(u"Show image thumbnails"), name=u'imgPreview', parent=self,
                                      style=0)
        self.imgPreview.SetToolTipString(_(u"Can slow preview considerably"))
        self.imgPreview.SetValue(False)
        self.imgPreview.Bind(wx.EVT_CHECKBOX, self.__refresh_picker)

        self.thumbSize = wx.Choice(id=wxID_THUMBSIZE,
                                   choices=[u'32', u'64', u'128', u'256'],
                                   name=u'dirsPlace', parent=self, size=wx.Size(62, -1),
                                   style=0)
        self.thumbSize.SetSelection(1)
        self.thumbSize.SetToolTipString(_(u"Thumbnail Size"))
        self.thumbSize.Bind(wx.EVT_CHOICE, self.__set_thumb_size)

        if not utils.is_pil_loaded():
            self.imgPreview.SetValue(False)
            self.imgPreview.Enable(False)
            self.thumbSize.Enable(False)

        self.autoPreview = wx.CheckBox(id=wxID_AUTOPREVIEW,
                                       label=_(u"Automatic Preview"), name=u'autoPreview', parent=self,
                                       style=0)
        self.autoPreview.SetToolTipString(_(u"Disable when working with many items"))
        self.autoPreview.SetValue(True)
    def __init_ctrls(self, prnt):
        wx.Panel.__init__(self, id=wxID_BOTTOM_WINDOW, name=u'Panel',
                          parent=prnt, style=wx.TAB_TRAVERSAL)


        self.display = ListCtrl(self, -1, size=wx.Size(520, -1))

        #self.display.Bind(wx.EVT_LIST_ITEM_FOCUSED, self.main.on_item_selected,
        #                  self.display)

        self.display.Bind(wx.EVT_LIST_ITEM_SELECTED, self.main.on_item_selected,
                          self.display)

        self.preview = buttons.GenBitmapTextButton(self, wxID_AUTOPREVIEW,
                                                   wx.Bitmap(utils.icon_path(u'preview.png'),
                                                   wx.BITMAP_TYPE_PNG), _(u"Preview"), size=(-1, 26))
        self.Bind(wx.EVT_BUTTON, self.main.on_preview_button,
                  id=wxID_AUTOPREVIEW)

        self.go = buttons.GenBitmapTextButton(self, wxID_GO,
                                              wx.Bitmap(utils.icon_path(u'go.png'), wx.BITMAP_TYPE_PNG),
                                              _(u"Go!"), size=(-1, 26))
        self.go.Enable(False)
        self.go.Bind(wx.EVT_BUTTON, self.main.rename_items, id=wxID_GO)

        self.imgPreview = wx.CheckBox(id=wxID_IMGPREVIEW,
                                      label=_(u"Show image thumbnails"), name=u'imgPreview', parent=self,
                                      style=0)
        self.imgPreview.SetToolTipString(_(u"Can slow preview considerably"))
        self.imgPreview.SetValue(False)
        self.imgPreview.Bind(wx.EVT_CHECKBOX, self.__refresh_picker)

        self.thumbSize = wx.Choice(id=wxID_THUMBSIZE,
                                   choices=[u'32', u'64', u'128', u'256'],
                                   name=u'dirsPlace', parent=self, size=wx.Size(62, -1),
                                   style=0)
        self.thumbSize.SetSelection(1)
        self.thumbSize.SetToolTipString(_(u"Thumbnail Size"))
        self.thumbSize.Bind(wx.EVT_CHOICE, self.__set_thumb_size)

        if not utils.is_pil_loaded():
            self.imgPreview.SetValue(False)
            self.imgPreview.Enable(False)
            self.thumbSize.Enable(False)

        self.autoPreview = wx.CheckBox(id=wxID_AUTOPREVIEW,
                                       label=_(u"Automatic Preview"), name=u'autoPreview', parent=self,
                                       style=0)
        self.autoPreview.SetToolTipString(_(u"Disable when working with many items"))
        self.autoPreview.SetValue(True)
Exemple #3
0
    def add_items(self, root, folders, files):
        """Add items found to list."""
        self.thumbnails = {}
        supported = (".png", ".jpg", ".bmp", ".tif", ".jpeg", ".tiff", ".gif", ".ico", ".thm")
        imgPreview = main.bottomWindow.imgPreview.GetValue()
        thumbSize = self.thumbSize = self.__create_image_list(imgPreview)

        if imgPreview and utils.is_pil_loaded():
            imgPreview = True

            def _get_ext(item):
                return os.path.splitext(item)[1].lower()

        else:
            imgPreview = False

        # list folders first
        folders.sort(key=lambda x: x.lower())
        for i in range(len(folders)):
            self.InsertImageStringItem(i, folders[i], 0)

        # ... then files
        def _make_key(f):
            return (os.path.dirname(f), f.lower())

        files.sort(key=_make_key)

        i = len(folders)
        for item in files:
            # preview images
            if imgPreview is True and _get_ext(item) in supported:
                fullitem = os.path.join(root, item.lstrip("/"))
                try:
                    thumb = self.__image_to_pil(fullitem, thumbSize)

                except IOError:
                    img = 1
                else:
                    img = self.imgs.Add(thumb)
                    # link name with number in imageList for main window
                    self.thumbnails[fullitem] = img
            else:
                img = 1
            self.InsertImageStringItem(i, item, img)
            i += 1
Exemple #4
0
    def add_items(self, root, folders, files):
        """Add items found to list."""
        self.thumbnails = {}
        supported = ('.png', '.jpg', '.bmp', '.tif', '.jpeg', '.tiff', '.gif',
                     '.ico', '.thm')
        imgPreview = main.bottomWindow.imgPreview.GetValue()
        thumbSize = self.thumbSize = self.__create_image_list(imgPreview)

        if imgPreview and utils.is_pil_loaded():
            imgPreview = True

            def _get_ext(item):
                return os.path.splitext(item)[1].lower()
        else:
            imgPreview = False

        # list folders first
        folders.sort(key=lambda x: x.lower())
        for i in range(len(folders)):
            self.InsertImageStringItem(i, folders[i], 0)

        # ... then files
        def _make_key(f):
            return (os.path.dirname(f), f.lower())

        files.sort(key=_make_key)

        i = len(folders)
        for item in files:
            # preview images
            if imgPreview is True and _get_ext(item) in supported:
                fullitem = os.path.join(root, item.lstrip('/'))
                try:
                    thumb = self.__image_to_pil(fullitem, thumbSize)

                except IOError:
                    img = 1
                else:
                    img = self.imgs.Add(thumb)
                    # link name with number in imageList for main window
                    self.thumbnails[fullitem] = img
            else:
                img = 1
            self.InsertImageStringItem(i, item, img)
            i += 1