def __init__(self, channels):
        JFrame.__init__(self, "Informa Example News Client")
        self.setSize(400, 400)
        self.addWindowListener(BasicWindowMonitor())

        self.channels = channels
        self.channel_dict = None

        self.channelTree = None
        self.channelPanel = None
        self.itemTable = None

        self.mediator = MainMediator(self)
        
        # items (in table)
        itemScrollPane = JScrollPane(self.getItemTable())

        # channels (as tree)
        channelScrollPane = JScrollPane(self.getChannelTree())

        # put together channel info with item table
        ch_and_items = JPanel()
        ch_and_items.setLayout(BorderLayout())
        ch_and_items.add(self.getChannelPanel(), BorderLayout.NORTH)
        ch_and_items.add(itemScrollPane, BorderLayout.CENTER)

        # final step
        sp = JSplitPane(JSplitPane.HORIZONTAL_SPLIT,
                        channelScrollPane, ch_and_items)
        # print "dividerLocation", sp.getDividerLocation()
        # sp.setDividerLocation(0.5)
        self.getContentPane().add(sp, BorderLayout.CENTER)
Beispiel #2
0
 def handle(self):
     print 'connection from', self.client_address
     conn = self.request
     while 1:
         msg = conn.recv(20)
         if msg == "keymap":
             print "keymapping!"
             keymapFrame = JFrame('Key Mapping Configuration',
                            defaultCloseOperation = JFrame.EXIT_ON_CLOSE,
                            size = (300, 500)
                            )
             keyButton = JButton('Press any key in iPhone')
             keymapFrame.add(keyButton)
             keymapFrame.visible = True
             while 1:
                 recvKey = conn.recv(20)
                 keyButton.setLabel("%s?" % recvKey)
                 keyInput = raw_input()
                 keynum[recvKey] = keyInput
                 keyButton.setText('Press any key in iPhone')
                 if recvKey == "keymap":
                     keymapFrame.visible = False
                     break
         if msg == "quit()":
             conn.close()
             print self.client_address, 'disconnected'
             break
         print self.client_address, msg
Beispiel #3
0
class UI(object):
    def __init__(self, game):

        self.frame = JFrame("Tic Tac Toe",
                             defaultCloseOperation = WindowConstants.EXIT_ON_CLOSE)

        self.panel = JPanel(GridLayout(3,3))
        self.buttons = []
        self.game = game
        for row in range(3):
            for col in range(3):
                self.buttons.append(TicTacButton(row,col,'',actionPerformed=self.clicked_button))

        self.panel.add
        self.frame.add(self.panel)
        for b in self.buttons:
            self.panel.add(b)

        self.frame.pack()
        self.show()


    def show(self):
        self.frame.size = 600,600
        self.frame.visible = True


    def clicked_button(self, event):
        button = event.getSource()
        print 'current_player', self.game.current_player
        if self.game.current_player.level == 'human' and self.game.state=='next':
            button.text = self.game.current_player.xo
            self.game.update(button)
        else:
            pass
 def __init__(self, title="Development Reloader Window"):
     if jython:
         JFrame.__init__(self, title, windowClosing=self.OnClose)
         self.setBounds(0, 0, 300, 550)
     else:
         self.window = MakeWindow("pyGTK Python Reloader window", 200, 500)
         
     self.BuildWindow()
Beispiel #5
0
    def run(self):
        frame = JFrame('MainFrame', defaultCloseOperation = JFrame.DISPOSE_ON_CLOSE)
        self.addButtons(frame.getContentPane())
        frame.size = (300, 175)
        frame.visible = 1 

        self.frame = frame
        self.startTimerTask()
Beispiel #6
0
 def __init__(self, title, size):
     JFrame.__init__(self, title)
     self.setDefaultCloseOperation(self.EXIT_ON_CLOSE)
     self.setResizable(False)
     self.setSize(size[0],size[1])
     self.setDefaultLookAndFeelDecorated(True)
     self.setBackground(Color.BLACK)
     self.jpanel = Panel(size)
     self.getContentPane().add(self.jpanel)
     self.pack()
Beispiel #7
0
 def gui_open(path):
     label = JLabel(ImageIcon(ImageIO.read(File(URL(path).getFile()))))
     frame = JFrame()
     frame.getContentPane().add(label)
     frame.pack()
     frame.setLocation(200, 200)
     frame.setVisible(True)
def show():
    """ adapted from here: http://wiki.gephi.org/index.php/Toolkit_-_Reuse_the_Preview_Applet"""
    from javax.swing import JFrame
    from java.awt import BorderLayout

    pc = PreviewController
    pc.refreshPreview();
     
    # New Processing target, get the PApplet
    target = pc.getRenderTarget("processing")
    applet = target.getApplet()
    applet.init()
     
    # Refresh the preview and reset the zoom
    try:
        pc.render(target) 
    except Exception:
        # throws sun.dc.pr.PRError: sun.dc.pr.PRError: setPenT4: invalid pen transformation (singular)
        pass
    target.refresh()
    target.resetZoom()
     
    # Add the applet to a JFrame and display
    frame = JFrame("Preview")
    frame.setLayout(BorderLayout())
     
    # frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE)
    frame.add(applet, BorderLayout.CENTER)
     
    frame.pack()
    frame.setVisible(True)
def test_swing():
    frame = JFrame("Hello Jython")
    button = JButton("Pulsar", actionPerformed = hello)
    frame.add(button)
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE)
    frame.setSize(200, 100)
    frame.show()
Beispiel #10
0
class _AccountAdder:
    def __init__(self, contactslist):
        self.contactslist = contactslist
        self.mainframe = JFrame("Add New Contact")
        self.account = JComboBox(self.contactslist.clientsByName.keys())
        self.contactname = JTextField()
        self.buildpane()

    def buildpane(self):
        buttons = JPanel()
        buttons.add(JButton("OK", actionPerformed=self.add))
        buttons.add(JButton("Cancel", actionPerformed=self.cancel))

        acct = JPanel(GridLayout(1, 2), doublebuffered)
        acct.add(JLabel("Account"))
        acct.add(self.account)

        mainpane = self.mainframe.getContentPane()
        mainpane.setLayout(BoxLayout(mainpane, BoxLayout.Y_AXIS))
        mainpane.add(self.contactname)
        mainpane.add(acct)
        mainpane.add(buttons)
        self.mainframe.pack()
        self.mainframe.show()

    #action listeners
    def add(self, ae):
        acct = self.contactslist.clientsByName[self.account.getSelectedItem()]
        acct.addContact(self.contactname.getText())
        self.mainframe.dispose()

    def cancel(self, ae):
        self.mainframe.dispose()
