当前位置: 首页>>代码示例>>Python>>正文


Python JFrame.setDefaultCloseOperation方法代码示例

本文整理汇总了Python中javax.swing.JFrame.setDefaultCloseOperation方法的典型用法代码示例。如果您正苦于以下问题:Python JFrame.setDefaultCloseOperation方法的具体用法?Python JFrame.setDefaultCloseOperation怎么用?Python JFrame.setDefaultCloseOperation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.swing.JFrame的用法示例。


在下文中一共展示了JFrame.setDefaultCloseOperation方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_swing

# 需要导入模块: from javax.swing import JFrame [as 别名]
# 或者: from javax.swing.JFrame import setDefaultCloseOperation [as 别名]
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()
开发者ID:blakbox,项目名称:curso_python_dga_11,代码行数:9,代码来源:swingexample.py

示例2: startGui

# 需要导入模块: from javax.swing import JFrame [as 别名]
# 或者: from javax.swing.JFrame import setDefaultCloseOperation [as 别名]
def startGui():
    frame = JFrame("MonkeyPySon")
    frame.setContentPane(getContentPane())
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE)
    frame.pack()
    frame.setVisible(True)
    frame.addWindowFocusListener(GuiWindowFocusListener())
    startLookingDevices()
开发者ID:JeKim,项目名称:MonkeyPySon,代码行数:10,代码来源:monkeypyson.py

示例3: show_plot_in_frame

# 需要导入模块: from javax.swing import JFrame [as 别名]
# 或者: from javax.swing.JFrame import setDefaultCloseOperation [as 别名]
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
开发者ID:CalSimCalLite,项目名称:CalLiteGUI,代码行数:15,代码来源:model_obs_compare.py

示例4: createFrame

# 需要导入模块: from javax.swing import JFrame [as 别名]
# 或者: from javax.swing.JFrame import setDefaultCloseOperation [as 别名]
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
开发者ID:tiagoantao,项目名称:lositan,代码行数:16,代码来源:Main.py

示例5: createAndShowGUI

# 需要导入模块: from javax.swing import JFrame [as 别名]
# 或者: from javax.swing.JFrame import setDefaultCloseOperation [as 别名]
def createAndShowGUI():
    # Create the GUI and show it. As with all GUI code, this must run
    # on the event-dispatching thread.
    frame = JFrame("GUI Development ")
    frame.setSize(500, 600)
    frame.setLayout(BorderLayout())
    splitPane = JSplitPane(JSplitPane.VERTICAL_SPLIT)
    
    #Create and set up the content pane.
    psimures= ResourcePanel()
    psimures.setOpaque(True)
    pconfig = ConfigurationPanel()
    pconfig.setOpaque(True)      #content panes must be opaque

    # show the GUI
    splitPane.add(psimures)
    splitPane.add(pconfig)
    frame.add(splitPane)
    frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE)
    frame.setVisible(True)
开发者ID:fran-jo,项目名称:SimuGUI,代码行数:22,代码来源:meegui_jy.py

示例6: createAndShowGUI

# 需要导入模块: from javax.swing import JFrame [as 别名]
# 或者: from javax.swing.JFrame import setDefaultCloseOperation [as 别名]
def createAndShowGUI():
    # Create the GUI and show it. As with all GUI code, this must run
    # on the event-dispatching thread.
    frame = JFrame("MAE ")
    frame.setSize(1024, 768)
    panel= JPanel()
    panel.setLayout(GridBagLayout())
    
    #Create and set up the content pane.
    psimures= SimoutPanel()
    psimures.setOpaque(True)
    c = GridBagConstraints()
    c.fill = GridBagConstraints.HORIZONTAL
    c.weightx = 1
    c.gridx = 0
    c.gridy = 0
    panel.add(psimures, c);
    pmeasure= MeasPanel()
    pmeasure.setOpaque(True)
    c = GridBagConstraints()
    c.fill = GridBagConstraints.HORIZONTAL
    c.weightx = 1
    c.gridx = 0
    c.gridy = 1
    panel.add(pmeasure, c);
    preport = ReportPanel()
    preport.setOpaque(True)
    c = GridBagConstraints()
    c.fill = GridBagConstraints.VERTICAL
    c.weighty = 1
    c.gridx = 1
    c.gridy = 0
    c.gridheight= 2
    panel.add(preport,c)
    # show the GUI
    
    frame.add(panel)
