def activate(self): if not self.active: if self.currentMode is None: self.setMode(skeletonselmodebase.firstMode().name) else: self.tbdict[self.currentMode].activate() toolboxGUI.GfxToolbox.activate(self)
def __init__(self, toolbox): # The 'toolbox' argument here is the non-gui toolbox # corresponding to one of the inner toolboxes. It doesn't # matter which one. toolboxGUI.GfxToolbox.__init__(self, toolbox) vbox = gtk.VBox(spacing=2) self.gtk.add(vbox) bbox = gtk.HBox(spacing=2) gtklogger.setWidgetName(bbox, "Select") vbox.pack_start(bbox, expand=0, fill=0) bbox.pack_start(gtk.Label("Select: "), expand=0, fill=0) self.tbbox = gtk.Frame() # holds SkelSelToolboxModeGUIs vbox.pack_start(self.tbbox, expand=1, fill=1) group = None self.tbdict = {} modebuttons = [] skeletonselectionmodes.initialize() for mode in skeletonselmodebase.SkeletonSelectionMode.modes: if group: button = gtk.RadioButton(label=mode.name, group=group) else: button = gtk.RadioButton(label=mode.name) group = button modebuttons.append(button) gtklogger.setWidgetName(button, mode.name) gtklogger.connect(button, 'clicked', self.switchModeCB, mode.name) # Get the actual toolbox for each mode tb = self.gfxwindow().getToolboxByName(mode.toolboxName()) tbgui = tbclasses[mode.name](tb, tb.method) self.tbdict[mode.name] = tbgui table = gtk.Table(columns=2, rows=2) bbox.pack_start(table, expand=0, fill=0) table.attach(modebuttons[0], 0,1, 0,1) table.attach(modebuttons[1], 1,2, 0,1) table.attach(modebuttons[2], 0,1, 1,2) table.attach(modebuttons[3], 1,2, 1,2) self.currentMode = None self.setMode(skeletonselmodebase.firstMode().name)
self.tbdict[self.currentMode].activate() toolboxGUI.GfxToolbox.activate(self) def deactivate(self): self.tbdict[self.currentMode].deactivate() toolboxGUI.GfxToolbox.deactivate(self) ###################################### ## Although there are many non-gui SkeletonSelectionToolboxes, they ## all share a GUI panel, so only one of them has a makeGUI function. def _makeGUI(self): return SkeletonSelectionToolboxGUI(self) skeletonselmodebase.firstMode().tbclass.makeGUI = _makeGUI ##################################### ## Assignment of rubberband types to SkeletonSelectionRegistration ## instances. Most assignments are to *instances*, and as such are ## not member functions. The default assignment (no rubberband) is to ## the class, and so the function needs a 'self' argument. def _NoRubberBand(self, reg): debug.mainthreadTest() return rubberband.NoRubberBand() skeletonselectionmethod.SkeletonSelectionRegistration.getRubberBand = \ _NoRubberBand
def installed(self): if not self.built: # initialize, arbitrarily, to the first mode listed self.pickerCB(None, self.modedict[skeletonselmodebase.firstMode().name]) self.built = True