Beispiel #11
0
class ConversationWindow(Conversation):
    """A GUI window of a conversation with a specific person"""
    def __init__(self, person, chatui):
        """ConversationWindow(basesupport.AbstractPerson:person)"""
        Conversation.__init__(self, person, chatui)
        self.mainframe = JFrame("Conversation with "+person.name)
        self.display = JTextArea(columns=100,
                                 rows=15,
                                 editable=0,
                                 lineWrap=1)
        self.typepad = JTextField()
        self.buildpane()
        self.lentext = 0

    def buildpane(self):
        buttons = JPanel(doublebuffered)
        buttons.add(JButton("Send", actionPerformed=self.send))
        buttons.add(JButton("Hide", actionPerformed=self.hidewindow))

        mainpane = self.mainframe.getContentPane()
        mainpane.setLayout(BoxLayout(mainpane, BoxLayout.Y_AXIS))
        mainpane.add(JScrollPane(self.display))
        self.typepad.actionPerformed = self.send
        mainpane.add(self.typepad)
        mainpane.add(buttons)

    def show(self):
        self.mainframe.pack()
        self.mainframe.show()

    def hide(self):
        self.mainframe.hide()

    def sendText(self, text):
        self.displayText("\n"+self.person.client.name+": "+text)
        Conversation.sendText(self, text)

    def showMessage(self, text, metadata=None):
        self.displayText("\n"+self.person.name+": "+text)

    def contactChangedNick(self, person, newnick):
        Conversation.contactChangedNick(self, person, newnick)
        self.mainframe.setTitle("Conversation with "+newnick)

    #GUI code
    def displayText(self, text):
        self.lentext = self.lentext + len(text)
        self.display.append(text)
        self.display.setCaretPosition(self.lentext)

    #actionlisteners
    def hidewindow(self, ae):
        self.hide()

    def send(self, ae):
        text = self.typepad.getText()
        self.typepad.setText("")
        if text != "" and text != None:
            self.sendText(text)
 def __init__(self):
     JFrame.__init__(self, 'MagicDraw Jython Console')
     # grab the current out and err so we can set them back later (for the main java
     # System.out/err, not the PythonInterpreter
     self.__outOriginal = System.out
     self.__errOriginal = System.err
     # use the printStream as it updates the textarea
     System.setOut(self.printStream)
     System.setErr(self.printStream)
     self.CreateComponents()
     self.setVisible(True) 
     self.requestFocus()
     self.inputField.requestFocus()
def readSVG(svgPath):
	#parser = XMLResourceDescriptor.getXMLParserClassName()
	#f = SAXSVGDocumentFactory(parser)
	#print(svgPath)
	#doc = f.createDocument(svgPath.toURI().toString())
	#print(doc)
	svgCanvas = JSVGCanvas()
	svgCanvas.setURI(svgPath.toURI().toString())
	f = JFrame('SVG image', size=(1000, 1000), locationRelativeTo=None)
	p = JPanel()
	p.add(svgCanvas)
	f.getContentPane().add(p)
	f.setVisible(True)
Beispiel #14
0
def start_ashdi():
    loadKeyLayout("data_2.0/ashdi_keylayout.xml")

    global frame
    frame = JFrame(FRAME_TITLE)
    frame.setContentPane(getContentPane())
    frame.windowClosing = lambda x: windowClosing()
    frame.pack()
    frame.setVisible(True)
    frame.addWindowFocusListener(GuiWindowFocusListener())
    start_android_waker()
    handleConnectedDevBtn(True)
    check_move_support()
class VacalcFrame(object):
    def __init__(self, employees, dateprovider):
        self._frame = JFrame("Vacation Calculator", defaultCloseOperation=JFrame.EXIT_ON_CLOSE)
        self._frame.setContentPane(self._create_ui(employees, dateprovider))
        self._frame.pack()

    def _create_ui(self, employees, dateprovider):
        panel = JPanel(layout=FlowLayout())
        self._overview = EmployeeOverview(employees, self)
        self._details = EmployeeDetails(employees, dateprovider)
        self._welcome = Welcome()
        panel.add(self._overview)
        panel.add(self._welcome)
        return panel

    def show(self):
        self._frame.setVisible(True)

    def employee_selected(self, employee):
        self._ensure_details_shown()
        self._details.show_employee(employee)

    def edit_new_employee(self):
        self._ensure_details_shown()
        self._details.edit_new_employee()

    def _ensure_details_shown(self):
        if self._welcome:
            self._frame.contentPane.remove(self._welcome)
            self._frame.contentPane.add(self._details)
            self._frame.pack()
            self._welcome = None
Beispiel #16
0
class positionDialog(JFrame):
    def __init__(self):
        self.frame = JFrame("CellCropper: Experiment details", size=(400,200))
        self.frame.setLocation(20,120)
        self.Panel = JPanel(GridLayout(4,2))
        self.frame.add(self.Panel)
        self.Panel.add(JLabel("Date:"))
        self.dateField = JTextField( str(date.today()), 8 )
        self.Panel.add(self.dateField)
        self.strainField = JTextField( "2926",4 )
        self.Panel.add(self.strainField)
        self.tempField = JTextField( "34",2 )
        self.Panel.add(self.tempField)
        self.ODField = JTextField( "0.5",3 )
        self.Panel.add(self.ODField)
        self.condField = JTextField( "0.5",3 )
        self.Panel.add(self.condField)

        self.OKButton = JButton("OK",actionPerformed=closeAndMakePos)
        self.Panel.add(self.OKButton)
        self.frame.pack()
        WindowManager.addWindow(self.frame)
        self.show()

    def show(self):
        self.frame.visible = True
    
    def close(self):
        return self.dateField.text, self.strainField.text, self.tempField.text, self.ODField.text, self.condField.text
        WindowManager.removeWindow(self.frame)
        self.frame.dispose()
class MainWindow(object):
    def __init__(self):
        self.frame = JFrame('Hello, Jython!',
                            defaultCloseOperation=JFrame.EXIT_ON_CLOSE,
                            size=(400, 600))
        bag_layout = GridBagLayout()
        self.frame.layout = bag_layout
        grid_constraints = GridBagConstraints()

        format_1_string_label = JLabel("Format 1 string:")
        grid_constraints.weightx = 0.1
        grid_constraints.weighty = 0.1
        grid_constraints.gridy = 0
        grid_constraints.fill = GridBagConstraints.NONE
        self._add_component(format_1_string_label, bag_layout, grid_constraints)

        self.input_textbox = JTextArea()
        grid_constraints.weightx = 1
        grid_constraints.weighty = 1
        grid_constraints.gridy = 1
        grid_constraints.fill = GridBagConstraints.BOTH
        input_scroll_pane = JScrollPane(self.input_textbox)
        input_scroll_pane.verticalScrollBarPolicy = ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS
        self._add_component(input_scroll_pane, bag_layout, grid_constraints)

        output_string_label = JLabel("Output:")
        grid_constraints.weightx = 0.1
        grid_constraints.weighty = 0.1
        grid_constraints.gridy = 2
        grid_constraints.fill = GridBagConstraints.NONE
        self._add_component(output_string_label, bag_layout, grid_constraints)

        self.output_textbox = JTextArea()
        grid_constraints.weightx = 1
        grid_constraints.weighty = 1
        grid_constraints.gridy = 3
        grid_constraints.fill = GridBagConstraints.BOTH
        self.output_textbox.editable = False
        output_scroll_pane = JScrollPane(self.output_textbox)
        output_scroll_pane.verticalScrollBarPolicy = ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS
        self._add_component(output_scroll_pane, bag_layout, grid_constraints)

    def _add_component(self, component, layout, constraint):
        layout.setConstraints(component, constraint)
        self.frame.add(component)

    def show(self):
        self.frame.visible = True
        listener = InputTextDocumentListener(self.input_textbox, self.output_textbox)
        self.input_textbox.document.addDocumentListener(listener)
