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


Python JButton.actionPerformed方法代码示例

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


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

示例1: __init__

# 需要导入模块: from javax.swing import JButton [as 别名]
# 或者: from javax.swing.JButton import actionPerformed [as 别名]
    def __init__(self):
        self.setLayout(GridBagLayout())

        shrinkX = JButton("shrinkX")
        shrinkX.actionPerformed = lambda event : rescaleLayout(0.5, 1)
        constr = GridBagConstraints()
        constr.gridx = 0
        constr.gridy = 0
        self.add(shrinkX, constr)

        growX = JButton("growX")
        growX.actionPerformed = lambda event : rescaleLayout(1.5, 1)
        constr = GridBagConstraints()
        constr.gridx = 2
        constr.gridy = 0
        self.add(growX, constr)

        shrinkY = JButton("shrinkY")
        shrinkY.actionPerformed = lambda event : rescaleLayout(1, 0.5)
        constr = GridBagConstraints()
        constr.gridx = 0
        constr.gridy = 2
        self.add(shrinkY, constr)

        growY = JButton("growY")
        growY.actionPerformed = lambda event : rescaleLayout(1, 1.5)
        constr = GridBagConstraints()
        constr.gridx = 2
        constr.gridy = 2
        self.add(growY, constr)

        centerB = JButton("center")
        centerB.actionPerformed = lambda event : center()
        constr = GridBagConstraints()
        constr.gridx = 1
        constr.gridy = 1
        self.add(centerB, constr)

        ui.dock(self)
开发者ID:carvalhomb,项目名称:tsmells,代码行数:41,代码来源:RescalePanel.py

示例2: create_file_choice_button

# 需要导入模块: from javax.swing import JButton [as 别名]
# 或者: from javax.swing.JButton import actionPerformed [as 别名]
    def create_file_choice_button(name, label_text):
        button = JButton('Click to select')
        label = JLabel(label_text)
        file_chooser = JFileChooser()
        
        def choose_file(event):
            user_did_choose_file = (file_chooser.showOpenDialog(frame) ==
                                   JFileChooser.APPROVE_OPTION)
            if user_did_choose_file:
                file_ = file_chooser.getSelectedFile();
                button.text = chosen_values[name] = str(file_)
        button.actionPerformed = choose_file

        panel.add(label)
        panel.add(button)
开发者ID:bjartem,项目名称:lancelot-eclipse,代码行数:17,代码来源:gui.py


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