def __init_notebook(self): parent = self.notebook # init Core classes self.picker = picker.Core(parent, self) self.sorting = sorting.Core(parent, self) self.errors = errors.Core(parent, self) self.renamer = renamer.Core(parent, self) # list containing notebook images il = wx.ImageList(16, 16) img0 = il.Add(wx.Bitmap(utils.icon_path(u'picker.ico'), wx.BITMAP_TYPE_ICO)) img1 = il.Add(wx.Bitmap(utils.icon_path(u'main.ico'), wx.BITMAP_TYPE_ICO)) img2 = il.Add(wx.Bitmap(utils.icon_path(u'sorting.ico'), wx.BITMAP_TYPE_ICO)) img3 = il.Add(wx.Bitmap(utils.icon_path(u'errors.ico'), wx.BITMAP_TYPE_ICO)) parent.AssignImageList(il) # add notebook pages to notebook parent.AddPage(self.picker.view, _(u"Picker"), True, img0) parent.AddPage(self.renamer.view, _(u"- Renamer -"), False, img1) parent.AddPage(self.sorting.view, _(u"Sorting"), False, img2) parent.AddPage(self.errors.view, _(u"Errors/Warnings: %s") % 0, False, img3)
def __init_menu(self, menu): """Right click menu.""" menu.edit = wx.MenuItem(menu, wxID_MENUEDIT, _(u"Manually Edit")) menu.edit.SetBitmap(wx.Bitmap(utils.icon_path(u'edit.png'), wx.BITMAP_TYPE_PNG)) menu.remove = wx.MenuItem(menu, wxID_MENUREMOVE, _(u"Remove Item(s)")) menu.remove.SetBitmap(wx.Bitmap(utils.icon_path(u'errors.png'), wx.BITMAP_TYPE_PNG)) menu.removeAndPreview = wx.MenuItem(menu, wxID_MENUREMOVEANDPREVIEW, _(u"Remove Item(s) and preview")) menu.removeAndPreview.SetBitmap(wx.Bitmap(utils.icon_path(u'errors.png'), wx.BITMAP_TYPE_PNG)) menu.AppendItem(menu.edit) menu.AppendItem(menu.remove) menu.AppendItem(menu.removeAndPreview) #menu.AppendItem(parent.disable) self.Bind(wx.EVT_MENU, self._remove_items, id=wxID_MENUREMOVE) self.Bind(wx.EVT_MENU, self._remove_items_and_preview, id=wxID_MENUREMOVEANDPREVIEW) self.Bind(wx.EVT_MENU, self._manual_edit, id=wxID_MENUEDIT)
def display_results(self, showDirs=False): """ Resets the bottom preview virtual list, then sets amount of items and the correct imagelist to use. """ self.errors.clear() pickerList = self.picker.view.ItemList display = self.bottomWindow.display #display.Enable(False) usedOperations = self.renamer.view.usedOperations # show complete path in new name if not showDirs: for i in range(usedOperations.GetItemCount()): op = usedOperations.GetItemText(i) if re.search(_("directory"), op): showDirs = True break display.showDirs = showDirs display.mode = 'preview' # set the image list if app.prefs.get('showPreviewIcons'): display.imgs = pickerList.imgs else: display.imgs = wx.ImageList(16, 16) display.folderIco = display.imgs.Add( wx.Bitmap(utils.icon_path(u'folder16.png'), wx.BITMAP_TYPE_PNG)) display.fileIco = display.imgs.Add( wx.Bitmap(utils.icon_path(u'file16.png'), wx.BITMAP_TYPE_PNG)) display.SetImageList(display.imgs, wx.IMAGE_LIST_SMALL) display.DeleteAllItems() display.SetItemCount(len(self.toRename)) #display.Enable(True) # auto resize column: #display.SetColumnWidth(2,-1) if display.GetColumnWidth(2) < 135: display.SetColumnWidth(2, 135) # show the last warning/error if self.warn: display.EnsureVisible(self.warn[-1]) elif self.bad: display.EnsureVisible(self.bad[-1]) # show the currently selected item try: display.Select(self.currentItem, True) except TypeError: # may need AttributeError pass else: display.EnsureVisible(self.currentItem)
def display_results(self, showDirs=False): """ Resets the bottom preview virtual list, then sets amount of items and the correct imagelist to use. """ self.errors.clear() pickerList = self.picker.view.ItemList display = self.bottomWindow.display #display.Enable(False) usedOperations = self.renamer.view.usedOperations # show complete path in new name if not showDirs: for i in range(usedOperations.GetItemCount()): op = usedOperations.GetItemText(i) if re.search(_("directory"), op): showDirs = True break display.showDirs = showDirs display.mode = 'preview' # set the image list if app.prefs.get('showPreviewIcons'): display.imgs = pickerList.imgs else: display.imgs = wx.ImageList(16, 16) display.folderIco = display.imgs.Add(wx.Bitmap( utils.icon_path(u'folder16.png'), wx.BITMAP_TYPE_PNG)) display.fileIco = display.imgs.Add(wx.Bitmap( utils.icon_path(u'file16.png'), wx.BITMAP_TYPE_PNG)) display.SetImageList(display.imgs, wx.IMAGE_LIST_SMALL) display.DeleteAllItems() display.SetItemCount(len(self.toRename)) #display.Enable(True) # auto resize column: #display.SetColumnWidth(2,-1) if display.GetColumnWidth(2) < 135: display.SetColumnWidth(2, 135) # show the last warning/error if self.warn: display.EnsureVisible(self.warn[-1]) elif self.bad: display.EnsureVisible(self.bad[-1]) # show the currently selected item try: display.Select(self.currentItem, True) except TypeError: # may need AttributeError pass else: display.EnsureVisible(self.currentItem)
def __create_undo_redo(self, label): """Deletes and creates a new button, hack to change image.""" if label == _("Undo"): img = wx.Bitmap(utils.icon_path(u'undo.ico'), wx.BITMAP_TYPE_ICO) else: img = wx.Bitmap(utils.icon_path(u'redo.ico'), wx.BITMAP_TYPE_ICO) if hasattr(self, 'undoRedo'): self.undoRedo.Destroy() self.undoRedo = buttons.GenBitmapTextButton(self, wxID_UNDOREDO, img, label, size=(-1, 26)) # do not use wx.EVT_BUTTON, causes seg fault self.undoRedo.Bind(wx.EVT_LEFT_DOWN, self.main.undo_rename, id=wxID_UNDOREDO) self.buttonSizer.Insert(2, self.undoRedo, proportion=0, flag=wx.LEFT, border=25) self.Layout()
def __create_image_list(self, imgPreview): # get thumbnail size if imgPreview: xy = int(main.bottomWindow.thumbSize.GetStringSelection()) thumbSize = (xy, xy) else: thumbSize = (16, 16) # apply to list self.imgs = wx.ImageList(thumbSize[0], thumbSize[1]) self.folderIco = self.imgs.Add(wx.Bitmap(utils.icon_path(u"folder%s.png" % thumbSize[0]), wx.BITMAP_TYPE_PNG)) self.fileIco = self.imgs.Add(wx.Bitmap(utils.icon_path(u"file%s.png" % thumbSize[0]), wx.BITMAP_TYPE_PNG)) self.SetImageList(self.imgs, wx.IMAGE_LIST_SMALL) return thumbSize
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__(self, parent, ID, pos=wx.DefaultPosition): style = wx.LC_REPORT | wx.LC_VIRTUAL wx.ListCtrl.__init__(self, parent, ID, pos, wx.DefaultSize, style) # causes freeze under winXP #ListCtrlAutoWidthMixin.__init__(self) self.InsertColumn(col=0, format=wx.LIST_FORMAT_LEFT, heading=_(u"Error"), width=260) self.InsertColumn(col=1, format=wx.LIST_FORMAT_LEFT, heading=_(u"File"), width=639) imgs = wx.ImageList(16, 16) imgs.Add(wx.Bitmap(utils.icon_path(u'warn.ico'), wx.BITMAP_TYPE_ICO)) imgs.Add(wx.Bitmap(utils.icon_path(u'failed.ico'), wx.BITMAP_TYPE_ICO)) self.AssignImageList(imgs, wx.IMAGE_LIST_SMALL) self.SetItemCount(0) self.parent = parent
def __create_image_list(self, imgPreview): # get thumbnail size if imgPreview: xy = int(main.bottomWindow.thumbSize.GetStringSelection()) thumbSize = (xy, xy) else: thumbSize = (16, 16) # apply to list self.imgs = wx.ImageList(thumbSize[0], thumbSize[1]) self.folderIco = self.imgs.Add(wx.Bitmap(utils.icon_path(u'folder%s.png' % thumbSize[0]), wx.BITMAP_TYPE_PNG)) self.fileIco = self.imgs.Add(wx.Bitmap(utils.icon_path(u'file%s.png' % thumbSize[0]), wx.BITMAP_TYPE_PNG)) self.SetImageList(self.imgs, wx.IMAGE_LIST_SMALL) return thumbSize
def __init_menu_picker(self, parent): parent.browseMenu = wx.MenuItem(parent, wxID_MENUPICKER_BROWSE, _(u"&Browse...\tF4"), self.make_space(_(u"Browse for path"))) parent.browseMenu.SetBitmap( wx.Bitmap(utils.icon_path(u'browse.png'), wx.BITMAP_TYPE_PNG)) parent.okMenu = wx.MenuItem( parent, wxID_MENUPICKER_OK, _(u"&Refresh\tF5"), self.make_space(_(u"Load or reload current path"))) parent.okMenu.SetBitmap( wx.Bitmap(utils.icon_path(u'reload.png'), wx.BITMAP_TYPE_PNG)) parent.getAllMenu = wx.MenuItem( parent, wxID_MENUPICKER_ALL, _(u"Select &All\tctrl+A"), self.make_space(_(u"Select all items in picker"))) parent.getAllMenu.SetBitmap( wx.Bitmap(utils.icon_path(u'selectAll.png'), wx.BITMAP_TYPE_PNG)) parent.getNoneMenu = wx.MenuItem( parent, wxID_MENUPICKER_NONE, _(u"Select &None\tctrl+N"), self.make_space(_(u"Deselect all items in picker"))) parent.getNoneMenu.SetBitmap( wx.Bitmap(utils.icon_path(u'selectNone.png'), wx.BITMAP_TYPE_PNG)) parent.walkMenu = wx.MenuItem( parent, wxID_MENUPICKER_WALK, _(u"Recursive &selection\tctrl+R"), self.make_space( _(u"Get all files in directory and sub-directories, but no folders" ))) parent.walkMenu.SetBitmap( wx.Bitmap(utils.icon_path(u'walk.png'), wx.BITMAP_TYPE_PNG)) parent.AppendItem(parent.browseMenu) parent.AppendItem(parent.okMenu) parent.AppendSeparator() parent.AppendItem(parent.getAllMenu) parent.AppendItem(parent.getNoneMenu) parent.AppendItem(parent.walkMenu) self.Bind(wx.EVT_MENU, self.picker.browse_for_path, id=wxID_MENUPICKER_BROWSE) self.Bind(wx.EVT_MENU, self.picker.set_path, id=wxID_MENUPICKER_OK) self.Bind(wx.EVT_MENU, self.picker.select_none, id=wxID_MENUPICKER_NONE) self.Bind(wx.EVT_MENU, self.picker.select_all, id=wxID_MENUPICKER_ALL) self.Bind(wx.EVT_MENU, self.picker.walk_from_menu, id=wxID_MENUPICKER_WALK)
def __init_ctrls(self, parent): wx.Dialog.__init__(self, id=wxID_HELP, name=u'help', parent=parent, size=wx.Size(591, 600), style=wx.DEFAULT_DIALOG_STYLE | wx.MAXIMIZE_BOX | wx.RESIZE_BORDER, title=_(u"Help")) self.SetMinSize(wx.Size(350, 200)) self.SetClientSize(wx.Size(600, 570)) self.SetFont(wx.Font(9, wx.DEFAULT, wx.NORMAL, wx.NORMAL)) self.SetIcon(wx.Icon(utils.icon_path(u'help.ico'), wx.BITMAP_TYPE_ICO)) self.notebook1 = wx.Notebook(id=wxID_HELPNOTEBOOK1, name=u'notebook1', parent=self, size=wx.Size(600, 571), style=wx.SUNKEN_BORDER) self.htmlWindow1 = wx.html.HtmlWindow(id=wxID_HELPHTMLWINDOW1, name=u'htmlWindow1', parent=self.notebook1, style=wx.html.HW_SCROLLBAR_AUTO) self.htmlWindow2 = wx.html.HtmlWindow(id=wxID_HELPHTMLWINDOW2, name=u'htmlWindow2', parent=self.notebook1, style=wx.html.HW_SCROLLBAR_AUTO) self.htmlWindow3 = wx.html.HtmlWindow(id=wxID_HELPHTMLWINDOW3, name=u'htmlWindow3', parent=self.notebook1, style=wx.html.HW_SCROLLBAR_AUTO) self.htmlWindow4 = wx.html.HtmlWindow(id=wxID_HELPHTMLWINDOW4, name=u'htmlWindow4', parent=self.notebook1, style=wx.html.HW_SCROLLBAR_AUTO) self.htmlWindow5 = wx.html.HtmlWindow(id=wxID_HELPHTMLWINDOW5, name=u'htmlWindow5', parent=self.notebook1, style=wx.html.HW_SCROLLBAR_AUTO) self.__init_notebook_pages(self.notebook1)
def __init__(self, prnt, helpFile, title, icon, size=False): if size == False: size = wx.Size(610, 531) wx.Dialog.__init__(self, id=-1, name='smallHelpDialog', parent=prnt, style=wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER | wx.MAXIMIZE_BOX, title=title) self.SetIcon( wx.Icon(utils.icon_path(u'%s.ico') % icon, wx.BITMAP_TYPE_ICO)) self.display = wx.html.HtmlWindow(id=-1, name=u'display', parent=self, style=wx.html.HW_SCROLLBAR_AUTO) #self.display.SetMinSize(wx.Size(1010, 531)) self.Center(wx.HORIZONTAL | wx.VERTICAL) if u'gtk2' in wx.PlatformInfo: self.display.SetStandardFonts() docspath = app.get_real_path(u'help') if os.path.isfile(os.path.join(docspath, app.language, helpFile)): helpFile = os.path.join(docspath, app.language, helpFile) else: helpFile = os.path.join(docspath, u'en_US', helpFile) self.display.LoadPage(helpFile) self.SetSize(size) self.CentreOnParent()
def init_pages(self, varPanel, varText, varIcon): """initialize notebook pages""" # load and assign notebook page images il = wx.ImageList(16, 16) img0 = il.Add(wx.Bitmap(utils.icon_path(varIcon), wx.BITMAP_TYPE_ICO)) img1 = il.Add(wx.Bitmap(utils.icon_path(u'numbering.ico'), wx.BITMAP_TYPE_ICO)) img2 = il.Add(wx.Bitmap(utils.icon_path(u'date_time.ico'), wx.BITMAP_TYPE_ICO)) self.AssignImageList(il) self.AddPage(page=varPanel, text=varText, select=True, imageId=img0) self.AddPage(imageId=img1, page=self.numbering, select=False, text=_(u"Numbering settings")) self.AddPage(imageId=img2, page=self.dateTime, select=False, text=_(u"Date && Time settings"))
def __init__(self, prnt, helpFile, title, icon, size=False): if size == False: size = wx.Size(610, 531) wx.Dialog.__init__(self, id=-1, name='smallHelpDialog', parent=prnt, style=wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER | wx.MAXIMIZE_BOX, title=title) self.SetIcon(wx.Icon(utils.icon_path(u'%s.ico') % icon, wx.BITMAP_TYPE_ICO)) self.display = wx.html.HtmlWindow(id=-1, name=u'display', parent=self, style=wx.html.HW_SCROLLBAR_AUTO) #self.display.SetMinSize(wx.Size(1010, 531)) self.Center(wx.HORIZONTAL | wx.VERTICAL) if u'gtk2' in wx.PlatformInfo: self.display.SetStandardFonts() docspath = app.get_real_path(u'help') if os.path.isfile(os.path.join(docspath, app.language, helpFile)): helpFile = os.path.join(docspath, app.language, helpFile) else: helpFile = os.path.join(docspath, u'en_US', helpFile) self.display.LoadPage(helpFile) self.SetSize(size) self.CentreOnParent()
def __init_ctrls(self, parent): wx.Dialog.__init__(self, name=u'dialog', parent=parent, style=wx.CAPTION, title=u'Preferences') self.SetIcon( wx.Icon(utils.icon_path(u'preferences.ico'), wx.BITMAP_TYPE_ICO)) self.notebook = Notebook(id=-1, name=u'notebook', parent=self) self.apply = wx.Button(id=wx.ID_APPLY, name=u'apply', parent=self, style=0) self.apply.Bind(wx.EVT_BUTTON, self.__on_apply_button) self.ok = wx.Button(id=wx.ID_OK, name=u'ok', parent=self, style=0) self.ok.Bind(wx.EVT_BUTTON, self.__on_ok_button) self.close = wx.Button(id=wx.ID_CANCEL, name=u'close', parent=self, style=0) self.close.Bind(wx.EVT_BUTTON, self.__close_diag) self.__init_sizers()
def __init_menu_help(self, parent): parent.aboutMenu = wx.MenuItem(parent, wxID_MENUHELP_ABOUT, _(u"About"), self.make_space(_(u"Display general information about Metamorphose"))) parent.aboutMenu.SetBitmap(wx.Bitmap(utils.icon_path(u'about.ico'), wx.BITMAP_TYPE_ICO)) parent.helpMenu = wx.MenuItem(parent, wxID_MENUHELP_HELP, _(u"&Help\tF1"), self.make_space(_(u"How to use Metamorphose"))) parent.helpMenu.SetBitmap(wx.Bitmap(utils.icon_path(u'help.ico'), wx.BITMAP_TYPE_ICO)) parent.examplesMenu = wx.MenuItem(parent, wxID_MENUHELP_EXAMPLES, _(u"&Examples\tF2"), self.make_space(_(u"Some useful examples"))) parent.examplesMenu.SetBitmap(wx.Bitmap( utils.icon_path(u'examples.ico'), wx.BITMAP_TYPE_ICO)) parent.FormatHelpMenu = wx.MenuItem(parent, wxID_MENUHELP_FORMATHELP, _(u"&Date && Time Formats"), self.make_space(_(u"Display a reference for Date & Time formats"))) parent.FormatHelpMenu.SetBitmap(wx.Bitmap( utils.icon_path(u'date_time.ico'), wx.BITMAP_TYPE_ICO)) parent.REhelpMenu = wx.MenuItem(parent, wxID_MENUHELP_REHELP, _(u"&Regular Expressions"), self.make_space(_(u"Display a regular expression reference"))) parent.REhelpMenu.SetBitmap(wx.Bitmap(utils.icon_path(u're.ico'), wx.BITMAP_TYPE_ICO)) parent.AppendItem(parent.aboutMenu) parent.AppendItem(parent.helpMenu) parent.AppendItem(parent.examplesMenu) parent.AppendItem(parent.FormatHelpMenu) parent.AppendItem(parent.REhelpMenu) self.Bind(wx.EVT_MENU, self.show_about, id=wxID_MENUHELP_ABOUT) self.Bind(wx.EVT_MENU, self.show_help, id=wxID_MENUHELP_HELP) self.Bind(wx.EVT_MENU, self.show_small_help, id=wxID_MENUHELP_EXAMPLES) self.Bind(wx.EVT_MENU, self.show_small_help, id=wxID_MENUHELP_FORMATHELP) self.Bind(wx.EVT_MENU, self.show_small_help, id=wxID_MENUHELP_REHELP)
def __init_ctrls(self, prnt): wx.Dialog.__init__(self, id=wxID_EDITDIALOG, name=u'editDialog', parent=prnt, style=wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER, title=_(u"Manually Edit")) self.SetIcon(wx.Icon(utils.icon_path(u'edit.png'), wx.BITMAP_TYPE_PNG)) self.staticText1 = wx.StaticText( id=wxID_EDITDIALOGSTATICTEXT1, label=_(u"Manually edit name, use with care."), name='staticText1', parent=self) self.staticText2 = wx.StaticText( id=wxID_EDITDIALOGSTATICTEXT2, label= _(u"Use the up and down keys to save changes to the name and \nmove to another item." ), name='staticText2', parent=self) self.staticText3 = wx.StaticText( id=wxID_EDITDIALOGSTATICTEXT3, label=_(u"Previewing will destroy any changes!"), name='staticText3', parent=self) self.staticText3.SetFont( wx.Font(10, wx.SWISS, wx.NORMAL, wx.BOLD, False)) self.value = wx.TextCtrl(id=wxID_EDITDIALOGVALUE, name=u'value', parent=self, size=wx.Size(410, -1), value=u'') self.backward = wx.Button(id=wx.ID_BACKWARD, name='backward', parent=self) self.backward.Bind(wx.EVT_BUTTON, self.set_next_item_from_button, id=wx.ID_BACKWARD) self.button1 = wx.Button(id=wx.ID_CANCEL, name='button1', parent=self) self.button2 = wx.Button(id=wx.ID_OK, name='button2', parent=self) self.forward = wx.Button(id=wx.ID_FORWARD, name='forward', parent=self) self.forward.Bind(wx.EVT_BUTTON, self.set_next_item_from_button, id=wx.ID_FORWARD) # Windows and Linux do things differently # Bind both ways to be sure self.value.Bind(wx.EVT_KEY_DOWN, self.keyboard_events) self.Bind(wx.EVT_KEY_DOWN, self.keyboard_events) self.__init_sizers()
def __init__(self, parent, ID, name, showHidden): self.parent = parent.GetParent() wx.GenericDirCtrl.__init__(self, parent, ID, name, defaultFilter=0, filter="", style=wx.DIRCTRL_DIR_ONLY) if showHidden: self.ShowHidden(True) isz = (16, 16) il = wx.ImageList(isz[0], isz[1]) # closed folder: il.Add(wx.Bitmap(utils.icon_path(u"folder16.png"), wx.BITMAP_TYPE_PNG)) # open folder: il.Add(wx.Bitmap(utils.icon_path(u"folderOpen.png"), wx.BITMAP_TYPE_PNG)) # root of filesystem (linux): il.Add(wx.Bitmap(utils.icon_path(u"root.ico"), wx.BITMAP_TYPE_ICO)) # drive letter (windows): il.Add(wx.Bitmap(utils.icon_path(u"hdd.ico"), wx.BITMAP_TYPE_ICO)) # cdrom drive: il.Add(wx.Bitmap(utils.icon_path(u"cdrom.ico"), wx.BITMAP_TYPE_ICO)) # removable drive on win98: il.Add(wx.Bitmap(utils.icon_path(u"fdd.ico"), wx.BITMAP_TYPE_ICO)) # removable drive (floppy, flash, etc): il.Add(wx.Bitmap(utils.icon_path(u"fdd.ico"), wx.BITMAP_TYPE_ICO)) self.il = il self.GetTreeCtrl().SetImageList(il) self.bind()
def __init__(self, parent, ID, name, showHidden): self.parent = parent.GetParent() wx.GenericDirCtrl.__init__(self, parent, ID, name, defaultFilter=0, filter='', style=wx.DIRCTRL_DIR_ONLY) if showHidden: self.ShowHidden(True) isz = (16, 16) il = wx.ImageList(isz[0], isz[1]) # closed folder: il.Add(wx.Bitmap(utils.icon_path(u'folder16.png'), wx.BITMAP_TYPE_PNG)) # open folder: il.Add( wx.Bitmap(utils.icon_path(u'folderOpen.png'), wx.BITMAP_TYPE_PNG)) # root of filesystem (linux): il.Add(wx.Bitmap(utils.icon_path(u'root.ico'), wx.BITMAP_TYPE_ICO)) # drive letter (windows): il.Add(wx.Bitmap(utils.icon_path(u'hdd.ico'), wx.BITMAP_TYPE_ICO)) # cdrom drive: il.Add(wx.Bitmap(utils.icon_path(u'cdrom.ico'), wx.BITMAP_TYPE_ICO)) # removable drive on win98: il.Add(wx.Bitmap(utils.icon_path(u'fdd.ico'), wx.BITMAP_TYPE_ICO)) # removable drive (floppy, flash, etc): il.Add(wx.Bitmap(utils.icon_path(u'fdd.ico'), wx.BITMAP_TYPE_ICO)) self.il = il self.GetTreeCtrl().SetImageList(il) self.bind()
def __init_menu_picker(self, parent): parent.browseMenu = wx.MenuItem(parent, wxID_MENUPICKER_BROWSE, _(u"&Browse...\tF4"), self.make_space(_(u"Browse for path"))) parent.browseMenu.SetBitmap(wx.Bitmap( utils.icon_path(u'browse.png'), wx.BITMAP_TYPE_PNG)) parent.okMenu = wx.MenuItem(parent, wxID_MENUPICKER_OK, _(u"&Refresh\tF5"), self.make_space(_(u"Load or reload current path"))) parent.okMenu.SetBitmap(wx.Bitmap(utils.icon_path(u'reload.png'), wx.BITMAP_TYPE_PNG)) parent.getAllMenu = wx.MenuItem(parent, wxID_MENUPICKER_ALL, _(u"Select &All\tctrl+A"), self.make_space(_(u"Select all items in picker"))) parent.getAllMenu.SetBitmap(wx.Bitmap( utils.icon_path(u'selectAll.png'), wx.BITMAP_TYPE_PNG)) parent.getNoneMenu = wx.MenuItem(parent, wxID_MENUPICKER_NONE, _(u"Select &None\tctrl+N"), self.make_space(_(u"Deselect all items in picker"))) parent.getNoneMenu.SetBitmap(wx.Bitmap( utils.icon_path(u'selectNone.png'), wx.BITMAP_TYPE_PNG)) parent.walkMenu = wx.MenuItem(parent, wxID_MENUPICKER_WALK, _(u"Recursive &selection\tctrl+R"), self.make_space(_(u"Get all files in directory and sub-directories, but no folders"))) parent.walkMenu.SetBitmap(wx.Bitmap(utils.icon_path(u'walk.png'), wx.BITMAP_TYPE_PNG)) parent.AppendItem(parent.browseMenu) parent.AppendItem(parent.okMenu) parent.AppendSeparator() parent.AppendItem(parent.getAllMenu) parent.AppendItem(parent.getNoneMenu) parent.AppendItem(parent.walkMenu) self.Bind(wx.EVT_MENU, self.picker.browse_for_path, id=wxID_MENUPICKER_BROWSE) self.Bind(wx.EVT_MENU, self.picker.set_path, id=wxID_MENUPICKER_OK) self.Bind(wx.EVT_MENU, self.picker.select_none, id=wxID_MENUPICKER_NONE) self.Bind(wx.EVT_MENU, self.picker.select_all, id=wxID_MENUPICKER_ALL) self.Bind(wx.EVT_MENU, self.picker.walk_from_menu, id=wxID_MENUPICKER_WALK)
def __init_menu_renamer(self, parent): parent.destroyMenu = wx.MenuItem(parent, wxID_MENURENAMER_DESTROY, _(u"Delete operation"), self.make_space(_(u"Delete current operation"))) parent.destroyMenu.SetBitmap(wx.Bitmap(utils.icon_path(u'errors.ico'), wx.BITMAP_TYPE_ICO)) parent.destroyAllMenu = wx.MenuItem(parent, wxID_MENURENAMER_DESTROYALL, _(u"Delete all operations\tctrl+D"), self.make_space(_(u"Delete all operations"))) parent.destroyAllMenu.SetBitmap(wx.Bitmap(utils.icon_path(u'nuke.png'), wx.BITMAP_TYPE_PNG)) parent.AppendItem(parent.destroyMenu) parent.AppendItem(parent.destroyAllMenu) self.Bind(wx.EVT_MENU, self.renamer.view.delete_operation, id=wxID_MENURENAMER_DESTROY) self.Bind(wx.EVT_MENU, self.renamer.view.destroy_all_operations, id=wxID_MENURENAMER_DESTROYALL)
def __init_menu_edit(self, parent): parent.PrefsMenu = wx.MenuItem(parent, wxID_MENUSETTINGS_PREFERENCES, _(u"Preferences"), self.make_space(_(u"Change your preferences"))) parent.langMenu = wx.MenuItem(parent, wxID_MENUSETTINGS_LANG, _(u"Language"), self.make_space(_(u"Change the language"))) parent.PrefsMenu.SetBitmap(wx.Bitmap( utils.icon_path(u'preferences.ico'), wx.BITMAP_TYPE_ICO)) parent.AppendItem(parent.PrefsMenu) parent.langMenu.SetBitmap(wx.Bitmap( utils.icon_path(u'language.png'), wx.BITMAP_TYPE_PNG)) parent.AppendItem(parent.langMenu) self.Bind(wx.EVT_MENU, self.show_preferences, id=wxID_MENUSETTINGS_PREFERENCES) self.Bind(wx.EVT_MENU, self.language_select, id=wxID_MENUSETTINGS_LANG)
def __init__(self, parent, id, name): wx.Toolbook.__init__(self, parent, id, name=name, style=wx.BK_TOP) il = wx.ImageList(22, 22) imgGeneral = il.Add( wx.Bitmap(utils.icon_path(u'22/general.png'), wx.BITMAP_TYPE_PNG)) imgDisplay = il.Add( wx.Bitmap(utils.icon_path(u'22/display.png'), wx.BITMAP_TYPE_PNG)) imgColors = il.Add( wx.Bitmap(utils.icon_path(u'22/colors.png'), wx.BITMAP_TYPE_PNG)) imgAuto = il.Add( wx.Bitmap(utils.icon_path(u'22/auto.png'), wx.BITMAP_TYPE_PNG)) imgLog = il.Add( wx.Bitmap(utils.icon_path(u'22/log.png'), wx.BITMAP_TYPE_PNG)) imgError = il.Add( wx.Bitmap(utils.icon_path(u'22/error.png'), wx.BITMAP_TYPE_PNG)) self.AssignImageList(il) panels = ((general, _(u'General'), imgGeneral), (display, _(u'Display'), imgDisplay), (colors, _(u'Colors'), imgColors), (automation, _(u'Automate'), imgAuto), (logging, _(u'Logging'), imgLog), (errorCheck, _(u'Error Checks'), imgError)) i = 0 for pane in panels: page = getattr(pane[0], 'Panel') page = page(self) self.AddPage(page, pane[1], imageId=pane[2]) notebookPage = self.GetPage(i) if not parent.initial: parent.load_prefs(notebookPage) if hasattr(notebookPage, 'init_enabled'): notebookPage.init_enabled() i += 1
def __init__(self, parent, id, name): wx.Toolbook.__init__(self, parent, id, name=name, style=wx.BK_TOP) il = wx.ImageList(22, 22) imgGeneral = il.Add(wx.Bitmap(utils.icon_path(u'22/general.png'), wx.BITMAP_TYPE_PNG)) imgDisplay = il.Add(wx.Bitmap(utils.icon_path(u'22/display.png'), wx.BITMAP_TYPE_PNG)) imgColors = il.Add(wx.Bitmap(utils.icon_path(u'22/colors.png'), wx.BITMAP_TYPE_PNG)) imgAuto = il.Add(wx.Bitmap(utils.icon_path(u'22/auto.png'), wx.BITMAP_TYPE_PNG)) imgLog = il.Add(wx.Bitmap(utils.icon_path(u'22/log.png'), wx.BITMAP_TYPE_PNG)) imgError = il.Add(wx.Bitmap(utils.icon_path(u'22/error.png'), wx.BITMAP_TYPE_PNG)) self.AssignImageList(il) panels = ( (general, _(u'General'), imgGeneral), (display, _(u'Display'), imgDisplay), (colors, _(u'Colors'), imgColors), (automation, _(u'Automate'), imgAuto), (logging, _(u'Logging'), imgLog), (errorCheck, _(u'Error Checks'), imgError) ) i = 0 for pane in panels: page = getattr(pane[0], 'Panel') page = page(self) self.AddPage(page, pane[1], imageId=pane[2]) notebookPage = self.GetPage(i) parent.load_prefs(notebookPage) if hasattr(notebookPage, 'init_enabled'): notebookPage.init_enabled() i += 1
def __init_ctrls(self, prnt): wx.SystemOptions.SetOption('msw.notebook.themed-background', '0') if app.debug: self.SetTitle(u"Métamorphose 2 v. %s -- DEBUG MODE" % app.version) else: self.SetTitle(u"Métamorphose 2 (beta)") self.SetBackgroundColour(wx.NullColour) self.SetAutoLayout(False) self.SetStatusBarPane(0) self.SetIcon( wx.Icon(utils.icon_path(u'metamorphose.ico'), wx.BITMAP_TYPE_ICO)) self.SetThemeEnabled(True) self.__init_fonts() self.statusBar1 = ESB.EnhancedStatusBar(id=wxID_MAIN_WINDOWSTATUSBAR1, name=u'statusBar1', parent=self) self.SetStatusBar(self.statusBar1) self.statusImage = wx.StaticBitmap(bitmap=self.statusImages[u'eyes'], id=wxID_MAIN_WINDOWSTATUSIMAGE, name=u'statusImage', parent=self.statusBar1, size=wx.Size(-1, 16), style=0) self.statusBar1.AddWidget(self.statusImage, ESB.ESB_ALIGN_LEFT) self.splitter = MySplitter(self) # notebook self.notebook = wx.Notebook(id=wxID_MAIN_WINDOWNOTEBOOK, name=u'notebook', parent=self.splitter, style=wx.NB_TOP | wx.NO_BORDER) self.notebook.SetThemeEnabled(True) self.bottomWindow = bottomWindow.MainPanel(self.splitter, self) self.SetMinSize(wx.Size(-1, 600)) self.splitter.SetMinimumPaneSize(40) if wx.Platform == '__WXGTK__': split = -210 elif wx.Platform == '__WXMSW__': split = -200 else: split = -205 self.splitter.SplitHorizontally(self.notebook, self.bottomWindow, split)
def __init_ctrls(self, parent): wx.Dialog.__init__(self, name=u'dialog', parent=parent, style=wx.CAPTION | wx.STAY_ON_TOP, title=_(u"Preferences")) self.SetIcon(wx.Icon(utils.icon_path(u'preferences.ico'), wx.BITMAP_TYPE_ICO)) self.notebook = Notebook(id=-1, name=u'notebook', parent=self) self.apply = wx.Button(id=wx.ID_APPLY, name=u'apply', parent=self, style=0) self.apply.Bind(wx.EVT_BUTTON, self.__on_apply_button) self.ok = wx.Button(id=wx.ID_OK, name=u'ok', parent=self, style=0) self.ok.Bind(wx.EVT_BUTTON, self.__on_ok_button) self.close = wx.Button(id=wx.ID_CANCEL, name=u'close', parent=self, style=0) self.close.Bind(wx.EVT_BUTTON, self.__close_diag) self.__init_sizers()
def __init_ctrls(self, prnt, Title): wx.Dialog.__init__(self, id=-1, name=u'langSelect', parent=prnt, size=wx.Size(281, 292), style=wx.DEFAULT_DIALOG_STYLE, title=Title) self.SetIcon( wx.Icon(utils.icon_path(u'language.png'), wx.BITMAP_TYPE_PNG)) def getBitmap(lang): return wx.Bitmap(utils.icon_path(u'flags/%s.png' % lang), wx.BITMAP_TYPE_PNG) # add languages selection to interface for lang_info in languages: lang = lang_info[0] setattr( self, lang, wx.RadioButton(id=-1, label=lang_info[1], name=lang, parent=self, style=0)) getattr(self, lang).SetToolTipString(u"%s (%s)" % (lang_info[1], lang)) setattr( self, '%s_flag' % lang, wx.StaticBitmap(parent=self, id=-1, bitmap=getBitmap(lang_info[2]))) self.ok = wx.Button(id=wx.ID_OK, name=u'ok', parent=self, pos=wx.Point(20, 300), style=0) self.cancel = wx.Button(id=wx.ID_CANCEL, name=u'cancel', parent=self, pos=wx.Point(120, 300), style=0)
def __init_ctrls(self, prnt): wx.SystemOptions.SetOption('msw.notebook.themed-background', '0') if app.debug: self.SetTitle(u"Métamorphose 2 v. %s -- DEBUG MODE" % app.version) else: self.SetTitle(u"Métamorphose 2 (beta)") self.SetBackgroundColour(wx.NullColour) self.SetAutoLayout(False) self.SetStatusBarPane(0) self.SetIcon(wx.Icon(utils.icon_path(u'metamorphose.ico'), wx.BITMAP_TYPE_ICO)) self.SetThemeEnabled(True) self.__init_fonts() self.statusBar1 = ESB.EnhancedStatusBar(id=wxID_MAIN_WINDOWSTATUSBAR1, name=u'statusBar1', parent=self) self.SetStatusBar(self.statusBar1) self.statusImage = wx.StaticBitmap(bitmap=self.statusImages[u'eyes'], id=wxID_MAIN_WINDOWSTATUSIMAGE, name=u'statusImage', parent=self.statusBar1, size=wx.Size(-1, 16), style=0) self.statusBar1.AddWidget(self.statusImage, ESB.ESB_ALIGN_LEFT) self.splitter = MySplitter(self) # notebook self.notebook = wx.Notebook(id=wxID_MAIN_WINDOWNOTEBOOK, name=u'notebook', parent=self.splitter, style=wx.NB_TOP | wx.NO_BORDER) self.notebook.SetThemeEnabled(True) self.bottomWindow = bottomWindow.MainPanel(self.splitter, self) self.SetMinSize(wx.Size(-1, 600)) self.splitter.SetMinimumPaneSize(40) if wx.Platform == '__WXGTK__': split = -210 elif wx.Platform == '__WXMSW__': split = -200 else: split = -205 self.splitter.SplitHorizontally(self.notebook, self.bottomWindow, split)
def __init_ctrls(self, prnt): wx.Dialog.__init__(self, id=wxID_EDITDIALOG, name=u'editDialog', parent=prnt, style=wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER, title=_(u"Manually Edit")) self.SetIcon(wx.Icon(utils.icon_path(u'edit.png'), wx.BITMAP_TYPE_PNG)) self.staticText1 = wx.StaticText(id=wxID_EDITDIALOGSTATICTEXT1, label=_(u"Manually edit name, use with care."), name='staticText1', parent=self) self.staticText2 = wx.StaticText(id=wxID_EDITDIALOGSTATICTEXT2, label=_(u"Use the up and down keys to save changes to the name and \nmove to another item."), name='staticText2', parent=self) self.staticText3 = wx.StaticText(id=wxID_EDITDIALOGSTATICTEXT3, label=_(u"Previewing will destroy any changes!"), name='staticText3', parent=self) self.staticText3.SetFont(wx.Font(10, wx.SWISS, wx.NORMAL, wx.BOLD, False)) self.value = wx.TextCtrl(id=wxID_EDITDIALOGVALUE, name=u'value', parent=self, size=wx.Size(410, -1), value=u'') self.backward = wx.Button(id=wx.ID_BACKWARD, name='backward', parent=self) self.backward.Bind(wx.EVT_BUTTON, self.set_next_item_from_button, id=wx.ID_BACKWARD) self.button1 = wx.Button(id=wx.ID_CANCEL, name='button1', parent=self) self.button2 = wx.Button(id=wx.ID_OK, name='button2', parent=self) self.forward = wx.Button(id=wx.ID_FORWARD, name='forward', parent=self) self.forward.Bind(wx.EVT_BUTTON, self.set_next_item_from_button, id=wx.ID_FORWARD) # Windows and Linux do things differently # Bind both ways to be sure self.value.Bind(wx.EVT_KEY_DOWN, self.keyboard_events) self.Bind(wx.EVT_KEY_DOWN, self.keyboard_events) self.__init_sizers()
def __init_ctrls(self, prnt, Title): wx.Dialog.__init__(self, id=-1, name=u'langSelect', parent=prnt, size=wx.Size(281, 292), style=wx.DEFAULT_DIALOG_STYLE, title=Title) self.SetIcon(wx.Icon(utils.icon_path(u'language.png'), wx.BITMAP_TYPE_PNG)) def getBitmap(lang): return wx.Bitmap(utils.icon_path(u'flags/%s.png' % lang), wx.BITMAP_TYPE_PNG) # add languages selection to interface for lang_info in languages: lang = lang_info[0] setattr(self, lang, wx.RadioButton(id=-1, label=lang_info[1], name=lang, parent=self, style=0)) getattr(self, lang).SetToolTipString(u"%s (%s)" % (lang_info[1], lang)) setattr(self, '%s_flag' % lang, wx.StaticBitmap(parent=self, id=-1, bitmap=getBitmap(lang_info[2]))) self.ok = wx.Button(id=wx.ID_OK, name=u'ok', parent=self, pos=wx.Point(20, 300), style=0) self.cancel = wx.Button(id=wx.ID_CANCEL, name=u'cancel', parent=self, pos=wx.Point(120, 300), style=0)
def __init_ctrls(self, prnt): wx.Panel.__init__(self, id=wxID_, name=u'mainPanel', parent=prnt, size=wx.DefaultSize, style=wx.TAB_TRAVERSAL) self.staticText1 = wx.StaticText(id=wxID_STATICTEXT1, label=_(u"Available:"), name='staticText1', parent=self, style=0) self.availableOperations = wx.ListCtrl(id=wxID_AVAILABLEOPERATIONS, name=u'availableOperations', parent=self, style=wx.LC_REPORT | wx.LC_NO_HEADER | wx.LC_SINGLE_SEL) self.availableOperations.Bind(wx.EVT_LIST_ITEM_ACTIVATED, self.stack_operation, id=wxID_AVAILABLEOPERATIONS) self.availableOperations.InsertColumn(0, '', format=wx.LIST_FORMAT_LEFT, width=-1) # add operations to list i = 0 for op in sorted(operations.defs.keys()): self.availableOperations.InsertStringItem(i, op) i += 1 # set vertical size h = self.availableOperations.GetItemRect(0)[-1] ops = self.availableOperations.GetItemCount() if wx.Platform == '__WXMSW__': h = (h * ops) + 6 else: h = h * ops # set horizontal size longest = operations.get_longest_name_length() w = app.fontParams['size'] * longest scrollBarSize = wx.SystemSettings.GetMetric(wx.SYS_VSCROLL_X) Size = (w, h) self.availableOperations.SetMinSize(Size) self.availableOperations.SetColumnWidth(0, w-scrollBarSize) self.usedOperations = UsedOperations(wxID_USEDOPERATIONS, u'usedOperations', self, w, scrollBarSize) self.usedOperations.Bind(wx.EVT_LIST_ITEM_SELECTED, self.__used_operations_listbox, id=wxID_USEDOPERATIONS) self.staticText2 = wx.StaticText(id=wxID_STATICTEXT2, label=_(u"Used:"), name='staticText2', parent=self, style=0) self.moveDown = wx.BitmapButton(bitmap=wx.Bitmap(utils.icon_path(u'down.png'), wx.BITMAP_TYPE_PNG), id=wxID_MOVEDOWN, name=u'moveDown', parent=self, style=wx.BU_AUTODRAW) self.moveDown.SetToolTipString(_(u"Move current operation down by 1")) self.moveDown.Bind(wx.EVT_BUTTON, self.__move_down_button, id=wxID_MOVEDOWN) self.moveUp = wx.BitmapButton(bitmap=wx.Bitmap(utils.icon_path(u'up.png'), wx.BITMAP_TYPE_PNG), id=wxID_MOVEUP, name=u'moveUp', parent=self, style=wx.BU_AUTODRAW) self.moveUp.SetToolTipString(_(u"Move current operation up by 1")) self.moveUp.Bind(wx.EVT_BUTTON, self.__move_up_button, id=wxID_MOVEUP) self.enableOperation = wx.ToggleButton(id=wxID_ENABLEOPERATION, label=_(u"Disable"), name=u'enableOperation', parent=self, style=wx.BU_EXACTFIT) self.enableOperation.SetToolTipString(_(u"Enable or Disable current operation")) self.enableOperation.SetValue(False) self.enableOperation.Bind(wx.EVT_TOGGLEBUTTON, self.__operation_toggle_btn, id=wxID_ENABLEOPERATION) self.deleteOperations = wx.Choice(choices=[_(u"Delete"), _(u"Delete All")], id=wxID_DELETEOPERATIONS, name=u'actions', parent=self) self.deleteOperations.SetSelection(0) self.deleteOperations.SetToolTipString(_(u"Delete operations")) self.deleteOperations.Bind(wx.EVT_CHOICE, self.__actions_choice, id=wxID_DELETEOPERATIONS) self.resetOperationButton = wx.Button(id=wxID_RESETOPERATIONBUTTON, label=_(u"Reset"), name=u'resetOperationButton', parent=self, style=wx.BU_EXACTFIT) self.resetOperationButton.SetToolTipString(_(u"Reset the current operation")) self.resetOperationButton.Bind(wx.EVT_BUTTON, self.__reset_operation, id=wxID_RESETOPERATIONBUTTON) self.staticText3 = wx.StaticText(id=wxID_STATICTEXT3, label=_(u"Order:"), name='staticText3', parent=self, style=0) self.applyExtension = wx.CheckBox(id=wxID_APPLYEXTENSION, label=_(u"extension"), name=u'applyExtension', parent=self, style=0) self.applyExtension.SetValue(False) self.applyExtension.Bind(wx.EVT_CHECKBOX, self.__set_operations_apply, id=wxID_APPLYEXTENSION) self.applyName = wx.CheckBox(id=wxID_APPLYNAME, label=_(u"name"), name='applyName', parent=self, style=0) self.applyName.SetValue(True) self.applyName.Bind(wx.EVT_CHECKBOX, self.__set_operations_apply, id=wxID_APPLYNAME) self.staticText4 = wx.StaticText(id=wxID_STATICTEXT4, label=_(u"Apply to:"), name='staticText4', parent=self, style=0) self.staticText5 = IntroTextPanel(self, wxID_STATICTEXT5) dt = OperationDropTarget(self.usedOperations) self.usedOperations.SetDropTarget(dt) wx.EVT_LIST_BEGIN_DRAG(self.availableOperations, self.availableOperations.GetId(), self.__available_drag_init) wx.EVT_LIST_BEGIN_DRAG(self.usedOperations, self.usedOperations.GetId(), self.__used_drag_init)
def __init_menu(self, parent, n): """ The used operations' right click menu """ # 'apply to' sub menu parent.applyTo = applyTo = wx.Menu() applyTo.name = wx.MenuItem(applyTo, wxID_MENUAPPLYNAME, _(u"Name"), kind=wx.ITEM_CHECK) applyTo.extension = wx.MenuItem(applyTo, wxID_MENUAPPLYEXTENSION, _(u"Extension"), kind=wx.ITEM_CHECK) applyTo.AppendItem(applyTo.name) applyTo.AppendItem(applyTo.extension) self.Bind(wx.EVT_MENU, self.__set_operations_apply_menu, id=wxID_MENUAPPLYNAME) self.Bind(wx.EVT_MENU, self.__set_operations_apply_menu, id=wxID_MENUAPPLYEXTENSION) opPanel = self.Core.operations[n] if opPanel.params['applyName']: applyTo.name.Check(True) if opPanel.params['applyExtension']: applyTo.extension.Check(True) # main menu parent.up = wx.MenuItem(parent, wxID_MENUUP, _(u"Move up")) parent.up.SetBitmap(wx.Bitmap(utils.icon_path(u'up.png'), wx.BITMAP_TYPE_PNG)) parent.down = wx.MenuItem(parent, wxID_MENUDOWN, _(u"Move down")) parent.down.SetBitmap(wx.Bitmap(utils.icon_path(u'down.png'), wx.BITMAP_TYPE_PNG)) if opPanel.IsEnabled(): txt = _(u"Disable") ico = 'disable' else: txt = _(u"Enable") ico = 'enable' parent.disable = wx.MenuItem(parent, wxID_MENUDISABLE, txt) parent.disable.SetBitmap(wx.Bitmap(utils.icon_path(u"%s.png" % ico), wx.BITMAP_TYPE_PNG)) parent.reset = wx.MenuItem(parent, wxID_MENURESET, _(u"Reset")) parent.reset.SetBitmap(wx.Bitmap(utils.icon_path(u'reset_op.png'), wx.BITMAP_TYPE_PNG)) parent.destroy = wx.MenuItem(parent, wxID_MENUDESTROY, _(u"Delete")) parent.destroy.SetBitmap(wx.Bitmap(utils.icon_path(u'errors.ico'), wx.BITMAP_TYPE_ICO)) parent.destroyAll = wx.MenuItem(parent, wxID_MENUDESTROYALL, _(u"Delete All")) parent.destroyAll.SetBitmap(wx.Bitmap(utils.icon_path(u'nuke.png'), wx.BITMAP_TYPE_PNG)) parent.setStatus = wx.MenuItem(parent, wxID_MENUSETSTATUS, _(u"Enable/Disable")) parent.setStatus.SetBitmap(wx.Bitmap(utils.icon_path(u're.ico'), wx.BITMAP_TYPE_ICO)) parent.changeName = wx.MenuItem(parent, wxID_MENUCHANGENAME, _(u"Change Name")) parent.AppendItem(parent.up) parent.AppendItem(parent.down) if _(u"directory") not in self.usedOperations.GetItemText(n): parent.applyToMenu = wx.MenuItem(parent, -1, _(u"Apply to"), subMenu=applyTo) parent.AppendItem(parent.applyToMenu) parent.AppendItem(parent.disable) parent.AppendItem(parent.reset) parent.AppendItem(parent.destroy) parent.AppendItem(parent.destroyAll) self.Bind(wx.EVT_MENU, self.__move_up_button, id=wxID_MENUUP) self.Bind(wx.EVT_MENU, self.__move_down_button, id=wxID_MENUDOWN) self.Bind(wx.EVT_MENU, self.__operation_toggle_btn, id=wxID_MENUDISABLE) self.Bind(wx.EVT_MENU, self.__reset_operation, id=wxID_MENURESET) self.Bind(wx.EVT_MENU, self.delete_operation, id=wxID_MENUDESTROY) self.Bind(wx.EVT_MENU, self.__destroy_all_gui_operations, id=wxID_MENUDESTROYALL)
def __init_menu_file(self, parent): parent.LoadIniMenu = wx.MenuItem(parent, wxID_MENUFILE_LOADINI, _(u"&Load Config\tctrl+L"), self.make_space(_(u"Load configuration from file"))) parent.LoadIniMenu.SetBitmap(wx.Bitmap(utils.icon_path(u'loadIni.png'), wx.BITMAP_TYPE_PNG)) parent.SaveIniMenu = wx.MenuItem(parent, wxID_MENUFILE_SAVEINI, _(u"&Save Config\tctrl+S"), self.make_space(_(u"Save configuration to file"))) parent.SaveIniMenu.SetBitmap(wx.Bitmap(utils.icon_path(u'saveIni.png'), wx.BITMAP_TYPE_PNG)) parent.SaveLog = wx.MenuItem(parent, wxID_MENUFILE_SAVELOG, _(u"&Export to log file"), self.make_space(_(u"Save current snapshot to a log file"))) parent.SaveLog.SetBitmap(wx.Bitmap(utils.icon_path(u'CSVto.png'), wx.BITMAP_TYPE_PNG)) parent.Import = wx.MenuItem(parent, wxID_MENUFILE_IMPORT, _(u"&Import from log file"), self.make_space(_(u"Load a snapshot"))) parent.Import.SetBitmap(wx.Bitmap(utils.icon_path(u'CSVfrom.png'), wx.BITMAP_TYPE_PNG)) parent.resetApp = wx.MenuItem(parent, wxID_MENUFILE_RESET, _(u"&Reset"), self.make_space(_(u"Reset all settings"))) parent.resetApp.SetBitmap(wx.Bitmap(utils.icon_path(u'preview.png'), wx.BITMAP_TYPE_PNG)) parent.PreviewMenu = wx.MenuItem(parent, wxID_MENUFILE_PREVIEW, _(u"&Preview\tF7"), self.make_space(_(u"Preview selection"))) parent.PreviewMenu.SetBitmap(wx.Bitmap(utils.icon_path(u'preview.png'), wx.BITMAP_TYPE_PNG)) parent.GoMenu = wx.MenuItem(parent, wxID_MENUFILE_GO, _(u"&Go !\tF8"), self.make_space(_(u"Rename selection"))) parent.GoMenu.SetBitmap(wx.Bitmap(utils.icon_path(u'go.png'), wx.BITMAP_TYPE_PNG)) parent.exitMenu = wx.MenuItem(parent, wxID_MENUFILE_EXIT, _(u"&Quit\tctrl+Q"), self.make_space(_(u"Quit Metamorphose"))) parent.exitMenu.SetBitmap(wx.Bitmap(utils.icon_path(u'exit.png'), wx.BITMAP_TYPE_PNG)) parent.AppendItem(parent.LoadIniMenu) parent.AppendItem(parent.SaveIniMenu) parent.AppendSeparator() parent.AppendItem(parent.SaveLog) parent.SaveLog.Enable(False) parent.AppendItem(parent.Import) parent.AppendSeparator() parent.AppendItem(parent.PreviewMenu) parent.AppendItem(parent.GoMenu) parent.AppendSeparator() parent.AppendItem(parent.resetApp) parent.AppendItem(parent.exitMenu) self.Bind(wx.EVT_MENU, self.save_items_as_text, id=wxID_MENUFILE_SAVELOG) self.Bind(wx.EVT_MENU, self.import_items_from_text, id=wxID_MENUFILE_IMPORT) self.Bind(wx.EVT_MENU, self.save_config, id=wxID_MENUFILE_SAVEINI) self.Bind(wx.EVT_MENU, self.load_config, id=wxID_MENUFILE_LOADINI) self.Bind(wx.EVT_MENU, self.on_preview_button, id=wxID_MENUFILE_PREVIEW) self.Bind(wx.EVT_MENU, self.rename_items, id=wxID_MENUFILE_GO) self.Bind(wx.EVT_MENU, self.on_menu_reset, id=wxID_MENUFILE_RESET) self.Bind(wx.EVT_MENU, self.on_menu_exit, id=wxID_MENUFILE_EXIT)
def __init_ctrls(self, prnt): wx.Panel.__init__(self, id=wxID_SORTINGPANEL, name=u'sortingPanel', parent=prnt, style=wx.TAB_TRAVERSAL) self.basicBox = wx.StaticBox(id=wxID_SORTINGPANELBASICBOX, label=_(u"Basic Options"), name=u'basicBox', parent=self, style=0) self.advancedBox = wx.StaticBox(id=wxID_SORTINGPANELADVANCEDBOX, label=_(u"Advanced Options"), name=u'advancedBox', parent=self, style=0) self.ascending = wx.RadioButton(id=wxID_SORTINGPANELASCENDING, label=_("Ascending (0 - 9)"), name='ascending', parent=self, style=wx.RB_GROUP) self.ascending.Bind(wx.EVT_RADIOBUTTON, self.setSortingOptions, id=wxID_SORTINGPANELASCENDING) self.descending = wx.RadioButton(id=wxID_SORTINGPANELDESCENDING, label=_("Descending (9 - 0)"), name='descending', parent=self, style=0) self.descending.Bind(wx.EVT_RADIOBUTTON, self.setSortingOptions, id=wxID_SORTINGPANELDESCENDING) self.manually = wx.RadioButton(id=wxID_SORTINGPANELMANUALLY, label=_(u"Manually Adjust"), name=u'manually', parent=self, style=0) self.manually.SetValue(False) self.manually.Bind(wx.EVT_RADIOBUTTON, self.setSortingOptions, id=wxID_SORTINGPANELMANUALLY) self.downButton = wx.BitmapButton(bitmap=wx.Bitmap(utils.icon_path(u'down.png'), wx.BITMAP_TYPE_PNG), id=wxID_SORTINGPANELDOWNBUTTON, name=u'downButton', parent=self, style=wx.BU_AUTODRAW) self.downButton.Bind(wx.EVT_BUTTON, self.change_item_order, id=wxID_SORTINGPANELDOWNBUTTON) self.upButton = wx.BitmapButton(bitmap=wx.Bitmap(utils.icon_path(u'up.png'), wx.BITMAP_TYPE_PNG), id=wxID_SORTINGPANELUPBUTTON, name=u'upButton', parent=self, style=wx.BU_AUTODRAW) self.upButton.Bind(wx.EVT_BUTTON, self.change_item_order, id=wxID_SORTINGPANELUPBUTTON) self.upTop = wx.BitmapButton(bitmap=wx.Bitmap(utils.icon_path(u'upAll.ico'), wx.BITMAP_TYPE_ICO), id=wxID_SORTINGPANELUPTOP, name=u'upTop', parent=self, style=wx.BU_AUTODRAW) self.upTop.SetToolTipString(_(u"move to top")) self.upTop.Bind(wx.EVT_BUTTON, self.change_item_order, id=wxID_SORTINGPANELUPTOP) self.downBottom = wx.BitmapButton(bitmap=wx.Bitmap(utils.icon_path(u'downAll.ico'), wx.BITMAP_TYPE_ICO), id=wxID_SORTINGPANELDOWNBOTTOM, name=u'downBottom', parent=self, style=wx.BU_AUTODRAW) self.downBottom.SetToolTipString(_(u"move to bottom")) self.downBottom.Bind(wx.EVT_BUTTON, self.change_item_order, id=wxID_SORTINGPANELDOWNBOTTOM) self.upMore = wx.BitmapButton(bitmap=wx.Bitmap(utils.icon_path(u'up5.png'), wx.BITMAP_TYPE_PNG), id=wxID_SORTINGPANELUPMORE, name=u'upMore', parent=self, style=wx.BU_AUTODRAW) self.upMore.SetToolTipString(_(u"move by 5")) self.upMore.Bind(wx.EVT_BUTTON, self.change_item_order, id=wxID_SORTINGPANELUPMORE) self.downMore = wx.BitmapButton(bitmap=wx.Bitmap(utils.icon_path(u'down5.png'), wx.BITMAP_TYPE_PNG), id=wxID_SORTINGPANELDOWNMORE, name=u'downMore', parent=self, style=wx.BU_AUTODRAW) self.downMore.SetToolTipString(_(u"move by 5")) self.downMore.Bind(wx.EVT_BUTTON, self.change_item_order, id=wxID_SORTINGPANELDOWNMORE) self.dirsPlace = wx.Choice(choices=[_(u"Directories before files"), _(u"Directories after files"), _(u"Directories mixed with files")], id=wxID_SORTINGPANELDIRSPLACE, name=u'dirsPlace', parent=self) self.dirsPlace.SetSelection(0) self.dirsPlace.Bind(wx.EVT_CHOICE, self.show_preview) self.normalSort = wx.RadioButton(id=wxID_SORTINGPANELNORMALSORT, label=_(u"Sort normally"), name=u'normalSort', parent=self, style=wx.RB_GROUP) self.normalSort.SetToolTipString(_(u"Standard sorting by item name.")) self.normalSort.SetValue(True) self.normalSort.Bind(wx.EVT_RADIOBUTTON, self.setSortingOptions, id=wxID_SORTINGPANELNORMALSORT) self.intelySort = wx.RadioButton(id=wxID_SORTINGPANELINTELYSORT, label=_(u"Sort numbers intelligently"), name=u'intelySort', parent=self, style=0) self.intelySort.SetToolTipString(_(u"Order these types of items: ...19, 2, 20...\nMay have unpredictable results!")) self.intelySort.Bind(wx.EVT_RADIOBUTTON, self.setStatOptions, id=wxID_SORTINGPANELINTELYSORT) self.byPosition = wx.RadioButton(id=wxID_SORTINGPANELBYPOSITION, label=_(u"Sort on a section of the name:"), name=u'byPosition', parent=self, style=0) self.byPosition.Bind(wx.EVT_RADIOBUTTON, self.setStatOptions, id=wxID_SORTINGPANELBYPOSITION) self.staticText1 = wx.StaticText(id=wxID_SORTINGPANELSTATICTEXT1, label=_(u"Starting at:"), name='staticText1', parent=self, style=0) self.PosStart = wx.SpinCtrl(id=wxID_SORTINGPANELPOSSTART, initial=0, max=255, min=-255, name=u'PosStart', parent=self, size=wx.Size(50, -1), style=wx.SP_ARROW_KEYS, value='0') self.PosStart.Bind(wx.EVT_SPINCTRL, self.show_preview, id=wxID_SORTINGPANELPOSSTART) self.staticText2 = wx.StaticText(id=wxID_SORTINGPANELSTATICTEXT2, label=_(u"Selection length:"), name='staticText2', parent=self, style=0) self.PosLength = wx.SpinCtrl(id=wxID_SORTINGPANELPOSLENGTH, initial=1, max=255, min=1, name=u'PosLength', parent=self, size=wx.Size(50, -1), style=wx.SP_ARROW_KEYS, value='1') self.PosLength.Bind(wx.EVT_SPINCTRL, self.show_preview, id=wxID_SORTINGPANELPOSLENGTH) self.statSortChoice = wx.Choice(choices=[self.ctime, _(u"last modification time"), _(u"last access time"), _(u"file size"), _(u"mode (protection bits)"), _(u"user ID of owner"), _(u"group ID of owner"), _(u"Exif : picture taken"), _(u"Exif : image modified"), ], id=wxID_SORTINGPANELSTATSORTCHOICE, name=u'statSortChoice', parent=self, style=0) self.statSortChoice.SetSelection(0) self.statSortChoice.Bind(wx.EVT_CHOICE, self.show_preview, id=wxID_SORTINGPANELSTATSORTCHOICE) self.statSort = wx.RadioButton(id=wxID_SORTINGPANELSTATSORT, label=_(u"Sort by item attributes, using:"), name=u'statSort', parent=self, style=0) self.statSort.Bind(wx.EVT_RADIOBUTTON, self.setStatOptions, id=wxID_SORTINGPANELSTATSORT) self.__init_sizers()
def getBitmap(lang): return wx.Bitmap(utils.icon_path(u'flags/%s.png' % lang), wx.BITMAP_TYPE_PNG)
def __init_ctrls(self, parent): wx.Dialog.__init__(self, id=wxID_ABOUT, name=u'About', parent=parent, style=wx.DEFAULT_DIALOG_STYLE, title=_(u"About Metamorphose")) self.SetIcon(wx.Icon(utils.icon_path(u'about.ico'), wx.BITMAP_TYPE_ICO)) fontParams = app.fontParams fontSize = fontParams['size'] fontFamily = fontParams['family'] fontStyle = fontParams['style'] self.SetFont(wx.Font(fontSize + 1, fontFamily, fontStyle, wx.NORMAL, False, u'Times New Roman')) self.Center(wx.HORIZONTAL | wx.VERTICAL) self.SetThemeEnabled(True) self.greet = wx.StaticText(id=wxID_ABOUTGREET, label=u"Métamorphose 2", name=u'greet', parent=self) self.greet.SetFont(wx.Font(fontSize + 4, fontFamily, fontStyle, wx.BOLD, False)) self.CLOSE = wx.BitmapButton(id=wxID_ABOUTCLOSE, bitmap=wx.Bitmap(utils.icon_path(u'metamorphose128.png'), wx.BITMAP_TYPE_PNG), name=u'CLOSE', parent=self, style=wx.BU_AUTODRAW) self.CLOSE.SetToolTipString(_(u"Click here to exit")) self.CLOSE.Bind(wx.EVT_BUTTON, self.on_close_button, id=wxID_ABOUTCLOSE) self.copyright = wx.StaticText(id=wxID_ABOUTCOPYRIGHT, label=u"Copyright © 2006-2015 Ianaré Sévi", name=u'copyright', parent=self) self.copyright.SetFont(wx.Font(fontSize + 2, fontFamily, fontStyle, wx.BOLD, False)) self.version = wx.StaticText(id=wxID_ABOUTVERSION, label=_(u"Version: %s") % app.version, name=u'version', parent=self) self.version.SetFont(wx.Font(fontSize + 2, fontFamily, fontStyle, wx.BOLD, False)) self.wxVersion = wx.StaticText(id=wxID_ABOUTWXVERSION, label=_(u"Using Python %s, wxPython %s") % ( platform.python_version(), utils.get_wxversion() ), name=u'version', parent=self) self.wxVersion.SetFont(wx.Font(fontSize + 1, fontFamily, fontStyle, wx.NORMAL, False)) self.link = hl.HyperLinkCtrl(self, wxID_ABOUTLINK, _(u"Metamorphose Home Page"), URL=u'http://file-folder-ren.sourceforge.net/', style=0) self.bugReport = hl.HyperLinkCtrl(self, wxID_ABOUTLINK, _(u"GitHub Project Page"), URL=u'https://github.com/metamorphose/metamorphose2') self.bugReport.Show(True) self.donateButton = wx.Button(id=wxID_PANELDONATEBUTTON, label=_(u"Donate"), name=u'donateButton', parent=self) self.donateButton.SetFont(wx.Font(fontSize + 4, fontFamily, fontStyle, wx.BOLD, False, u'Times New Roman')) self.donateButton.Bind(wx.EVT_BUTTON, self.on_donate_button, id=wxID_PANELDONATEBUTTON) self.donate = hl.HyperLinkCtrl(self, wxID_ABOUTDONATE, _(u"Donate"), URL=u'http://sourceforge.net/donate/index.php?group_id=146403') self.donate.Show(False) self.licenseButton = wx.Button(id=wxID_PANELLICENSEBUTTON, label=_(u"License"), name=u'licenseButton', parent=self) self.licenseButton.Bind(wx.EVT_BUTTON, self.show_small_help,id=wxID_PANELLICENSEBUTTON) self.creditsButton = wx.Button(id=wxID_PANELCREDITSBUTTON, label=_(u"Credits"), name=u'licenseButton', parent=self) self.creditsButton.Bind(wx.EVT_BUTTON, self.show_small_help,id=wxID_PANELCREDITSBUTTON)
def __init_menu(self, parent, n): """ The used operations' right click menu """ # 'apply to' sub menu parent.applyTo = applyTo = wx.Menu() applyTo.name = wx.MenuItem(applyTo, wxID_MENUAPPLYNAME, _(u"Name"), kind=wx.ITEM_CHECK) applyTo.extension = wx.MenuItem(applyTo, wxID_MENUAPPLYEXTENSION, _(u"Extension"), kind=wx.ITEM_CHECK) applyTo.AppendItem(applyTo.name) applyTo.AppendItem(applyTo.extension) self.Bind(wx.EVT_MENU, self.__set_operations_apply_menu, id=wxID_MENUAPPLYNAME) self.Bind(wx.EVT_MENU, self.__set_operations_apply_menu, id=wxID_MENUAPPLYEXTENSION) opPanel = self.Core.operations[n] if opPanel.params['applyName']: applyTo.name.Check(True) if opPanel.params['applyExtension']: applyTo.extension.Check(True) # main menu parent.up = wx.MenuItem(parent, wxID_MENUUP, _(u"Move up")) parent.up.SetBitmap( wx.Bitmap(utils.icon_path(u'up.png'), wx.BITMAP_TYPE_PNG)) parent.down = wx.MenuItem(parent, wxID_MENUDOWN, _(u"Move down")) parent.down.SetBitmap( wx.Bitmap(utils.icon_path(u'down.png'), wx.BITMAP_TYPE_PNG)) if opPanel.IsEnabled(): txt = _(u"Disable") ico = 'disable' else: txt = _(u"Enable") ico = 'enable' parent.disable = wx.MenuItem(parent, wxID_MENUDISABLE, txt) parent.disable.SetBitmap( wx.Bitmap(utils.icon_path(u"%s.png" % ico), wx.BITMAP_TYPE_PNG)) parent.reset = wx.MenuItem(parent, wxID_MENURESET, _(u"Reset")) parent.reset.SetBitmap( wx.Bitmap(utils.icon_path(u'reset_op.png'), wx.BITMAP_TYPE_PNG)) parent.destroy = wx.MenuItem(parent, wxID_MENUDESTROY, _(u"Delete")) parent.destroy.SetBitmap( wx.Bitmap(utils.icon_path(u'errors.ico'), wx.BITMAP_TYPE_ICO)) parent.destroyAll = wx.MenuItem(parent, wxID_MENUDESTROYALL, _(u"Delete All")) parent.destroyAll.SetBitmap( wx.Bitmap(utils.icon_path(u'nuke.png'), wx.BITMAP_TYPE_PNG)) parent.setStatus = wx.MenuItem(parent, wxID_MENUSETSTATUS, _(u"Enable/Disable")) parent.setStatus.SetBitmap( wx.Bitmap(utils.icon_path(u're.ico'), wx.BITMAP_TYPE_ICO)) parent.changeName = wx.MenuItem(parent, wxID_MENUCHANGENAME, _(u"Change Name")) parent.AppendItem(parent.up) parent.AppendItem(parent.down) if _(u"directory") not in self.usedOperations.GetItemText(n): parent.applyToMenu = wx.MenuItem(parent, -1, _(u"Apply to"), subMenu=applyTo) parent.AppendItem(parent.applyToMenu) parent.AppendItem(parent.disable) parent.AppendItem(parent.reset) parent.AppendItem(parent.destroy) parent.AppendItem(parent.destroyAll) self.Bind(wx.EVT_MENU, self.__move_up_button, id=wxID_MENUUP) self.Bind(wx.EVT_MENU, self.__move_down_button, id=wxID_MENUDOWN) self.Bind(wx.EVT_MENU, self.__operation_toggle_btn, id=wxID_MENUDISABLE) self.Bind(wx.EVT_MENU, self.__reset_operation, id=wxID_MENURESET) self.Bind(wx.EVT_MENU, self.delete_operation, id=wxID_MENUDESTROY) self.Bind(wx.EVT_MENU, self.__destroy_all_gui_operations, id=wxID_MENUDESTROYALL)
def __init_ctrls(self, prnt): wx.Panel.__init__(self, id=wxID_, name=u'mainPanel', parent=prnt, size=wx.DefaultSize, style=wx.TAB_TRAVERSAL) self.staticText1 = wx.StaticText(id=wxID_STATICTEXT1, label=_(u"Available:"), name='staticText1', parent=self, style=0) self.availableOperations = wx.ListCtrl( id=wxID_AVAILABLEOPERATIONS, name=u'availableOperations', parent=self, style=wx.LC_REPORT | wx.LC_NO_HEADER | wx.LC_SINGLE_SEL) self.availableOperations.Bind(wx.EVT_LIST_ITEM_ACTIVATED, self.stack_operation, id=wxID_AVAILABLEOPERATIONS) self.availableOperations.InsertColumn(0, '', format=wx.LIST_FORMAT_LEFT, width=-1) # add operations to list i = 0 for op in sorted(operations.defs.keys()): self.availableOperations.InsertStringItem(i, op) i += 1 # set vertical size h = self.availableOperations.GetItemRect(0)[-1] ops = self.availableOperations.GetItemCount() if wx.Platform == '__WXMSW__': h = (h * ops) + 6 else: h = h * ops # set horizontal size longest = operations.get_longest_name_length() w = app.fontParams['size'] * longest scrollBarSize = wx.SystemSettings.GetMetric(wx.SYS_VSCROLL_X) Size = (w, h) self.availableOperations.SetMinSize(Size) self.availableOperations.SetColumnWidth(0, w - scrollBarSize) self.usedOperations = UsedOperations(wxID_USEDOPERATIONS, u'usedOperations', self, w, scrollBarSize) self.usedOperations.Bind(wx.EVT_LIST_ITEM_SELECTED, self.__used_operations_listbox, id=wxID_USEDOPERATIONS) self.staticText2 = wx.StaticText(id=wxID_STATICTEXT2, label=_(u"Used:"), name='staticText2', parent=self, style=0) self.moveDown = wx.BitmapButton(bitmap=wx.Bitmap( utils.icon_path(u'down.png'), wx.BITMAP_TYPE_PNG), id=wxID_MOVEDOWN, name=u'moveDown', parent=self, style=wx.BU_AUTODRAW) self.moveDown.SetToolTipString(_(u"Move current operation down by 1")) self.moveDown.Bind(wx.EVT_BUTTON, self.__move_down_button, id=wxID_MOVEDOWN) self.moveUp = wx.BitmapButton(bitmap=wx.Bitmap( utils.icon_path(u'up.png'), wx.BITMAP_TYPE_PNG), id=wxID_MOVEUP, name=u'moveUp', parent=self, style=wx.BU_AUTODRAW) self.moveUp.SetToolTipString(_(u"Move current operation up by 1")) self.moveUp.Bind(wx.EVT_BUTTON, self.__move_up_button, id=wxID_MOVEUP) self.enableOperation = wx.ToggleButton(id=wxID_ENABLEOPERATION, label=_(u"Disable"), name=u'enableOperation', parent=self, style=wx.BU_EXACTFIT) self.enableOperation.SetToolTipString( _(u"Enable or Disable current operation")) self.enableOperation.SetValue(False) self.enableOperation.Bind(wx.EVT_TOGGLEBUTTON, self.__operation_toggle_btn, id=wxID_ENABLEOPERATION) self.deleteOperations = wx.Choice( choices=[_(u"Delete"), _(u"Delete All")], id=wxID_DELETEOPERATIONS, name=u'actions', parent=self) self.deleteOperations.SetSelection(0) self.deleteOperations.SetToolTipString(_(u"Delete operations")) self.deleteOperations.Bind(wx.EVT_CHOICE, self.__actions_choice, id=wxID_DELETEOPERATIONS) self.resetOperationButton = wx.Button(id=wxID_RESETOPERATIONBUTTON, label=_(u"Reset"), name=u'resetOperationButton', parent=self, style=wx.BU_EXACTFIT) self.resetOperationButton.SetToolTipString( _(u"Reset the current operation")) self.resetOperationButton.Bind(wx.EVT_BUTTON, self.__reset_operation, id=wxID_RESETOPERATIONBUTTON) self.staticText3 = wx.StaticText(id=wxID_STATICTEXT3, label=_(u"Order:"), name='staticText3', parent=self, style=0) self.applyExtension = wx.CheckBox(id=wxID_APPLYEXTENSION, label=_(u"extension"), name=u'applyExtension', parent=self, style=0) self.applyExtension.SetValue(False) self.applyExtension.Bind(wx.EVT_CHECKBOX, self.__set_operations_apply, id=wxID_APPLYEXTENSION) self.applyName = wx.CheckBox(id=wxID_APPLYNAME, label=_(u"name"), name='applyName', parent=self, style=0) self.applyName.SetValue(True) self.applyName.Bind(wx.EVT_CHECKBOX, self.__set_operations_apply, id=wxID_APPLYNAME) self.staticText4 = wx.StaticText(id=wxID_STATICTEXT4, label=_(u"Apply to:"), name='staticText4', parent=self, style=0) self.staticText5 = IntroTextPanel(self, wxID_STATICTEXT5) dt = OperationDropTarget(self.usedOperations) self.usedOperations.SetDropTarget(dt) wx.EVT_LIST_BEGIN_DRAG(self.availableOperations, self.availableOperations.GetId(), self.__available_drag_init) wx.EVT_LIST_BEGIN_DRAG(self.usedOperations, self.usedOperations.GetId(), self.__used_drag_init)
def __init__(self, prnt, options): # Important variables needed throughout the application classes self.warn = [] # warnings self.bad = [] # errors self.errorLog = [] # all errors go here self.items = [] # items to rename self.spacer = u" " * 6 # spacer for status messages (to clear image) # icons used for status bar messages self.statusImages = { u'failed': wx.Bitmap(utils.icon_path(u'failed_sb.ico'), wx.BITMAP_TYPE_ICO), u'wait': wx.Bitmap(utils.icon_path(u'wait.png'), wx.BITMAP_TYPE_PNG), u'warn': wx.Bitmap(utils.icon_path(u'warn_sb.ico'), wx.BITMAP_TYPE_ICO), u'complete': wx.Bitmap(utils.icon_path(u'complete.ico'), wx.BITMAP_TYPE_ICO), u'eyes': wx.Bitmap(utils.icon_path(u'eyes.png'), wx.BITMAP_TYPE_PNG), } app.debug_print("Init MainWindow") wx.Frame.__init__(self, id=wxID_MAIN_WINDOW, name=u'MainWindow', parent=prnt, style=wx.DEFAULT_FRAME_STYLE) app.debug_print("") app.debug_print("======== System Info =======") app.debug_print("Operating System: %s - %s - %s" % (platform.system(), platform.release(), platform.version())) app.debug_print("Python version: %s" % platform.python_version()) app.debug_print("wxPython version: %s" % wx.version()) app.debug_print("============================") app.debug_print("") # first run? utils.init_environment() self.set_language() # import these modules here since they need language settings activated global renamer import renamer global configs import configs global picker import picker global bottomWindow import bottomWindow # initialize preferences app.debug_print("======== Preferences =======") app.prefs = preferences.Methods() app.debug_print("============================") app.debug_print("") # build main GUI self.__init_ctrls(prnt) # clear undo if set in preferences: if app.prefs.get(u'clearUndo'): try: originalFile = codecs.open(utils.get_user_path(u'undo/original.bak'), 'w', "utf-8") originalFile.write('') renamedFile = codecs.open(utils.get_user_path(u'undo/renamed.bak'), 'w', "utf-8") renamedFile.write('') except IOError, error: utils.make_err_msg(_(u"%s\n\nCould not clear undo") % error, _(u"Error")) pass
def __init_ctrls(self, parent): wx.Dialog.__init__(self, id=wxID_ABOUT, name=u'About', parent=parent, style=wx.DEFAULT_DIALOG_STYLE, title=_(u"About Metamorphose")) self.SetIcon(wx.Icon(utils.icon_path(u'about.ico'), wx.BITMAP_TYPE_ICO)) fontParams = app.fontParams fontSize = fontParams['size'] fontFamily = fontParams['family'] fontStyle = fontParams['style'] self.SetFont( wx.Font(fontSize + 1, fontFamily, fontStyle, wx.NORMAL, False, u'Times New Roman')) self.Center(wx.HORIZONTAL | wx.VERTICAL) self.SetThemeEnabled(True) self.greet = wx.StaticText(id=wxID_ABOUTGREET, label=u"Métamorphose 2", name=u'greet', parent=self) self.greet.SetFont( wx.Font(fontSize + 4, fontFamily, fontStyle, wx.BOLD, False)) self.CLOSE = wx.BitmapButton( id=wxID_ABOUTCLOSE, bitmap=wx.Bitmap(utils.icon_path(u'metamorphose128.png'), wx.BITMAP_TYPE_PNG), name=u'CLOSE', parent=self, style=wx.BU_AUTODRAW) self.CLOSE.SetToolTipString(_(u"Click here to exit")) self.CLOSE.Bind(wx.EVT_BUTTON, self.on_close_button, id=wxID_ABOUTCLOSE) self.copyright = wx.StaticText( id=wxID_ABOUTCOPYRIGHT, label=u"Copyright © 2006-2015 Ianaré Sévi", name=u'copyright', parent=self) self.copyright.SetFont( wx.Font(fontSize + 2, fontFamily, fontStyle, wx.BOLD, False)) self.version = wx.StaticText(id=wxID_ABOUTVERSION, label=_(u"Version: %s") % app.version, name=u'version', parent=self) self.version.SetFont( wx.Font(fontSize + 2, fontFamily, fontStyle, wx.BOLD, False)) self.wxVersion = wx.StaticText( id=wxID_ABOUTWXVERSION, label=_(u"Using Python %s, wxPython %s") % (platform.python_version(), self._get_wxversion()), name=u'version', parent=self) self.wxVersion.SetFont( wx.Font(fontSize + 1, fontFamily, fontStyle, wx.NORMAL, False)) self.link = hl.HyperLinkCtrl( self, wxID_ABOUTLINK, _(u"Metamorphose Home Page"), URL=u'http://file-folder-ren.sourceforge.net/', style=0) self.bugReport = hl.HyperLinkCtrl( self, wxID_ABOUTLINK, _(u"GitHub Project Page"), URL=u'https://github.com/metamorphose/metamorphose2') self.bugReport.Show(True) self.donateButton = wx.Button(id=wxID_PANELDONATEBUTTON, label=_(u"Donate"), name=u'donateButton', parent=self) self.donateButton.SetFont( wx.Font(fontSize + 4, fontFamily, fontStyle, wx.BOLD, False, u'Times New Roman')) self.donateButton.Bind(wx.EVT_BUTTON, self.on_donate_button, id=wxID_PANELDONATEBUTTON) self.donate = hl.HyperLinkCtrl( self, wxID_ABOUTDONATE, _(u"Donate"), URL=u'http://sourceforge.net/donate/index.php?group_id=146403') self.donate.Show(False) self.licenseButton = wx.Button(id=wxID_PANELLICENSEBUTTON, label=_(u"License"), name=u'licenseButton', parent=self) self.licenseButton.Bind(wx.EVT_BUTTON, self.show_small_help, id=wxID_PANELLICENSEBUTTON) self.creditsButton = wx.Button(id=wxID_PANELCREDITSBUTTON, label=_(u"Credits"), name=u'licenseButton', parent=self) self.creditsButton.Bind(wx.EVT_BUTTON, self.show_small_help, id=wxID_PANELCREDITSBUTTON)