示例#1
0
    def __init__(self):
        #color = Color(.25,.25,.25,1)
        self.ng = ca.nengo.ui.NengoGraphics.getInstance()
        self.toolbar = JToolBar("Nengo actions", floatable=False)
        #self.toolbar.setBackground(color)

        ### Make and add buttons
        self.toolbar.add(make_button('open', self.do_open, 'open file'))
        self.toolbar.add(make_button(
                'savefile', self.do_save, 'save selected network'))
        self.button_scriptgen = make_button(
            'scriptgen', self.do_scriptgen,
            'generate selected network script', enabled=False)
        self.toolbar.add(self.button_scriptgen)
        self.toolbar.add(make_button('clear', self.do_clear_all, 'clear all'))

        self.toolbar.add(Box.createHorizontalGlue())

        self.toolbar.add(make_button('inspect', self.do_inspect, 'inspect'))
        self.button_run = make_button(
            'interactive', self.do_run, 'interactive plots', enabled=False)
        self.toolbar.add(self.button_run)

        SelectionHandler.addSelectionListener(self)
        self.ng.getWorld().getGround().addChildrenListener(self)

        self.ng.setToolbar(self.toolbar)
示例#2
0
 def get_selected_network(self, top_parent=False):
     network = SelectionHandler.getActiveNetwork(top_parent)
     if network is not None:
         return network
     else:
         # see if the main world has only one network; if so, return it
         found_candidate = False
         for wo in self.ng.world.ground.children:
             if isinstance(wo, ca.nengo.ui.models.nodes.UINetwork):
                 if not found_candidate:
                     network = wo
                     found_candidate = True
                 else:
                     network = None
                     break
     return network