Пример #1
0
 def OnAddFilter(self, ft, event = None):
     """
     
         Add given filter to current filter bank.
         
         Parameters:
             ft    -    filter (Filter)
             event -    wx.Event
     
     """
     # add filter selected in menu
     modules = GetModules(self.dim)
     idx = modules.index(ft.__class__)
     if ft.set_filter(self):
         # if filter 'set' procedure succeeded, add filter to list in adequate position
         itm = self.list.HitTest(self.menuPosition)
         if itm[0]==-1: # test if click didn't occur above an item
             pos = self.list.GetItemCount()
             if self.list.GetFirstSelected()>-1: # if not, test if one list item is selected
                 pos = self.list.GetFirstSelected()
         else: # otherwise, insert before clicked item
             pos = itm[0]
         self.list.InsertImageStringItem(pos,ft.__extname__,idx)
         self.bank.InsertFilter(pos, ft)
     # update reference plot if necessary, update display
     self.UpdateFilterDisplay()
     self.OnFilterUpdate()
Пример #2
0
 def RefreshFilters(self, inst=None):
     """
     
         Refresh displayed filter list.
         
         Parameters:
             inst    -    pubsub event data (FilterBank)
     
     """
     if inst!=None:
         if inst!=self.bank: return
     # store currently selected items
     sels = []
     itm = self.list.GetFirstSelected()
     while itm>-1:
         sels.append(itm)
         itm = self.list.GetNextSelected(itm)
     # rebuild filter list
     modules = GetModules(self.dim)
     self.list.DeleteAllItems()
     if not(isinstance(self.bank,FilterBank)): return
     for ft in self.bank.filters:
         if modules.count(ft.__class__)>0:
             n = modules.index(ft.__class__)
             self.list.InsertImageStringItem(self.list.GetItemCount(),ft.name,n)
             f = self.list.GetItemFont(self.list.GetItemCount()-1)
             f.SetPointSize(10)
             if ft.is_active:
                 f.SetStyle(wx.FONTSTYLE_NORMAL)
             else:
                 f.SetStyle(wx.FONTSTYLE_ITALIC)
             self.list.SetItemFont(self.list.GetItemCount()-1,f)
     # select previously selected items
     for x in sels:
         self.list.Select(x, True)