#     frame.add(pmeasure)
#     frame.add(preport)
    frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE)
    frame.setVisible(True)
开发者ID:fran-jo,项目名称:SimuGUI,代码行数:43,代码来源:maegui_jy.py

示例7: __init__

# 需要导入模块: from javax.swing import JFrame [as 别名]
# 或者: from javax.swing.JFrame import setDefaultCloseOperation [as 别名]
  def __init__(self):
    frame = JFrame("Jython JTable Example")
    frame.setSize(500, 250)
    frame.setLayout(BorderLayout())

    self.tableData = [
      ['Mouse 1', eventNames[0], eventScriptType[0]],
      ['Mouse 2', eventNames[1] , eventScriptType[1]],
      ['Mouse 3', eventNames[2], eventScriptType[2]],
      ['Mouse 1 Shift', eventNames[3], eventScriptType[3]],
      ['Mouse 2 Shift',eventNames[4], eventScriptType[4]],
      ['Mouse 3 Shift',eventNames[5], eventScriptType[5]],
      ['Mouse 1 Control',eventNames[6], eventScriptType[6]],
      ['Mouse 2 Control',eventNames[7], eventScriptType[7]],
      ['Mouse 3 Control',eventNames[8], eventScriptType[8]],
       ]
    colNames = ('Script/Event','Name','Type')
    dataModel = DefaultTableModel(self.tableData, colNames)
    self.table = JTable(dataModel)

    scrollPane = JScrollPane()
    scrollPane.setPreferredSize(Dimension(400,200))
    scrollPane.getViewport().setView((self.table))

    panel = JPanel()
    panel.add(scrollPane)

    frame.add(panel, BorderLayout.CENTER)

    self.label = JLabel('Hello from Jython')
    frame.add(self.label, BorderLayout.NORTH)
    button = JButton('Save Settings',actionPerformed=self.setText)
    frame.add(button, BorderLayout.SOUTH)
    exitButton = JButton('Exit',actionPerformed=self.myExit)
    frame.add(exitButton, BorderLayout.EAST)

    frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE)
    frame.setVisible(True)
开发者ID:kwmiebach,项目名称:openwonderland-modules,代码行数:40,代码来源:mouse1s.py

示例8: main

# 需要导入模块: from javax.swing import JFrame [as 别名]
# 或者: from javax.swing.JFrame import setDefaultCloseOperation [as 别名]
def main(args):
  _WIDTH = 300
  _HEIGHT = 300
  fps = 20#frames per second
  bgColor = Color.white
  frame = JFrame("Graphics!")
  frame.setBackground(bgColor);
  frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE)

  drawgraphics = DrawGraphics()
  content = Animator(drawgraphics, _WIDTH, _HEIGHT, fps)
  content.setBackground(bgColor)
  content.setSize(_WIDTH, _HEIGHT)
  content.setMinimumSize(Dimension(_WIDTH, _HEIGHT))
  content.setPreferredSize(Dimension(_WIDTH, _HEIGHT))

  frame.setSize(_WIDTH, _HEIGHT)
  frame.setContentPane(content)
  frame.setResizable(True)
  frame.pack()

  Thread(content).start()
  frame.setVisible(True)
开发者ID:cgraziano,项目名称:misc,代码行数:25,代码来源:animate.py

示例9: getArguments