Beispiel #18
0
class View:
    def __init__(self):
        self.stats=None
        self.frame=JFrame('Statistics',visible=True,layout=BorderLayout())

        self.graph=GraphPanel(self,componentResized=lambda event: self.graph.update())
        self.frame.add(self.graph)

        self.options=OptionsPanel(self)
        self.frame.add(self.options,BorderLayout.WEST)


        self.model_selection=ModelSelectionPanel(self)
        self.frame.add(self.model_selection,BorderLayout.NORTH)

        self.frame.add(RunPanel(self),BorderLayout.SOUTH)

        self.frame.size=(800,600)
    def selected_params(self):
        return self.options.parameters.get_selected()

    def file_changed(self,event):
        if event.stateChange==ItemEvent.SELECTED:
            self.select_model(event.item)



    def select_model(self,name):
        self.model_selection.files.selectedItem=name
        self.stats=stats.Stats(name)
        self.options.update()
        self.graph.update()
Beispiel #19
0
    def draw(self):

        try:
            UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
        except:
            pass

        self.images_dict = dict()
        self.canvas = Canvas(self.images_dict, None)
        self.canvas.addMouseListener(self)

        self.frame = JFrame("SimplePyzzle", visible = 1)
        self.frame.setMinimumSize(Dimension(300, 300))
        self.frame.setLocationRelativeTo(None)
        self.generate_button = JButton("Generate Puzzle")
        self.bottom_panel = JPanel()

        self.combo_box_list = [9, 16, 25, 36, 49]
        self.combo_box = JComboBox(self.combo_box_list)

        self.frame.contentPane.add(self.canvas, BorderLayout.CENTER)
        self.frame.contentPane.add(self.bottom_panel, BorderLayout.SOUTH)
        self.bottom_panel.add(self.generate_button, BorderLayout.EAST)
        self.bottom_panel.add(self.combo_box, BorderLayout.WEST)

        self.generate_button.actionPerformed = self.generate_board

        self.frame.setSize(500, 500)
        self.frame.defaultCloseOperation = JFrame.EXIT_ON_CLOSE;
        self.frame.pack()
Beispiel #20
0
   def __init__(self, filename, width=None, height=None): 
      """Create an image from a file, or an empty (black) image with specified dimensions."""
      
      # Since Python does not allow constructors with different signatures,
      # the trick is to reuse the first argument as a filename or a width.
      # If it is a string, we assume they want is to open a file.
      # If it is an int, we assume they want us to create a blank image.
      
      if type(filename) == type(""):  # is it a string?
         self.filename = filename        # treat is a filename
         self.image = BufferedImage(1, 1, BufferedImage.TYPE_INT_RGB)  # create a dummy image
         self.read(filename)             # and read external image into ti
                  
      elif type(filename) == type(1): # is it a int?
      
         # create blank image with specified dimensions
         self.filename = "Untitled"
         self.width = filename       # holds image width (shift arguments)
         self.height = width         # holds image height
         self.image = BufferedImage(self.width, self.height, BufferedImage.TYPE_INT_RGB)  # holds image buffer (pixels)
      else:
         raise  TypeError("Image(): first argument must a filename (string) or an blank image width (int).")
         
      # display image
      self.display = JFrame()      # create frame window to hold image
      icon = ImageIcon(self.image) # wrap image appropriately for displaying in a frame
      container = JLabel(icon)         
      self.display.setContentPane(container)  # and place it

      self.display.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE)
      self.display.setTitle(self.filename)
      self.display.setResizable(False)
      self.display.pack()
      self.display.setVisible(True)
    def __init__(self, cell, mF, title="Results"): # add mF?
        # Call constructor of superclass
        TextPanel.__init__(self)
        # pass menue for setting save active/inactive
        self.cell = cell
        self.mF = mF
        # Create a window to show the content in
        self.window = JFrame()
        self.window.add(self)
        self.window.setTitle(title)
        # Add event listeners for keyboard and mouse responsiveness
        
        self.addKeyListener(ListenToKey())
        self.addMouseListener(ListenToMouse())
        
        # TODO: unpacking info out of cell object should be done in cell object itself and accessible e. g. via getData()
        self.imp = self.openImp(self.cell.getMeasTifPath())
        csvFile = open(self.cell.getCsvPath())        
        lines = csvFile.readlines()
        heads = lines.pop(0)
        self.setColumnHeadings("Frame\tDistance\tAnaphase")
        self.XYZtable = []
        for line in lines:      # load file lines in textPanel.
            frame, timepoint, dist, ch0x, ch0y, ch0z, ch0vol, ch1x, ch1y, ch1z, ch1vol = line.split(",")
            self.append(frame + "\t" + dist + "\t" )
            self.XYZtable.append((ch0x, ch0y, ch0z, ch0vol, ch1x, ch1y, ch1z, ch1vol))
        self.setSelection(0,0) # int startline, int endline
        self.changeFrame()
        self.mF.setSaveInactive()
        self.requestFocus()

        self.window.setSize(Dimension(220, 600))
        x = int(self.imp.getWindow().getLocation().getX()) + int(self.imp.getWindow().getWidth()) + 10
        self.window.setLocation(x, int(self.imp.getWindow().getLocation().getY()) )
        self.window.show()
Beispiel #22
0
    def __init__(self, p):
        self.cellCounter = 1
        self.olay = Overlay()
        self.position = p
        print p.getRoiPath()
        if p.getRoiPath() != None:         # check if there is an existing overlay file and load it!
            p.loadRois()

        self.frame = JFrame("CellCropper", size=(200,200))
        self.frame.setLocation(20,120)
        self.Panel = JPanel(GridLayout(0,1))
        self.frame.add(self.Panel)
        #self.nameField = JTextField("p" + "_c",15)
        self.nameField = JTextField("p" + str(self.position.getID()) + "_c",15)
        self.Panel.add(self.nameField)
        self.cutoutButton = JButton("Cut out cell",actionPerformed=cut)
        self.Panel.add(self.cutoutButton)
        self.delOlButton = JButton("Delete Overlay",actionPerformed=delOverlay)
        self.Panel.add(self.delOlButton)
        self.saveOlButton = JButton("Save Overlay",actionPerformed=saveOverlay)
        self.Panel.add(self.saveOlButton) 
        self.quitButton = JButton("Quit script",actionPerformed=quit)
        self.Panel.add(self.quitButton)
        self.frame.pack()
        WindowManager.addWindow(self.frame)
        self.show()
