With Métamorphose 2, you can make your own modules and have them appear as operations in the -Renamer- panel. This is usefull if you have some specific renaming requirements that are not implemented in Métamorphose, while still allowing you to use the full capabilities of the renaming engine. Indeed, any functionality already present can be intergrated into your custom module.
Note: All steps documented here are already made for you, including the example module.
First step is to create the 'YourModuleName.py' file containing a wx.Panel class
with the GUI stuff and the renaming operation.
Your panel class should be called 'OpPanel' otherwise it will not work properly.
def __init__(self, parent, main_window): global main main = main_window global parent parent = prnt self.opsApply = [parent.applyName.GetValue(), parent.applyExtension.GetValue()]To rename, you must make a function in your panel class that has these characteristics: # the renaming function def renameItem(self, path, name, ext, original): newName = utils.joinExt(self.opsApply,name,ext) if not newName: return path,name,ext #== your code START ====================# newName = u"it worked" #== your code END ======================# # apply to name and/or ext name,ext = utils.splitExt(self.opsApply,newName,name,ext) return path, name, ext path is the path as returned by os.path.split()[0] .name is the name as returned by os.path.split()[1] .ext is the file extension.original is the full path name of the item, before
any renaming operations.newName will be either name or name+'.'+ext Input will all be in Unicode, you MUST output to Unicode! If you want to have autopreview, link the following function to an event (or function) you wish to trigger a preview action: # make event a wx.Event or an integer value of 1 or 0 main.showPreview(event)
OK, now to add your module to the application. That's it, I'll take care of the rest ;-)
Thou shall not enslave my free program! Ianaré Sévi ianare@gmail.com This document is released under the GNU Free Documentation License v1.2. Last modified: 2007-09-01 20:17:17 |