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)
def initComponents(self): self.panel = JPanel() self.panel.setLayout(BorderLayout()) toolbar = JToolBar() openb = JButton("Select", actionPerformed=self.onClick) toolbar.add(openb) self.area = JTextArea() self.area.setBorder(BorderFactory.createEmptyBorder(10, 100, 10, 100)) pane = JScrollPane() pane.getViewport().add(self.area) self.panel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)) self.panel.add(pane) self.add(self.panel) self.add(toolbar)
def initUI(self): global outputTextField self.panel = JPanel() self.panel.setLayout(BorderLayout()) toolbar = JToolBar() openb = JButton("Choose input file", actionPerformed=self.onClick) outputLabel = JLabel(" Enter output file name: ") outputTextField = JTextField("hl7OutputReport.txt", 5) print outputTextField.getText() toolbar.add(openb) toolbar.add(outputLabel) toolbar.add(outputTextField) self.area = JTextArea() self.area.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)) self.area.setText("Select your HL7 ORU messages text file to be converted to tab-delimited flat \nfile with select HL7 fields.\n") self.area.append("You can enter the path + file name for your output file or it will default to the current \nfile name in the text field above in your current working directory.") pane = JScrollPane() pane.getViewport().add(self.area) self.panel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)) self.panel.add(pane) self.add(self.panel) self.add(toolbar, BorderLayout.NORTH) self.setTitle("HL7 ORU Results Reporter") self.setSize(600, 300) self.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE) self.setLocationRelativeTo(None) self.setVisible(True) return outputTextField.getText()
def createToolbar(self): toolBar = JToolBar() margin = Insets(1, 1, 1, 1) [self.createButton(toolBar, i, t, f) for (i, t, f) in self.actions] return toolBar
def make(eb): view = JToolBar("Tools") btn_undo = make_button("Undo", "Undo previous action", "res/icons/edit-undo.png") btn_redo = make_button("Redo", "Redo previously undone action", "res/icons/edit-redo.png") btn_combo = make_button("Combo", "Select and move elements", "res/icons/combo-tool.png") btn_link = make_button("Link", "Create link between two elements", "res/icons/link-tool.png") btn_ellipse = make_button("Ellipse", "Create new ellipse element", "res/icons/document-new.png") # TODO: change btn_path = make_button("Path", "Create new path element") # TODO: to be removed view.add(btn_undo) view.add(btn_redo) view.add(JToolBar.Separator(Dimension(30, 30))) view.add(btn_combo) view.add(btn_link) view.add(btn_ellipse) view.add(btn_path) btn_undo.mousePressed = lambda _: eb.dispatch(Undo_Requested()) btn_redo.mousePressed = lambda _: eb.dispatch(Redo_Requested()) btn_combo.mousePressed = lambda _: eb.dispatch(Tool_Changed(COMBO_TOOL)) btn_link.mousePressed = lambda _: eb.dispatch(Tool_Changed(LINK_TOOL)) btn_ellipse.mousePressed = lambda _: eb.dispatch(Tool_Changed(ELLIPSE_TOOL)) btn_path.mousePressed = lambda _: eb.dispatch(Tool_Changed(PATH_TOOL)) states = { } trans = { } return (view, states, trans)
class ToolBar( ca.nengo.ui.lib.world.handlers.SelectionHandler.SelectionListener, ca.nengo.ui.lib.world.WorldObject.ChildListener, java.lang.Runnable): 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) def selectionChanged(self, objs): self.update() def childAdded(self, obj): self.update() def childRemoved(self, obj): self.update() def update(self): net = self.get_selected_network() self.button_scriptgen.enabled = net is not None topnet = self.get_selected_network(top_parent=True) self.button_run.enabled = topnet is not None 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 def get_current_network_viewer(self): viewer = None net = self.get_selected_network(top_parent=False) if net is not None and hasattr(net, 'getViewer'): viewer = net.getViewer() if viewer is None or viewer.isDestroyed(): if (hasattr(net, 'networkParent') and net.networkParent is not None): net = net.networkParent viewer = net.getViewer() elif net is not None and hasattr(net, 'networkParent'): net = net.networkParent if net is not None and hasattr(net, 'getViewer'): viewer = net.getViewer() if (viewer is not None and (viewer.isDestroyed() or not isinstance(viewer, ca.nengo.ui.models.viewers.NetworkViewer))): return None else: return viewer def do_open(self, event): ca.nengo.ui.actions.OpenNeoFileAction(self.ng).doAction() def do_save(self, event): network = self.get_selected_network() if network is not None: ca.nengo.ui.actions.SaveNodeAction(network).doAction() def do_scriptgen(self, event): network = self.get_selected_network() if network is not None: ca.nengo.ui.actions.GeneratePythonScriptAction(network).doAction() def do_clear_all(self, event): ca.nengo.ui.actions.ClearAllAction("Clear all").doAction() def do_inspect(self, event): self.ng.toggleConfigPane() def do_run(self, event): network = self.get_selected_network(top_parent=True) if network is not None: ca.nengo.ui.actions.RunInteractivePlotsAction(network).doAction() def do_interrupt(self, event): self.ng.progressIndicator.interrupt()