Beispiel #23
0
 def __init__(self):
     self.frame = JFrame("Python Window")
     self.historyList = JList(DefaultListModel())
     self.historyList.cellRenderer = MyListCellRenderer()
     #self.historyPanel.layout = BoxLayout(
     #    self.historyPanel,
     #    BoxLayout.Y_AXIS
     #)
     scrollpane = JScrollPane()
     #    JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
     #    JScrollPane.HORIZONTAL_SCROLLBAR_NEVER
     #)
     # scrollpane.preferredSize = 400, 800
     inputPanel = JPanel()
     inputPanel.layout = GridLayout(1, 1)
     self.input = JTextArea("")
     self.input.border = BorderFactory.createEmptyBorder(5, 5, 5, 5)
     self.input.tabSize = 4
     self.input.font = Font("Monospaced", Font.PLAIN, 12)
     #self.input.preferredSize = 500, 200 
     self.input.addKeyListener(self)
     #self.button = JButton('Run', actionPerformed=self.run)
     inputPanel.add(self.input)
     #inputPanel.add(self.button)
     scrollpane.viewport.view = self.historyList
     self.frame.add(scrollpane, BorderLayout.CENTER)
     self.frame.add(inputPanel, BorderLayout.PAGE_END)
     self.frame.size = 500, 600
     self.frame.visible = False
    def __init__(self, title, w, h, backgroundColor=white):
        assert w > 0, "GraphicsWindow width must be greater than zero"
        assert h > 0, "GraphicsWindow height must be greater than zero"

        self._SHAPELIST_MAX_LENGTH = 200

        self.objs = []  # List of GraphicsObjects
        self.backgroundColor = backgroundColor

        self.frame = JFrame(
            title, defaultCloseOperation=JFrame.EXIT_ON_CLOSE,
            size=(w, h))

        self.frame.setLocationRelativeTo(None)
        self.frame.contentPane = Canvas(self, self.objs, self.backgroundColor)
        self.frame.contentPane.setPreferredSize(Dimension(w, h))

        self.frame.addMouseListener(self)
        self.frame.addMouseMotionListener(self)
        self.frame.addKeyListener(self)

        # MouseEvent attributes
        self.mouseEventType = 0
        self.mouseX = 0
        self.mouseY = 0

        # Mouse callbacks
        self.onMouseClicked = None
        self.onMouseDragged = None
        self.onMouseMoved = None
        self.onMousePressed = None
        self.onMouseReleased = None
        self.onMouseDragged = None
        self.onMouseExited = None
        self.onMouseEntered = None

        # KeyEvent booleans keyPressed, keyTyped
        self.keyEventType = 0
        self.keyP = False
        self.keyT = False

        # Key callbacks
        self.onKeyPressed = None
        self.onKeyReleased = None
        self.onKeyTyped = None

        # Key values
        self.lastKeyChar = None
        self.lastKeyCode = None

        self.charsPressed = Set()

        # Event queue
        self.eventQueue = Queue()

        self.mainRunning = False

        # not needed, user_draw is /called directly from onDraw
        self.onDraw = None
def show_plot_in_frame(mainPanel):
    """
    embeds panel containing plots in a closable frame
    clears the panel background to white 
    """
    fr=JFrame()
    fr.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE)
    fr.getContentPane().add(mainPanel)
    fr.setSize(1100,850);
    mainPanel.setSize(1100,850);
    mainPanel.setBackground(Color.WHITE);
    fr.show();
    return fr
Beispiel #26
0
    def __init__(self):
        self.frame = JFrame("Display Image")

        btn = JButton("Switch",actionPerformed=self.switchPic)
        #self.frame.getContentPane().add(btn)
        self.switchPic('/home/jack/Desktop/mgarvin.jpg')
        self.frame.setSize(500,500)
        self.frame.setVisible(True)
Beispiel #27
0
class myAnimFrame:
  """
  Supporting class for animations.
  """
  def desty(self, event):
    self.display.destroy()
    self.frame.dispose()

  def __init__(self, display, widget, width, height, title):
    from javax.swing import JFrame, JPanel
    from java.awt import BorderLayout, FlowLayout
    self.display = display
    self.panel = JPanel(BorderLayout())
    self.panel2 = JPanel(FlowLayout())
    self.panel2.add(widget)
    self.panel.add("North", self.panel2)
    self.panel.add("Center",self.display.getComponent())

    self.frame = JFrame(title, windowClosing=self.desty)
    self.pane = self.frame.getContentPane()
    self.pane.add(self.panel)

    self.frame.setSize(width,height)
    self.frame.pack()
    self.frame.show()
Beispiel #28
0
def createFrame():
    global isDominant
    manager = doAction()
    if isTemporal:
        frame = JFrame("LosiTemp - LOoking for Selection In TEMPoral datasets")
    elif isDominant:
        frame = JFrame("Mcheza - Dominant Selection Workbench")
    else:
        frame = JFrame("LOSITAN - Selection Workbench")
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE)
    doPrettyType(frame, manager)
    frame.setVisible(1)
    frame.setResizable(0)
    return frame
Beispiel #29
0
 def __init__(self):
     self.frame = JFrame("StopWatch", defaultCloseOperation=JFrame.EXIT_ON_CLOSE)
     self.start = JButton("Start", actionPerformed=self.start)
     self.frame.add(self.start, BorderLayout.WEST)
     self.stop = JButton("Stop", actionPerformed=self.stop)
     self.frame.add(self.stop, BorderLayout.EAST)
     self.label = JLabel(" " * 45)
     self.frame.add(self.label, BorderLayout.SOUTH)
     self.frame.pack()
 def __init__(self):
     self.frame = JFrame('Phone status twitter')
     self.frame.defaultCloseOperation = WindowConstants.EXIT_ON_CLOSE
     self.asteriskLoginPanel = gui.AsteriskLoginPanel(buttonAction=self.loginToAsterisk)
     self.asteriskLoginPanel.render()
     self.frame.add(self.asteriskLoginPanel)
     self.asteriskLoginPanel.getRootPane().setDefaultButton(self.asteriskLoginPanel.login)
     self.frame.pack()
     self.frame.visible = True
Beispiel #31
0
def addFontResizing():
  global frames
  containers = [frame for frame in JFrame.getFrames()
                if frame.getTitle() == "File paths" and frame.isVisible()]
  frames = containers[:]
  from java.awt import Container
  while len(containers) > 0:
    for component in containers.pop(0).getComponents():
      if isinstance(component, JTable):
        tables.append(component)
        components.append(component)
        components.append(component.getTableHeader())
      elif isinstance(component, Container):
        containers.append(component)
      components.append(component)
  #
  for component in components:
    #print type(component).getSimpleName()
    component.addKeyListener(FontSizeAdjuster())
    def run(self):
        frame = JFrame('SecConfigReport_05',
                       size=(300, 300),
                       locationRelativeTo=None,
                       defaultCloseOperation=JFrame.EXIT_ON_CLOSE)

        data = []
        text = AdminTask.generateSecConfigReport()
        for line in text.splitlines()[2:]:
            data.append([info.strip() for info in line[:-2].split(';')])

        table = JTable(reportTableModel(
            data,
            ';;;'.split(';'),
        ),
                       selectionMode=ListSelectionModel.SINGLE_SELECTION)
        table.setDefaultRenderer(String, reportRenderer())
        frame.add(JScrollPane(table))

        frame.pack()
        frame.setVisible(1)