# 需要导入模块: from javax.swing import JFrame [as 别名]
# 或者: from javax.swing.JFrame import setDefaultCloseOperation [as 别名]
  def getArguments(self):
    """
    This function brings up a window to retreive any required arguments.  It uses a window with fields for each argument, filled with any arguments already given.
    While this window is visible the program will wait, once it is no longer visible all the arguments will be filled with the entries in the fields.
    """

    class LocationAction(AbstractAction):
      """
      Action to set the text of a text field to a folder or directory.
      """
      def __init__(self, field):
        AbstractAction.__init__(self, "...")
        self.field = field

      def actionPerformed(self, event):
        fileChooser = JFileChooser()
        fileChooser.fileSelectionMode = JFileChooser.FILES_AND_DIRECTORIES
        if fileChooser.showOpenDialog(None) == JFileChooser.APPROVE_OPTION:
          self.field.text = fileChooser.selectedFile.absolutePath
    
    class HelpAction(AbstractAction):
      """
      Displays a help page in a web browser.
      """
      def __init__(self):
        AbstractAction.__init__(self, "Help")

      def actionPerformed(self, event):
        browsers = ["google-chrome", "firefox", "opera", "epiphany", "konqueror", "conkeror", "midori", "kazehakase", "mozilla"]
        osName = System.getProperty("os.name")
        helpHTML = ClassLoader.getSystemResource("help.html").toString()
        if osName.find("Mac OS") == 0:
          Class.forName("com.apple.eio.FileManager").getDeclaredMethod( "openURL", [String().getClass()]).invoke(None, [helpHTML])
        elif osName.find("Windows") == 0:
          Runtime.getRuntime().exec( "rundll32 url.dll,FileProtocolHandler " + helpHTML)
        else:
          browser = None
          for b in browsers:
            if browser == None and Runtime.getRuntime().exec(["which", b]).getInputStream().read() != -1:
              browser = b
              Runtime.getRuntime().exec([browser, helpHTML])

    class OKAction(AbstractAction):
      """
      Action for starting the pipeline.  This action will simply make the window invisible.
      """
      def __init__(self):
        AbstractAction.__init__(self, "Ok")

      def actionPerformed(self, event):
        frame.setVisible(False)

    class CancelAction(AbstractAction):
      """
      Action for canceling the pipeline.  Exits the program.
      """
      def __init__(self):
        AbstractAction.__init__(self, "Cancel")

      def actionPerformed(self, event):
        sys.exit(0)

    frame = JFrame("Neofelis")
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE)
    constraints = GridBagConstraints()
    contentPane = JPanel(GridBagLayout())
    frame.setContentPane(contentPane)
    blastField = JTextField(self.blastLocation)
    genemarkField = JTextField(self.genemarkLocation)
    transtermField = JTextField(self.transtermLocation)
    tRNAscanField = JTextField(self.tRNAscanLocation)
    databaseLocationField = JTextField(os.path.split(self.database)[0])
    databaseField = JTextField(os.path.split(self.database)[1])
    matrixField = JTextField(str(self.matrix))
    eValueField = JTextField(str(self.eValue))
    minLengthField = JTextField(str(self.minLength))
    scaffoldingDistanceField = JTextField(str(self.scaffoldingDistance))
    promoterScoreField = JTextField(str(self.promoterScoreCutoff))
    queryField = JTextField(self.sources[0])

    constraints.gridx = 0
    constraints.gridy = 0
    constraints.gridwidth = 1
    constraints.gridheight = 1
    constraints.fill = GridBagConstraints.HORIZONTAL
    constraints.weightx = 0
    constraints.weighty = 0
    contentPane.add(JLabel("Blast Location"), constraints)
    constraints.gridy = 1
    contentPane.add(JLabel("Genemark Location"), constraints)
    constraints.gridy = 2
    contentPane.add(JLabel("Transterm Location"), constraints)
    constraints.gridy = 3
    contentPane.add(JLabel("tRNAscan Location"), constraints)
    constraints.gridy = 4
    contentPane.add(JLabel("Databases Location"), constraints)
    constraints.gridy = 5
    contentPane.add(JLabel("Database"), constraints)
    constraints.gridy = 6
    contentPane.add(JLabel("Matrix(Leave blank to use heuristic matrix)"), constraints)
#.........这里部分代码省略.........
开发者ID:pavithra03,项目名称:neofelis,代码行数:103,代码来源:main.py

示例10: __init__

# 需要导入模块: from javax.swing import JFrame [as 别名]
# 或者: from javax.swing.JFrame import setDefaultCloseOperation [as 别名]

#.........这里部分代码省略.........
    '''
    '''
    jMenuBar1 = JMenuBar()
    jMenu1 = JMenu()
    jMenu2 = JMenu()
    jMenuItem1 = JMenuItem('Open', actionPerformed=self.onClick)
    jMenuItem2 = JMenuItem()
    jMenu1.setText('File')
    jMenu2.setText('Simulation')
    
    #jMenuItem1.setText('Open')
    jMenuItem2.setText('Exit')
    jMenu1.add(jMenuItem1)
    jMenu1.add(jMenuItem2)
    jMenuBar1.add(jMenu1)
    
    jMenuItem21 = JMenuItem('Simulation Options',actionPerformed=self.writeText)
    jMenuItem22 = JMenuItem('Simulate',actionPerformed=self.writeText)
    jMenuItem23 = JMenuItem('Generate FMU',actionPerformed=self.writeText)
    
