def duplicate(self,ask=1): duplicates = mkthumb.check_duplicate(self.options,self.name_reduced) if ask == 0: clean_duplicate = 1 else: clean_duplicate = 0 if ask and duplicates != []: msg = "Remove this duplicates pictures ?\n\n" + "\n".join(duplicates) dlg = wx.MessageDialog(None, msg, "Duplicated Photos",wx.YES_NO | wx.ICON_QUESTION) retCode = dlg.ShowModal() if (retCode == wx.ID_YES): #print("Remove {}".format(filename)) clean_duplicate = 1 if clean_duplicate: for photo in duplicates: print("Removing {} ...".format(photo)) os.remove(photo) mkthumb.mkthumb(self.options,self.name_reduced) self.update = True
def RightClickPictureMenu(self,filename,event): print("ThumbPanel.RightClickMenu()") update = 0 if event.GetId() == self.popupID_DELETE: print("DELETE") msg = u'Are you sure you want to delete "{}" ?'.format(filename) dlg = wx.MessageDialog(None, msg, "Please confirm ...",wx.YES_NO | wx.ICON_QUESTION) retCode = dlg.ShowModal() if (retCode == wx.ID_YES): print("Remove {}".format(filename)) os.remove(filename) update = 1 else: print "no" elif event.GetId() == self.popupID_RENAME: print("RENAME",filename) path,name = os.path.split(filename) dlg = wx.FileDialog(self, message="Rename as ...", defaultDir=path, defaultFile=name, wildcard="*", style=wx.SAVE) if dlg.ShowModal() == wx.ID_OK: newfilename = dlg.GetPath() os.rename(filename,newfilename) update = 1 dlg.Destroy() elif event.GetId() == self.popupID_SET_DEFAULT: print("SET_DEFAULT") mkthumb.setdefault(self.options,self.name_reduced, os.path.split(filename)[-1]) update = 1 if update: mkthumb.mkthumb(self.options,self.name_reduced) self.Update() self.parent.Refresh()
def onDownload(self,event): print("onDownload") if not wx.TheClipboard.IsOpened(): # may crash, otherwise do = wx.TextDataObject() wx.TheClipboard.Open() success = wx.TheClipboard.GetData(do) wx.TheClipboard.Close() if success: link = do.GetText() if re.match("https?://",link): mkthumb.download(self.options,self.name_reduced,link) print("download done") mkthumb.number(self.options,self.name_reduced) mkthumb.mkthumb(self.options,self.name_reduced) self.update = True self.duplicate(0) if self.update: self.Update()
def RightClickMenu(self,event): #------------------------------------------------------------------------------- print("ThumbPanel.RightClickMenu()") s="" if event.GetId() == self.popupID_REFRESH: mkthumb.number(self.options,self.name_reduced) mkthumb.mkthumb(self.options,self.name_reduced) self.Update() elif event.GetId() == self.popupID_DUPLICATE: print("CHECK_DUPLICATE") self.duplicate() if self.update: self.Update() elif event.GetId() == self.popupID_DOWNLOAD: self.onDownload(event)
#------------------------------------------------------------------------------- # #------------------------------------------------------------------------------- if __name__ == '__main__': wxflore_bin_path = os.path.join(os.path.split(os.path.abspath(__file__))[0],"..","wxflore-x.x") sys.path.append(wxflore_bin_path) import mkthumb options = OPTIONS() parse_argv(options) if os.getenv("HOME") == None: options.home = os.getenv("HOMEPATH")#.decode(sys.stdout.encoding) else: options.home = os.getenv("HOME")#.decode(sys.stdout.encoding) options.wxflore = os.path.join(options.home,".wxflore") if options.local: options.img = os.getcwd() else: import config config.read(options) mkthumb.mkthumb(options) if options.duplicates: mkthumb.check_all_duplicate(options)
def onRefresh(self,event): print("onRefresh") mkthumb.mkthumb(options)