Beispiel #33
0
 def run(self):
     frame = JFrame('Table6c',
                    size=(300, 150),
                    locationRelativeTo=None,
                    defaultCloseOperation=JFrame.EXIT_ON_CLOSE)
     headings = 'T/F,Date,Integer,Float,Double'.split(',')
     model = myTM(self.data, headings)
     table = JTable(model,
                    selectionMode=ListSelectionModel.SINGLE_SELECTION)
     table.getColumnModel().getColumn(model.getColumnCount() -
                                      1  # i.e., last column
                                      ).setCellRenderer(myRenderer())
     frame.add(JScrollPane(table))
     frame.setVisible(1)
Beispiel #34
0
 def run( self ) :
     frame = JFrame(
         'WaitCursor1',
         size = ( 150, 100 ),
         locationRelativeTo = None,
         defaultCloseOperation = JFrame.EXIT_ON_CLOSE
     )
     frame.add(
         JButton(
             'Wait',
             actionPerformed = self.wait
         )
     )
     frame.setVisible( 1 )
Beispiel #35
0
    def run( self ) :
        frame = JFrame(
            'SpinEdit3',
            size = ( 200, 106 ),
#           size = ( 200, 116 ),
            locationRelativeTo = None,
            defaultCloseOperation = JFrame.EXIT_ON_CLOSE
        )
        table = JTable( tm(), rowHeight = 20 )
#       table = JTable( tm(), rowHeight = 25 )
        table.setDefaultRenderer( JSpinner, sRenderer() )
        table.setDefaultEditor( JSpinner, editor() )
        frame.add( JScrollPane( table ) )
        frame.setVisible( 1 )
Beispiel #36
0
def create_gui(): 
	global dropdown, current_file
	frame = JFrame('',
            defaultCloseOperation = JFrame.DISPOSE_ON_CLOSE,
            size = (400, 150));
	frame.setBounds(350,350,400,150);

	container_panel = JPanel(GridBagLayout());	
	c = GridBagConstraints();
	
	dropdown = JComboBox(list(img_paths.keys()));
	c.fill = GridBagConstraints.HORIZONTAL;
	c.gridx = 0;
	c.gridy = 0;
	c.weightx = 0.5;
	c.gridwidth = 3;
	container_panel.add(dropdown, c);

	add_file_button = JButton('<html>Add Image/File</html>', actionPerformed=select_file);
	c.fill = GridBagConstraints.HORIZONTAL;
	c.gridx = 3;
	c.gridy = 0;
	c.weightx = 0.5;
	c.gridwidth = 1;
	container_panel.add(add_file_button, c);
	
	process_file_button = JButton('<html>Process Selected Image</html>', actionPerformed=process_current_img);
	c.fill = GridBagConstraints.HORIZONTAL;
	c.gridx = 0;
	c.gridy = 1;
	c.weightx = 0.5;
	c.gridwidth = 2;
	container_panel.add(process_file_button, c);
	
	process_all_button = JButton('<html>Process Entire Stack</html>', actionPerformed=process_stack);
	c.fill = GridBagConstraints.HORIZONTAL;
	c.gridx = 2;
	c.gridy = 1;
	c.weightx = 0.5;
	c.gridwidth = 2;
	container_panel.add(process_all_button, c);
	current_file = dropdown.getSelectedItem();
	
	frame.add(container_panel);
	frame.visible = True;
Beispiel #37
0
 def run(self):
     screenSize = Toolkit.getDefaultToolkit().getScreenSize()
     w = screenSize.width >> 1  # 1/2 screen width
     h = screenSize.height >> 1  # 1/2 screen height
     x = (screenSize.width - w) >> 1
     y = (screenSize.height - h) >> 1
     frame = JFrame(
         'iFrameEvents1',
         bounds=(x, y, w, h),  # location & size
         defaultCloseOperation=JFrame.EXIT_ON_CLOSE)
     desktop = JDesktopPane()
     desktop.add(eventLogger(), 0, 0)
     frame.setContentPane(desktop)
     frame.setVisible(1)
Beispiel #38
0
    def run(self):
        self.frame = frame = JFrame('SecConfigReport_11',
                                    size=(500, 300),
                                    locationRelativeTo=None,
                                    componentResized=self.frameResized,
                                    defaultCloseOperation=JFrame.EXIT_ON_CLOSE)

        #-----------------------------------------------------------------------
        # Add our menu bar to the frame
        #-----------------------------------------------------------------------
        frame.setJMenuBar(self.MenuBar())

        data = []
        text = AdminTask.generateSecConfigReport()
        #-----------------------------------------------------------------------
        # The RegExp was added to replace multiple blanks with a single one
        #-----------------------------------------------------------------------
        for line in text.splitlines()[2:]:
            data.append([
                re.sub('  +', ' ', info.strip())
                for info in line[:-2].split(';')
            ])

        self.table = table = JTable(
            reportTableModel(
                data,
                ';;;'.split(';'),
            ),
            autoCreateRowSorter=1,
            selectionMode=ListSelectionModel.SINGLE_SELECTION)

        for key in 'UP,DOWN,PAGE_UP,PAGE_DOWN,ctrl END'.split(','):
            upDownAction(table, key)

        table.setDefaultRenderer(String, reportRenderer())
        self.setColumnWidths(table)
        scroller = JScrollPane(table)
        frame.add(scroller)

        frame.pack()
        frame.setVisible(1)
        frame.setMinimumSize(frame.getSize())
Beispiel #39
0
    def run( self ) :
        self.frame = frame = JFrame(
            'Frame3',
            size = ( 200, 200 ),
            layout = None,
            locationRelativeTo = None,
            defaultCloseOperation = JFrame.EXIT_ON_CLOSE
        )
        frame.addComponentListener( listener( self ) )
        self.width  = JTextField(
            4, actionPerformed = self.changeWidth
        )
        self.height = JTextField(
            4, actionPerformed = self.changeHeight
        )
        self.x      = JTextField(
            4, actionPerformed = self.changeX
        )
        self.y      = JTextField(
            4, actionPerformed = self.changeY
        )
        items = [
            [ JLabel( 'Width:' ) , 11,  7 ],
            [ self.width         , 50,  5 ],
            [ JLabel( 'Height:' ),  7, 31 ],
            [ self.height        , 50, 30 ],
            [ JLabel( 'X:' )     , 35, 55 ],
            [ self.x             , 50, 53 ],
            [ JLabel( 'Y:' )     , 35, 79 ],
            [ self.y             , 50, 78 ]
        ]
        for item in items :
            thing = frame.add( item[ 0 ] )
            size  = thing.getPreferredSize()
            thing.setBounds(
                item[ 1 ],
                item[ 2 ],
                size.width,
                size.height
            )

        frame.setVisible( 1 )