#     jMenuItem21.setText('Run Project')
#     jMenuItem22.setText('Generate FMU')
    jMenu2.add(jMenuItem21)
    jMenu2.add(jMenuItem22)
    jMenu2.add(jMenuItem23)
    jMenuBar1.add(jMenu2)
    frame.setJMenuBar(jMenuBar1)
    
    '''
    '''
    panel1.add(label1,BorderLayout.WEST)
    panel1.add(self.textfield1, BorderLayout.CENTER)
    copyButton = JButton('send',actionPerformed=self.copyText)
    panel1.add(copyButton, BorderLayout.EAST)
    #panel1.add(self.textfield2, BorderLayout.SOUTH)
    splitPane.setLeftComponent(panel1);
    '''
    
   image adding in the frame
    
    
    '''
    
    #imPanel.add(imPanel,BorderLayout.WEST)
    #imPanel.setBackground(Color(66, 66, 66))
    imPanel1 = JPanel()
    rot = ImageIcon("ballon.jpg")
    rotLabel = JLabel(rot)
    rotLabel.setBounds(0,0, rot.getIconWidth(), rot.getIconHeight())
    imPanel1.add(rotLabel, BorderLayout.SOUTH)
    frame.add(imPanel1, BorderLayout.SOUTH)
    
    '''
    panel for text area adding in split pan 
    
    '''
    tabPane = JTabbedPane(JTabbedPane.TOP)

    label = JLabel("<html><br>This is a tab1</html>")
    panel1 = JPanel()
    panel1.setBackground(Color.lightGray)
    panel23 = JPanel()
    panel23.setBackground(Color.black)
    panel1.add(panel23,BorderLayout.SOUTH)
    panel1.add(label,BorderLayout.NORTH)
    '''
    adding button in the panel1
    '''
    writeButton = JButton('write')
    panel1.add(writeButton, BorderLayout.WEST)
    tabPane.addTab("tab1", panel1)
    
    
    #frame.add(panel1,BorderLayout.EAST)
    #panel1.setBackground(Color(66, 66, 66))
#     rot1 = ImageIcon("ballon.jpg",BorderLayout.SOUTH)
#     rotLabel1 = JLabel(rot1)
#     rotLabel1.setBounds(0,0, rot.getIconWidth(), rot.getIconHeight())
#     panel1.add(rotLabel1)

    label2 = JLabel("This is a tab2")

    panel2 = JPanel()
    panel2.setBackground(Color.lightGray)
    panel2.add(label2)
    tabPane.addTab("tab2", panel2)

#     imPanel2 =JPanel()
    self.textarea = JTextArea('Write something from commandLine')
    self.textarea.setColumns(40);
    self.textarea.setRows(40);
 
    panel2.add(self.textarea, BorderLayout.NORTH)

    splitPane.setRightComponent(tabPane);
    splitPane.setDividerLocation(60);

    frame.add(splitPane)
    frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE)
    frame.setVisible(True)
开发者ID:fran-jo,项目名称:SimuGUI,代码行数:104,代码来源:demo.py

示例11: JyTwitter

# 需要导入模块: from javax.swing import JFrame [as 别名]
# 或者: from javax.swing.JFrame import setDefaultCloseOperation [as 别名]
class JyTwitter(object):
    def __init__(self):
        self.frame = JFrame("Jython Twitter")
        self.frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE)
 
        self.loginPanel = JPanel(GridLayout(0,2))
        self.frame.add(self.loginPanel)

        self.usernameField = JTextField('',15)
        self.loginPanel.add(JLabel("username:", SwingConstants.RIGHT))
        self.loginPanel.add(self.usernameField)

        self.passwordField = JPasswordField('', 15)
        self.loginPanel.add(JLabel("password:", SwingConstants.RIGHT))
        self.loginPanel.add(self.passwordField)

        self.loginButton = JButton('Log in',actionPerformed=self.login)
        self.loginPanel.add(self.loginButton)

        self.message = JLabel("Please Log in")
        self.loginPanel.add(self.message)

        self.frame.pack()
        self.frame.visible = True

    def login(self,event):
        self.message.text = "Attempting to Log in..."
        self.frame.show()
        username = self.usernameField.text
        try:
            self.api = twitter.Api(username, self.passwordField.text)
            self.timeline(username)
            self.loginPanel.visible = False
            self.message.text = "Logged in"
        except:
            self.message.text = "Log in failed."
            raise
        self.frame.size = 400,800
        self.frame.show()

    def timeline(self, username):
        timeline = self.api.GetFriendsTimeline(username)
        self.resultPanel = JPanel()
        self.resultPanel.layout = BoxLayout(self.resultPanel, BoxLayout.Y_AXIS)
        for s in timeline:
            self.showTweet(s)

        scrollpane = JScrollPane(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
                                 JScrollPane.HORIZONTAL_SCROLLBAR_NEVER)
        scrollpane.preferredSize = 400, 800
        scrollpane.viewport.view = self.resultPanel

        self.frame.add(scrollpane)

    def showTweet(self, status):
        user = status.user
        p = JPanel()

        # image grabbing seems very expensive, good place for a callback?
        p.add(JLabel(ImageIcon(URL(user.profile_image_url))))

        p.add(JTextArea(text = status.text,
                        editable = False,
                        wrapStyleWord = True,
                        lineWrap = True,
                        alignmentX = Component.LEFT_ALIGNMENT,
                        size = (300, 1)
             ))
        self.resultPanel.add(p)
