def extend_plugins(path, lst, err): rst = [] for i in lst: if isinstance(i, tuple) or i=='-': rst.append(i) elif i[-3:] == 'rpt': pt = os.path.join(root_dir,path) rst.append(Report(i[:-4], pt+'/'+i)) elif i[-3:] in {'.md', '.mc', '.wf'}: p = os.path.join(os.path.join(root_dir, path), i).replace('\\','/') rst.append(Macros(i[:-3], ['Open>{"path":"%s"}'%p])) elif i[-6:] in ['wgt.py', 'gts.py']: try: rpath = path.replace('/', '.').replace('\\','.') plg = __import__('imagepy.'+ rpath+'.'+i[:-3],'','',['']) if hasattr(plg, 'wgts'): rst.extend([j if j=='-' else Widget(j) for j in plg.wgts]) else: rst.append(Widget(plg.Plugin)) except Exception as e: err.append((path, i, sys.exc_info()[1])) else: try: rpath = path.replace('/', '.').replace('\\','.') plg = __import__('imagepy.'+ rpath+'.'+i[:-3],'','',['']) if hasattr(plg, 'plgs'): rst.extend([j for j in plg.plgs]) for p in plg.plgs: if not isinstance(p, str): pass else: rst.append(plg.Plugin) except Exception as e: err.append((path, i, sys.exc_info()[1])) return rst
def extend_tools(path, lst, err): rst = [] for i in lst: if i[-3:] in ('.mc', '.md', '.wf', 'rpt'): p = os.path.join(os.path.join(root_dir,path), i).replace('\\','/') rst.append((Macros(i[:-3], ['Open>{"path":"%s"}'%p]), os.path.join(root_dir, path)+'/'+i[:-3]+'.gif')) else: try: rpath = path.replace('/', '.').replace('\\','.') plg = __import__('imagepy.'+rpath+'.'+i,'','',['']) if hasattr(plg, 'plgs'): for i,j in plg.plgs: rst.append((i, path+'/'+j)) else: rst.append((plg.Plugin, os.path.join(root_dir, path)+'/'+i.split('_')[0]+'.gif')) except Exception as e: err.append((path, i, sys.exc_info()[1])) return rst
def on_setting(self, event): Macros('', ['ROI Setting>None']).start(self.app)
def on_sketch(self, event): Macros('', ['Sketch>None']).start(self.app)
def on_clearout(self, event): Macros('', ['Clear Out>None']).start(self.app)
def on_symdiff(self, event): idx = self.lst_rois.GetFirstSelected() if idx == -1: return self.app.alert('No ROI Selected!') name = self.lst_rois.OnGetItemText(idx, 0) Macros('', ['ROI Symmetric Diff>{"name":"%s"}' % name]).start(self.app)
def on_invert(self, event): Macros('', ['ROI Invert>None']).start(self.app)
def on_add_nameless(self, event): ips = ImageManager.get() if ips is None: return self.app.alert('No image opened!') if ips.roi is None: return self.app.alert('No Roi found!') Macros('', ['ROI Add>{"name":"%s-roi"}' % ips.title]).start( self.app, callafter=self.UpdateData)
def on_update(self, event): Macros('', ['Update Plugins List>None']).start(self.app, callafter=self.load)
def on_convex(self, event): Macros('', ['ROI Convex Hull>None']).start(self.app)
def on_shrink(self, event): Macros('', ['ROI Shrink>None']).start(self.app)
def on_inflate(self, event): Macros('', ['ROI Inflate>None']).start(self.app)
def on_save(self, event): Macros('', ['ROI Save>None']).start(self.app)
def on_open(self, event): Macros('', ['ROI Open>None']).start(self.app)
def on_remove(self, event): idx = self.lst_rois.GetFirstSelected() if idx == -1: return self.app.alert('No ROI Selected!') name = self.lst_rois.OnGetItemText(idx, 0) Macros('', ['ROI Remove>{"name":"%s"}' % name]).start( self.app, callafter=self.UpdateData)
def on_box(self, event): Macros('', ['ROI Bound Box>None']).start(self.app)
def on_clip(self, event): Macros('', ['ROI Clip>None']).start(self.app)
def on_make(self, event): Macros(None, ['Build Mark Image>None']).start(self.app)
def on_add(self, event): Macros('', ['ROI Add>None']).start(self.app, callafter=self.UpdateData)