Beispiel #40
0
    def run(self):
        self.frame = frame = JFrame('Frame1',
                                    size=(200, 200),
                                    layout=None,
                                    locationRelativeTo=None,
                                    defaultCloseOperation=JFrame.EXIT_ON_CLOSE)
        frame.addComponentListener(listener(self))
        insets = frame.getInsets()
        #       print '\n',insets
        self.width = JTextField(4)
        self.height = JTextField(4)
        items = [[JLabel('Width:'), 7, 7], [self.width, 50, 5],
                 [JLabel('Height:'), 7, 31], [self.height, 50, 30]]
        for item in items:
            thing = frame.add(item[0])
            size = thing.getPreferredSize()
            thing.setBounds(insets.left + item[1], insets.top + item[2],
                            size.width, size.height)

        frame.setVisible(1)
Beispiel #41
0
    def run( self ) :
        frame = JFrame(
            'Toggle Button',
            layout = FlowLayout(),
            size   = ( 275, 85 ),
            defaultCloseOperation = JFrame.EXIT_ON_CLOSE
        )

        button  = JToggleButton(            # Make a toggle button
            'Off' ,                         # Initial button text
            itemStateChanged = self.toggle  # Event handler
        )

        frame.add( button  )
        frame.setVisible( 1 )
Beispiel #42
0
    def run(self):
        frame = JFrame('Menu2',
                       size=(200, 125),
                       defaultCloseOperation=JFrame.EXIT_ON_CLOSE)
        menuBar = JMenuBar(background=Color.blue, foreground=Color.white)
        fileMenu = JMenu('File')
        fileMenu.add(JMenuItem('Exit'))
        menuBar.add(fileMenu)

        helpMenu = JMenu('Help')
        helpMenu.add(JMenuItem('About'))
        menuBar.add(helpMenu)

        frame.setJMenuBar(menuBar)
        frame.setVisible(1)
Beispiel #43
0
def renderHistogram(values,
                    n_bins,
                    min_max=None,
                    title="Histogram",
                    color=Color.red,
                    show=True,
                    setThemeFn=setTheme):
    """ values: a list or array of numeric values.
      n_bins: the number of bins to use.
      min_max: defaults to None, a tuple with the minimum and maximum value.
      title: defaults to "Histogram", must be not None.
      show: defaults to True, showing the histogram in a new window.
      setThemeFn: defaults to setTheme, can be None or another function that takes a chart
               as argument and sets rendering colors etc.
      Returns a tuple of the JFreeChart instance and the window JFrame, if shown.
  """
    hd = HistogramDataset()
    hd.setType(HistogramType.RELATIVE_FREQUENCY)
    print min_max
    if min_max:
        hd.addSeries(title, values, n_bins, min_max[0], min_max[1])
    else:
        hd.addSeries(title, values, n_bins)
    chart = ChartFactory.createHistogram(title, "", "", hd,
                                         PlotOrientation.VERTICAL, False,
                                         False, False)
    # Adjust series color
    chart.getXYPlot().getRendererForDataset(hd).setSeriesPaint(0, color)
    #
    if setThemeFn:
        setThemeFn(chart)
    frame = None
    if show:
        frame = JFrame(title)
        frame.getContentPane().add(ChartPanel(chart))
        frame.pack()
        frame.setVisible(True)
    return chart, frame
Beispiel #44
0
 def setPayload(self, event):
     proto = 0
     httpRequestResponse = self.context.getSelectedMessages()
     for currentRequest in httpRequestResponse:
         parentFrame = JFrame()
         cmd = JOptionPane.showInputDialog(parentFrame, "Insert the RCE you want to execute on remote target")
         requestInfo = self._helpers.analyzeRequest(currentRequest)
         bodyBytes = currentRequest.getRequest()[requestInfo.getBodyOffset():]
         bodyStr = self._helpers.bytesToString(bodyBytes)
         headers = requestInfo.getHeaders()
         newHeaders = list(headers)
         for header in newHeaders:
             if 'content-type' in header.lower():
                 newHeaders.remove(header)
         newHeaders.append('Content-Type: {0}'.format(PAYLOAD.format(cmd)))
         newMessage = self._helpers.buildHttpMessage(newHeaders, bodyStr)
         host = currentRequest.getHttpService().getHost()
         port = currentRequest.getHttpService().getPort()
         if currentRequest.getHttpService().getProtocol() == 'https':
             proto = 1
         self._callbacks.sendToRepeater(host, port, proto, newMessage, None)
Beispiel #45
0
    def output(self, value):
        #url = "https://dict.leo.org/englisch-deutsch/dog"
        #import urllib.request
        #with urllib.request.urlopen(url) as response:
        #html = response.read()
        #with open("leoausgabe.txt","w") as f:
        #f.write(str(html))
        t = ''

        frame = JFrame(
            'Lektion erstellen',
            defaultCloseOperation=JFrame.EXIT_ON_CLOSE,
            size=(500, 500),
        )

        def change_text(event):
            text = feld.getText()
            name = feld2.getText() + ".csv"
            with open(name, "w") as f:
                f.write(text)
                #print(name + " gespeichert")
            #print(text)
            t = text
            self.send(t)
            #return(t)

        button = JButton('Lektion speichern!',
                         actionPerformed=change_text,
                         size=(10, 20))
        button.setBounds(20, 40, 20, 40)
        pnl = JPanel()
        pnl.setLayout(BoxLayout(pnl, BoxLayout.Y_AXIS))
        feld = JTextArea()
        feld.editable = True

        feld.setText("Deutsch,Englisch\n")
        feld2 = JTextField()
        feld2.setText("Ersetzen durch Namen der Lektion")
        pnl.add(feld2)
        pnl.add(feld)
        pnl.add(button)
        frame.add(pnl)
        frame.setVisible(True)

        #change_text(value)
        print(t)

        print "Lektion erstellt"
Beispiel #46
0
class ActionMenu:
    def __init__(self):
        self.titleBase = 'HCR2 Monkey'
        self.frame = JFrame(self.titleBase,
                            defaultCloseOperation=JFrame.EXIT_ON_CLOSE,
                            size=(300, 250))
        self.inputMap = self.frame.getRootPane().getInputMap(
            JComponent.WHEN_IN_FOCUSED_WINDOW)
        self.actionMap = self.frame.getRootPane().getActionMap()
        self.actionLabels = {}
        self.actionThread = None

        self.defaultBackground = self.frame.getBackground()
        self.frame.getContentPane().setLayout(
            BoxLayout(self.frame.getContentPane(), BoxLayout.Y_AXIS))

        self.addAction("ESCAPE", "Abort current action", lambda: None)

    def addAction(self, key, desc, cb):
        if " " in key:
            strokeString = key
        else:
            strokeString = "pressed " + key

        stroke = KeyStroke.getKeyStroke(strokeString)
        if stroke == None:
            raise ValueError("Invalid key: " + str(key))
        self.inputMap.put(stroke, key)
        self.actionMap.put(key, MenuAction(cb, key, desc, self))
        self.actionLabels[key] = JLabel(key + ": " + desc)
        self.actionLabels[key].setOpaque(True)
        self.frame.getContentPane().add(self.actionLabels[key])

    def run(self):
        log("Starting menu")
        self.frame.visible = True
        while True:
            sleep(300)