开发者ID:jython,项目名称:book,代码行数:71,代码来源:twitfriends.py

示例12: Config

# 需要导入模块: from javax.swing import JFrame [as 别名]
# 或者: from javax.swing.JFrame import setDefaultCloseOperation [as 别名]
class Config(ITab):
    """Defines the Configuration tab"""

    def __init__(self, callbacks, parent):
        # Initialze self stuff
        self._callbacks = callbacks
        self.config = {}
        self.ext_stats = {}
        self.url_reqs = []
        self.parse_files = False
        self.tab = JPanel(GridBagLayout())
        self.view_port_text = JTextArea("===SpyDir===")
        self.delim = JTextField(30)
        self.ext_white_list = JTextField(30)
        # I'm not sure if these fields are necessary still
        # why not just use Burp func to handle this?
        # leaving them in case I need it for the HTTP handler later
        # self.cookies = JTextField(30)
        # self.headers = JTextField(30)
        self.url = JTextField(30)
        self.parent_window = parent
        self.plugins = {}
        self.loaded_p_list = set()
        self.loaded_plugins = False
        self.config['Plugin Folder'] = None
        self.double_click = False
        self.source_input = ""
        self.print_stats = True
        self.curr_conf = JLabel()
        self.window = JFrame("Select plugins",
                             preferredSize=(200, 250),
                             windowClosing=self.p_close)
        self.window.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE)
        self.window.setVisible(False)
        self.path_vars = JTextField(30)


        # Initialize local stuff
        tab_constraints = GridBagConstraints()
        status_field = JScrollPane(self.view_port_text)

        # Configure view port
        self.view_port_text.setEditable(False)

        labels = self.build_ui()

        # Add things to rows
        tab_constraints.anchor = GridBagConstraints.FIRST_LINE_END
        tab_constraints.gridx = 1
        tab_constraints.gridy = 0
        tab_constraints.fill = GridBagConstraints.HORIZONTAL
        self.tab.add(JButton(
            "Resize screen", actionPerformed=self.resize),
                     tab_constraints)
        tab_constraints.gridx = 0
        tab_constraints.gridy = 1
        tab_constraints.anchor = GridBagConstraints.FIRST_LINE_START
        self.tab.add(labels, tab_constraints)

        tab_constraints.gridx = 1
        tab_constraints.gridy = 1
        tab_constraints.fill = GridBagConstraints.BOTH
        tab_constraints.weightx = 1.0
        tab_constraints.weighty = 1.0

        tab_constraints.anchor = GridBagConstraints.FIRST_LINE_END
        self.tab.add(status_field, tab_constraints)
        try:
            self._callbacks.customizeUiComponent(self.tab)
        except Exception:
            pass

    def build_ui(self):
        """Builds the configuration screen"""
        labels = JPanel(GridLayout(21, 1))
        checkbox = JCheckBox("Attempt to parse files for URL patterns?",
                             False, actionPerformed=self.set_parse)
        stats_box = JCheckBox("Show stats?", True,
                              actionPerformed=self.set_show_stats)
        # The two year old in me is laughing heartily
        plug_butt = JButton("Specify plugins location",
                            actionPerformed=self.set_plugin_loc)
        load_plug_butt = JButton("Select plugins",
                                 actionPerformed=self.p_build_ui)
        parse_butt = JButton("Parse directory", actionPerformed=self.parse)
        clear_butt = JButton("Clear text", actionPerformed=self.clear)
        spider_butt = JButton("Send to Spider", actionPerformed=self.scan)
        save_butt = JButton("Save config", actionPerformed=self.save)
        rest_butt = JButton("Restore config", actionPerformed=self.restore)
        source_butt = JButton("Input Source File/Directory",
                              actionPerformed=self.get_source_input)

        # Build grid
        labels.add(source_butt)
        labels.add(self.curr_conf)
        labels.add(JLabel("String Delimiter:"))
        labels.add(self.delim)
        labels.add(JLabel("Extension Whitelist:"))
        labels.add(self.ext_white_list)
        labels.add(JLabel("URL:"))
