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


Python JComboBox.setSize方法代码示例

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


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

示例1: addLine

# 需要导入模块: from javax.swing import JComboBox [as 别名]
# 或者: from javax.swing.JComboBox import setSize [as 别名]
    def addLine(self, objectID, category, text):
        """
        Add a new panel containing the text corresponding to one line in the
        ATF file.
        This panel will show the line type (ruling, comment, text,
        translation...), followed by the line content and a group of icons to
        add, edit or remove the line.
        """
        linePanel = JPanel()
        linePanel.setLayout(BorderLayout())

        label = JLabel(category)

        combo = JComboBox(text)
        combo.setEditable(True)
        combo.setPreferredSize(Dimension(500, 20))
        combo.setSize(combo.getPreferredSize())
        combo.setMinimumSize(combo.getPreferredSize())
        combo.setMaximumSize(combo.getPreferredSize())

        buttonsPanel = JPanel()
        addButton = JButton("Add")
        editButton = JButton("Edit")
        deleteButton = JButton("Delete")
        buttonsPanel.add(addButton)
        buttonsPanel.add(editButton)
        buttonsPanel.add(deleteButton)

        linePanel.add(label, BorderLayout.WEST)
        linePanel.add(combo, BorderLayout.CENTER)
        linePanel.add(buttonsPanel, BorderLayout.EAST)

        # Add metadataPanel to object tab in main panel
        self.objectTabs[objectID].add(linePanel)
开发者ID:oracc,项目名称:nammu,代码行数:36,代码来源:ModelView.py

示例2: NewAtfView

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

#.........这里部分代码省略.........
        project_label = JLabel('Project: ')
        self.right_combo = JComboBox()
        self.right_combo.setEditable(True)

        def create_project_list():
            '''
            Prepares list of projects and subprojects ordered with the default
            one first.
            '''
            default_project = self.projects['default'][0].split('/')[0]
            if '/' in self.projects['default']:
                default_subproject = self.projects['default'].split('/')[1]
            else:
                default_subproject = ''
            projects = [default_project]
            subprojects = [default_subproject]
            # User created projects might not be in default dictionary
            for project in self.projects.keys():
                if (project != default_project and project != 'default'):
                    projects.append(project)
                # Default project might not have subproject
            if default_project in self.projects.keys():
                if default_subproject:
                    for subproject in self.projects[default_project]:
                        if (subproject != default_subproject):
                            subprojects.append(subproject)
            return projects, subprojects

        self.left_combo = JComboBox(create_project_list()[0])
        # Make left combo keep size no matter how long project names are
        self.left_combo.setPreferredSize(Dimension(125, 30))
        self.left_combo.setMinimumSize(self.left_combo.getPreferredSize())
        self.left_combo.setMaximumSize(self.left_combo.getPreferredSize())
        self.left_combo.setSize(self.left_combo.getPreferredSize())

        self.right_combo = JComboBox(create_project_list()[1])
        # Prevent right combo to change sizes dynamically
        self.right_combo.setPreferredSize(Dimension(100, 30))
        self.right_combo.setMinimumSize(self.left_combo.getPreferredSize())
        self.right_combo.setMaximumSize(self.left_combo.getPreferredSize())
        self.right_combo.setSize(self.left_combo.getPreferredSize())

        action_listener = ComboActionListener(self.right_combo,
                                              self.projects)
        self.left_combo.addActionListener(action_listener)
        self.left_combo.setEditable(True)
        self.right_combo.setEditable(True)

        slash_label = JLabel('/')

        tooltip_text = ("<html><body>Choose project from list or insert a new "
                        "one.<br/>You can leave the right-hand field blank."
                        "</body><html>")
        help_label = self.build_help_label(tooltip_text)
        panel.add(project_label)
        panel.add(self.left_combo)
        panel.add(slash_label)
        panel.add(self.right_combo)
        panel.add(help_label)
        # Set up constraints to tell panel how to position components.
        layout.putConstraint(SpringLayout.WEST,
                             project_label,
                             15,
                             SpringLayout.WEST,
                             panel)
        layout.putConstraint(SpringLayout.NORTH,
开发者ID:oracc,项目名称:nammu,代码行数:70,代码来源:NewAtfView.py


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