Esempio n. 1
0
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
Esempio n. 2
0
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)
Esempio n. 9
0
 def on_update(self, event):
     Macros('', ['Update Plugins List>None']).start(self.app,
                                                    callafter=self.load)
Esempio n. 10
0
 def on_convex(self, event):
     Macros('', ['ROI Convex Hull>None']).start(self.app)
Esempio n. 11
0
 def on_shrink(self, event):
     Macros('', ['ROI Shrink>None']).start(self.app)
Esempio n. 12
0
 def on_inflate(self, event):
     Macros('', ['ROI Inflate>None']).start(self.app)
Esempio n. 13
0
 def on_save(self, event):
     Macros('', ['ROI Save>None']).start(self.app)
Esempio n. 14
0
 def on_open(self, event):
     Macros('', ['ROI Open>None']).start(self.app)
Esempio n. 15
0
 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)
Esempio n. 16
0
 def on_box(self, event):
     Macros('', ['ROI Bound Box>None']).start(self.app)
Esempio n. 17
0
 def on_clip(self, event):
     Macros('', ['ROI Clip>None']).start(self.app)
Esempio n. 18
0
	def on_make(self, event):
		Macros(None, ['Build Mark Image>None']).start(self.app)
Esempio n. 19
0
 def on_add(self, event):
     Macros('', ['ROI Add>None']).start(self.app, callafter=self.UpdateData)