Beispiel #47
0
 def run(self):
     self.frame = frame = JFrame('DynamicComboBox',
                                 size=(310, 137),
                                 layout=BorderLayout(),
                                 defaultCloseOperation=JFrame.EXIT_ON_CLOSE)
     panel = JPanel()
     panel.add(JLabel('Pick one:'))
     self.choices = 'The,quick,brown,fox,jumped'.split(',')
     self.choices.extend('over,the,lazy,spam'.split(','))
     self.ComboBox = ComboBox = JComboBox(self.choices, editable=1)
     ComboBox.addActionListener(self)
     panel.add(ComboBox)
     frame.add(panel, BorderLayout.NORTH)
     panel = JPanel()
     self.RemoveButton = JButton('Remove', actionPerformed=self.remove)
     panel.add(self.RemoveButton)
     frame.add(panel, BorderLayout.CENTER)
     panel = JPanel(alignmentX=Component.CENTER_ALIGNMENT)
     self.msg = panel.add(JLabel('Make a selection'))
     frame.add(panel, BorderLayout.SOUTH)
     frame.setVisible(1)
Beispiel #48
0
 def run( self ) :
     frame = JFrame(
         'Tree4',
         size = ( 320, 200 ),
         layout = BorderLayout(),
         defaultCloseOperation = JFrame.EXIT_ON_CLOSE
     )
     tree = self.cellTree()
     tree.getSelectionModel().setSelectionMode(
         TreeSelectionModel.SINGLE_TREE_SELECTION
     )
     frame.add( JScrollPane( tree ), BorderLayout.CENTER )
     panel = JPanel()
     panel.add( JLabel( 'Selected:' ) )
     self.msg = panel.add(
         JTextField(
             '<none>',         # Initial value
             20,               # Field width (columns)
             editable = 0      # Disable editing
         )
     )
     frame.add( panel, BorderLayout.SOUTH )
     frame.setVisible( 1 )
    def run( self ) :
        frame = JFrame(
            'SecConfigReport_01',
            size = ( 300, 300 ),
            locationRelativeTo = None,
            defaultCloseOperation = JFrame.EXIT_ON_CLOSE
        )

        data = []
        text = AdminTask.generateSecConfigReport()
        for line in text.splitlines()[ 2: ] :
            data.append(
                [ info.strip() for info in line.split( ';' ) ]
            )

        frame.add(
            JScrollPane(
                JTable( data, ';;;;'.split( ';' ) )
            )
        )

        frame.pack()
        frame.setVisible( 1 )
Beispiel #50
0
    def run(self):
        frame = JFrame('List5',
                       size=(200, 220),
                       layout=GridLayout(1, 2),
                       defaultCloseOperation=JFrame.EXIT_ON_CLOSE)

        panel = JPanel(layout=GridLayout(0, 1))
        panel.add(self.button('Remove'))
        panel.add(self.button('First'))
        panel.add(self.button('Last'))
        panel.add(self.button('Before'))
        panel.add(self.button('After'))
        self.text = panel.add(JTextField(10))
        frame.add(panel)

        data = ('Now is the time for all good spam ' +
                'to come to the aid of their eggs').split(' ')
        self.info = JList(data,
                          valueChanged=self.selection,
                          selectionMode=ListSelectionModel.SINGLE_SELECTION)
        #       self.info = JList( data )
        frame.add(JScrollPane(self.info, preferredSize=(200, 100)))
        frame.setVisible(1)
    def run( self ) :
        frame = JFrame(
            'ProgressMonitor',
            size = ( 280, 125 ),
            locationRelativeTo = None,
            defaultCloseOperation = JFrame.EXIT_ON_CLOSE
        )
        frame.getContentPane().setBorder(
            BorderFactory.createEmptyBorder( 20, 20, 20, 20 )
        )

        panel = JPanel()
        self.button = panel.add(
            JButton(
                'Start',
                actionPerformed = self.start
            )
        )
        frame.add(
            panel,
            BorderLayout.NORTH
        )
        frame.setVisible( 1 )
 def run( self ) :
     self.frame = frame = JFrame(
         'MessageDialogDemo',
         locationRelativeTo = None,
         defaultCloseOperation = JFrame.EXIT_ON_CLOSE
     )
     frame.add(
         JButton(
             'Minimum',
             actionPerformed = self.one
         ),
         BorderLayout.NORTH
     )
     frame.add(
         JButton(
             'Full',
             actionPerformed = self.two
         ),
         BorderLayout.SOUTH
     )
     frame.pack()
     frame.setVisible( 1 )
Beispiel #53
0
 def run( self ) :
     frame = JFrame(
         'Table4',
         size = ( 300, 200 ),
         locationRelativeTo = None,
         defaultCloseOperation = JFrame.EXIT_ON_CLOSE
     )
     headings = 'Date,size,Location'.split( ',' )
     frame.add(
         JScrollPane(
             JTable(
                 myTM( self.data, headings ),
                 selectionMode = ListSelectionModel.SINGLE_SELECTION
             )
         )
     )
     frame.setVisible( 1 )
Beispiel #54
0
def openDesktop(
    screen=0,
    handle=None,
    title=None,
    width=None,
    height=None,
    x=0,
    y=0,
    windows=None,
):
    """Creates an additional Desktop in a new frame.

    Args:
        screen (int): The screen index of which screen to place the new
            frame on. If omitted, screen 0 will be used.
        handle (str): A name for the desktop. If omitted, the screen
            index will be used.
        title (str): The title for the new frame. If omitted, the index
            handle will be used. If the handle and title are omitted,
            the screen index will be used.
        width (int): The width for the new Desktop's frame. If omitted,
            frame will become maximized on the specified monitor.
        height (int): The width for the new desktop's frame. If omitted,
            frame will become maximized on the specified monitor.
        x (int): The X coordinate for the new desktop's frame. Only used
            if both width and height are specified. If omitted, defaults
            to 0.
        y (int): The Y coordinate for the new desktop's frame. Only used
            if both width and height are specified. If omitted, defaults
            to 0.
        windows (list[str]): A list of window paths to open in the new
            Desktop frame.

    Returns:
        JFrame: A reference to the new Desktop frame.
    """
    print(screen, handle, title, width, height, x, y, windows)
    return JFrame()