#.........这里部分代码省略.........
开发者ID:aur3lius-dev,项目名称:SpyDir,代码行数:103,代码来源:SpyDir.py

示例13: FilamentGame_ModelEditor

# 需要导入模块: from javax.swing import JFrame [as 别名]
# 或者: from javax.swing.JFrame import setDefaultCloseOperation [as 别名]
class FilamentGame_ModelEditor(EditorExtension, JPanel, MouseListener, MouseMotionListener):
    def getExtensionName(self):
        return "Filament Model Tool"

    def initializeExtension(self, manager):
        self.manager = manager
        self.frame = JFrame(self.getExtensionName())
        self.frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE)

        # instance setup
        self.state = State.NOTHING
        self.entity = Entity()

        # Setupgui
        self.setupGui()
        self.addMouseListener(self)
        self.addMouseMotionListener(self)
        self.setPreferredSize(Dimension(500, 500))
        self.frame.pack()
        self.frame.setResizable(False)
        self.frame.setVisible(True)
        self.cameraPos = [0, 0]

    def setupGui(self):

        cPanel = JPanel()

        # Draw Shape Button
        self.drawShapeButton = JButton("Draw", actionPerformed=self.drawShapeButtonAction)
        cPanel.add(self.drawShapeButton)

        drawShapeButton = JButton("Clear", actionPerformed=self.clearShapeButtonAction)
        cPanel.add(drawShapeButton)

        # Label
        self.infoLabel = JLabel("Shape Editor")
        cPanel.add(self.infoLabel)

        self.frame.add(BorderLayout.NORTH, cPanel)
        self.frame.add(BorderLayout.CENTER, self)

    def entitySelected(self, entity):
        self.entity = entity
        self.repaint()

    def sceneChanged(self, scene):
        self.scene = scene
        self.entity = Entity()
        self.repaint()

    # BUTTONS
    def drawShapeButtonAction(self, e):
        if self.state == State.NOTHING:
            self.state = State.DRAW_SHAPE
            self.infoLabel.setText("Click to Draw Shape")
            self.drawShapeButton.setText("Stop Drawing")
        elif self.state != State.NOTHING:
            self.state = State.NOTHING
            self.infoLabel.setText("")
            self.drawShapeButton.setText("Draw")
        self.revalidate()

    def clearShapeButtonAction(self, e):
        if self.state != State.NOTHING:
            self.drawShapeButtonAction(e)
        self.state = State.NOTHING
        polygon = self.entity.getModel().pol
        polygon.reset()
        self.repaint()

    # DRAWING
    def paintComponent(self, g):
        self.super__paintComponent(g)
        g.scale(1, -1)
        g.translate(-self.cameraPos[0] + self.getWidth() / 2, -self.cameraPos[1] - self.getHeight() / 2)
        self.drawGrid(g)
        polygon = self.entity.getModel().pol
        x = []
        y = []
        g.setColor(Color.BLACK)
        for i in range(polygon.npoints):
            x = x + [int(polygon.xpoints[i])]
            y = y + [int(polygon.ypoints[i])]
            g.drawRect(int(polygon.xpoints[i]) - 2, int(polygon.ypoints[i]) - 2, 4, 4)
        g.fillPolygon(x, y, polygon.npoints)

    def drawGrid(self, g):
        g.setColor(Color.RED)
        g.drawLine(50, 0, -50, 0)
        g.drawLine(0, 50, 0, -50)

    # MOUSE LISTENER
    def mouseCicked(self, e):
        return

    def mouseEntered(self, e):
        return

    def mouseExited(self, e):
        return
#.........这里部分代码省略.........
开发者ID:efruchter,项目名称:Filament-HIBERNATE,代码行数:103,代码来源:FilamentGame_ModelEditor.py

示例14: doall

# 需要导入模块: from javax.swing import JFrame [as 别名]
# 或者: from javax.swing.JFrame import setDefaultCloseOperation [as 别名]

#.........这里部分代码省略.........
            lrms2_max=calculate_rms(drun2m_max.data,dobsm_max.data)*weights[l]
            rmsmap[l] = lrms1,lrms2,lrms1_min,lrms2_min,lrms1_max,lrms2_max
            rms2=rms2+lrms2
            rms2_min=rms2_min+lrms2_min
            rms2_max=rms2_max+lrms2_max
        plotd = newPlot("Hist vs New Geom [%s]"%l)
        if data1 != None:
            plotd.addData(dobsd.data)
        plotd.addData(drun1d.data)
        if drun2 != None:
            plotd.addData(drun2d.data)
        plotd.showPlot()
        legend_label = plotd.getLegendLabel(drun1d.data)
        legend_label.setText(legend_label.getText()+" ["+str(int(lrms1*100)/100.)+","+str(int(lrms1_min*100)/100.)+","+str(int(lrms1_max*100)/100.)+"]")
        legend_label = plotd.getLegendLabel(drun2d.data)
        legend_label.setText(legend_label.getText()+" ["+str(int(lrms2*100)/100.)+","+str(int(lrms2_min*100)/100.)+","+str(int(lrms2_max*100)/100.)+"]")
        plotd.setVisible(False)
        xaxis=plotd.getViewport(0).getAxis("x1")
        vmin =xaxis.getViewMin()+261500. # hardwired to around july 1, 2008
        xaxis.setViewLimits(vmin,vmin+10000.)
        if data1 != None:
            pline = plotd.getCurve(dobsd.data)
            pline.setLineVisible(1)
            pline.setLineColor("blue")
            pline.setSymbolType(Symbol.SYMBOL_CIRCLE)
            pline.setSymbolsVisible(0)
            pline.setSymbolSize(3)
            pline.setSymbolSkipCount(0)
            pline.setSymbolFillColor(pline.getLineColorString())
            pline.setSymbolLineColor(pline.getLineColorString())
            g2dPanel = plotd.getPlotpanel()
            g2dPanel.revalidate();
            g2dPanel.paintGfx();
        plotm = newPlot("Hist vs New Geom Monthly [%s]"%l)
        plotm.setSize(1800,1200)
        if data1 != None:
            plotm.addData(dobsm.data)
           #plotm.addData(dobsm_max.data)
            #plotm.addData(dobsm_min.data)
        plotm.addData(drun1m.data)
        #plotm.addData(drun1m_max.data)
        #plotm.addData(drun1m_min.data)
        if drun2 != None:
            plotm.addData(drun2m.data)
            #plotm.addData(drun2m_max.data)
            #plotm.addData(drun2m_min.data)
        plotm.showPlot()
        if data1 != None:
            pline = plotm.getCurve(dobsm.data)
            pline.setLineVisible(1)
            pline.setLineColor("blue")
            pline.setSymbolType(Symbol.SYMBOL_CIRCLE)
            pline.setSymbolsVisible(0)
            pline.setSymbolSize(3)
            pline.setSymbolSkipCount(0)
            pline.setSymbolFillColor(pline.getLineColorString())
            pline.setSymbolLineColor(pline.getLineColorString())
        plotm.setVisible(False)
        if data1 != None:
            plots=do_regression_plots(dobsm,drun1m,drun2m)
            if plots != None:
                spanel = plots.getPlotpanel()
                removeToolbar(spanel)
        mpanel = plotm.getPlotpanel()
        removeToolbar(mpanel)
        dpanel = plotd.getPlotpanel()
        removeToolbar(dpanel)
        from javax.swing import JPanel,JFrame
        from java.awt import GridBagLayout, GridBagConstraints
        mainPanel = JPanel()
        mainPanel.setLayout(GridBagLayout())
        c=GridBagConstraints()
        c.fill=c.BOTH
        c.weightx,c.weighty=0.5,1
        c.gridx,c.gridy,c.gridwidth,c.gridheight=0,0,10,4
        if data1 != None:
            if plots != None:
                pass
                #mainPanel.add(spanel,c)
        c.gridx,c.gridy,c.gridwidth,c.gridheight=0,0,10,4
        c.weightx,c.weighty=1,1
        mainPanel.add(mpanel,c)
        c.gridx,c.gridy,c.gridwidth,c.gridheight=0,4,10,6
        mainPanel.add(dpanel,c)
        fr=JFrame()
        fr.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE)
        fr.getContentPane().add(mainPanel)
        fr.setSize(1100,850);
        fr.show();
        mainPanel.setSize(1100,850);
        mainPanel.setBackground(Color.WHITE);
        #import time; time.sleep(5)
        saveToPNG(mainPanel,imageDir+l+".png")
    if weights != None:
        rms1=(rms1+rms1_min+rms1_max)/sumwts
        rms2=(rms2+rms2_min+rms2_max)/sumwts
        print 'RMS Run 1: %f'%rms1
        print 'RMS Run 2: %f'%rms2
        for loc in rmsmap.keys():
            print loc, rmsmap[loc] 