Beispiel #55
0
    def run(self):

        #-----------------------------------------------------------------------
        # Starting width, height & location of the application frame
        #-----------------------------------------------------------------------
        screenSize = Toolkit.getDefaultToolkit().getScreenSize()
        w = screenSize.width >> 1  # Use 1/2 screen width
        h = screenSize.height >> 1  # and 1/2 screen height
        x = (screenSize.width - w) >> 1  # Top left corner of frame
        y = (screenSize.height - h) >> 1

        #-----------------------------------------------------------------------
        # Center the application frame in the window
        #-----------------------------------------------------------------------
        frame = self.frame = JFrame('WASports_08',
                                    bounds=(x, y, w, h),
                                    defaultCloseOperation=JFrame.EXIT_ON_CLOSE)

        #-----------------------------------------------------------------------
        # Add our menu bar to the frame, keeping a reference to the object
        #-----------------------------------------------------------------------
        frame.setJMenuBar(self.MenuBar())

        #-----------------------------------------------------------------------
        # Internal frames require us to use a JDesktopPane()
        #-----------------------------------------------------------------------
        desktop = JDesktopPane()

        cellName = AdminConfig.showAttribute(AdminConfig.list('Cell'), 'name')
        #-----------------------------------------------------------------------
        # Create our initial internal frame, and add it to the desktop
        #-----------------------------------------------------------------------
        internal = InternalFrame(cellName, Dimension(w >> 1, h >> 1),
                                 Point(5, 5), self.cellData)
        desktop.add(internal)

        frame.setContentPane(desktop)
        frame.setVisible(1)
Beispiel #56
0
 def generateScript(event):
   script = template % (str(datetime.now()),
                        filter(lambda path: path.endswith("IsoView-GCaMP"), sys.path)[-1],
                        srcDir,
                        tgtDir,
                        kernel_path,
                        ", ".join(imap(str, calibration)),
                        asString(preCropAffines[0]),
                        asString(preCropAffines[1]),
                        asString(preCropAffines[2]),
                        asString(preCropAffines[3]),
                        params["CM_0_1_n_iterations"],
                        params["CM_2_3_n_iterations"],
                        ", ".join(imap(str, ROI[0])),
                        ", ".join(imap(str, ROI[1])),
                        asString(postCropAffines[1]),
                        asString(postCropAffines[2]),
                        asString(postCropAffines[3]),
                        params["First time point"],
                        params["Last time point"])
   tab = None
   for frame in JFrame.getFrames():
     if str(frame).startswith("org.scijava.ui.swing.script.TextEditor["):
       try:
         tab = frame.newTab(script, "python")
         break
       except:
         print sys.exc_info()
   if not tab:
     try:
       now = datetime.now()
       with open(os.path.join(System.getProperty("java.io.tmpdir"),
                              "script-%i-%i-%i_%i:%i.py" % (now.year, now.month, now.day,
                                                            now.hour, now.minute)), 'w') as f:
         f.write(script)
     except:
       print sys.exc_info()
       print script
    def run( self ) :
        self.frame = frame = JFrame(
            'consoleTimeout_07',
            size = ( 428, 474 ),
            locationRelativeTo = None,
            defaultCloseOperation = JFrame.EXIT_ON_CLOSE
        )

        #-----------------------------------------------------------------------
        # Add the menu bar to the frame
        #-----------------------------------------------------------------------
        frame.setJMenuBar( self.MenuBar() )

        #-----------------------------------------------------------------------
        # Internal frames must be added to a desktop pane
        #-----------------------------------------------------------------------
        desktop = JDesktopPane()

        #-----------------------------------------------------------------------
        # Here is where we have to decide what needs to be displayed.
        #-----------------------------------------------------------------------
        if globals().has_key( 'AdminConfig' ) :
            self.timeout = self.initialTimeout()
            self.inner = TextField( self )       # JTextField only
            desktop.add( self.inner )
            desktop.add( TextandButton( self ) ) # JTextField & JButton
            desktop.add( RadioButtons( self ) )  # JRadioButton & JTextField
        else :
            self.inner = self.noWSAS()           # WebSphere not found
            desktop.add( self.inner )

        #-----------------------------------------------------------------------
        # Next, we add the desktop to the application frame; make the application
        # frame visible, and request the focus on one of the inner frames
        #-----------------------------------------------------------------------
        frame.add( desktop )
        frame.setVisible( 1 )
        self.inner.setSelected( 1 )
Beispiel #58
0
 def generateScript(event):
     script = template % (
         str(datetime.now()),
         filter(lambda path: path.endswith("IsoView-GCaMP"), sys.path)[-1],
         srcDir, tgtDir, kernel_path, ", ".join(imap(str, calibration)),
         "".join("\n    %i: [%s]," % (i, asString(aff))
                 for i, aff in enumerate(preCropAffines)),
         params.get("CM_0_1_n_iterations",
                    1), "\"CM_2_3_n_iterations\": %i" %
         params.get("CM_2_3_n_iterations", 1)
         if 4 == len(preCropAffines) else "", ", ".join(imap(
             str, ROI[0])), ", ".join(imap(str, ROI[1])), "".join(
                 "\n    [%s]," % asString(postCropAffines[i])
                 for i in xrange(1, len(postCropAffines))),
         params["First time point"], params["Last time point"])
     tab = None
     for frame in JFrame.getFrames():
         if str(frame).startswith(
                 "org.scijava.ui.swing.script.TextEditor["):
             try:
                 tab = frame.newTab(script, "python")
                 break
             except:
                 print sys.exc_info()
     if not tab:
         try:
             now = datetime.now()
             path = os.path.join(
                 System.getProperty("java.io.tmpdir"),
                 "script-%i-%i-%i_%i:%i.py" %
                 (now.year, now.month, now.day, now.hour, now.minute))
             with open(path, 'w') as f:
                 f.write(script)
                 print "Wrote script to " + path
         except:
             print sys.exc_info()
             print script
Beispiel #59
0
    def run(self):
        frame = JFrame('Menu3',
                       size=(200, 125),
                       defaultCloseOperation=JFrame.EXIT_ON_CLOSE)
        menuBar = JMenuBar(background=Color.blue)
        #       print '\nmenuBar size before:', menuBar.getPreferredSize()

        fileMenu = JMenu('File', foreground=Color.white)
        fileMenu.add(JMenuItem('Exit'))
        menuBar.add(fileMenu)
        #       print 'menuBar size  after:', menuBar.getPreferredSize()

        helpMenu = JMenu('Help', foreground=Color.white)
        helpMenu.add(JMenuItem('About'))
        menuBar.add(helpMenu)

        frame.setJMenuBar(menuBar)
        frame.setVisible(1)
Beispiel #60
0
    def run(self):
        frame = JFrame('Menu4',
                       size=(200, 125),
                       defaultCloseOperation=JFrame.EXIT_ON_CLOSE)

        menuBar = JMenuBar()

        fileMenu = JMenu('File')
        exitItem = fileMenu.add(JMenuItem('Exit', actionPerformed=self.exit))
        menuBar.add(fileMenu)

        helpMenu = JMenu('Help')
        aboutItem = helpMenu.add(JMenuItem('About',
                                           actionPerformed=self.about))
        menuBar.add(helpMenu)

        frame.setJMenuBar(menuBar)

        frame.setVisible(1)