开发者ID:CalSimCalLite,项目名称:CalLiteGUI,代码行数:104,代码来源:calibration_compare_plots.py

示例15: makeEditorFrame

# 需要导入模块: from javax.swing import JFrame [as 别名]
# 或者: from javax.swing.JFrame import setDefaultCloseOperation [as 别名]
def makeEditorFrame(ldPath, compiler):
    mb = JMenuBar()
    
    file = JMenu("File")
    edit = JMenu("Edit")
    run = JMenu("Run")
    
    newMenu = menu_with_accelerator("New",(KeyEvent.VK_N,ActionEvent.META_MASK))
    file.add(newMenu)
           
    open = menu_with_accelerator("Open",(KeyEvent.VK_O,ActionEvent.META_MASK))
    file.add(open)
    
    save = menu_with_accelerator("Save",(KeyEvent.VK_S,ActionEvent.META_MASK))
    file.add(save)
    
    file.add(JSeparator());
    
    resetPipe = menu_with_accelerator("Reset Pipeline",(KeyEvent.VK_N,ActionEvent.META_MASK | ActionEvent.SHIFT_MASK))
    file.add(resetPipe)
            
    openPipe = menu_with_accelerator("Open Pipeline",(KeyEvent.VK_O,ActionEvent.META_MASK | ActionEvent.SHIFT_MASK))
    file.add(openPipe)
            
    compile = menu_with_accelerator("Compile",(KeyEvent.VK_ENTER, ActionEvent.META_MASK))
    run.add(compile)
            
    mb.add(file)
    mb.add(edit)
    mb.add(run)
            
    f = JFrame("SFGP Shader Editor")
    f.setJMenuBar(mb)
    c = f.getContentPane()
    c.setLayout(BorderLayout())
    editor = GLSLEditorPane("",ldPath,compiler)
    c.add(editor, BorderLayout.CENTER)
    c.doLayout()
    
    f.setSize(1000, 700);
    f.setVisible(True);
    f.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
            
    class EditorActionListener(ActionListener):
        def makeRelay(srcObj):
            return (lambda e: editor.actionPerformed(ActionEvent(srcObj, e.getID(), e.getActionCommand())))
        editorActions = {
            save : (lambda e: editor.saveCurrent()),
            compile : (lambda e: editor.compileCurrent()),
            open : makeRelay(editor.openShader),
            newMenu : makeRelay(editor.newShader),
            openPipe : makeRelay(editor.openPipeline),
            resetPipe : makeRelay(editor.resetPipeline)
                        }
        def actionPerformed(self, e):
            editorActions = EditorActionListener.editorActions
            evtSrc = e.getSource()
            if evtSrc in editorActions:
                editorActions[evtSrc](e)
            else:
                raise IllegalStateException("Imaginary menu item registered an ActionEvent: " + evtSrc)
    menuListener = EditorActionListener()
    compile.addActionListener(menuListener);
    newMenu.addActionListener(menuListener);
    open.addActionListener(menuListener);
    save.addActionListener(menuListener);
    resetPipe.addActionListener(menuListener);
    openPipe.addActionListener(menuListener);
开发者ID:elfprince13,项目名称:FreeBuild,代码行数:70,代码来源:shaderUI.py


注:本文中的javax.swing.JFrame.setDefaultCloseOperation方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。