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


Python QComboBox.isVisible方法代码示例

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


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

示例1: SlitSelectionUI

# 需要导入模块: from qtpy.QtWidgets import QComboBox [as 别名]
# 或者: from qtpy.QtWidgets.QComboBox import isVisible [as 别名]
class SlitSelectionUI(QDialog):
    """
    Custom slit selection UI and editor.
    Right now it only applies slits temporarly,
    ie. if the current target is changed, slit settings
    will be lost.
    """
    def __init__(self, mosviz_viewer, parent=None):
        super(SlitSelectionUI, self).__init__(parent=parent)

        self.mosviz_viewer = mosviz_viewer
        self._slit_dict = {}

        self._mosviz_table_option_text = 'Slit from MOSViz Table'

        self._init_ui()

    def _init_ui(self):
        self.slit_type_label = QLabel('Slit Type')
        self.slit_type_combo = QComboBox()
        self.slit_type_combo.currentIndexChanged.connect(self.update_info)

        hbl1 = QHBoxLayout()
        hbl1.addWidget(self.slit_type_label)
        hbl1.addWidget(self.slit_type_combo)

        self.slit_width_label = QLabel('Slit Width')
        self.slit_width_input = QLineEdit()
        self.slit_width_combo = QComboBox()
        self.slit_width_units = QLabel('arcsec')

        hbl2 = QHBoxLayout()
        hbl2.addWidget(self.slit_width_label)
        hbl2.addWidget(self.slit_width_input)
        hbl2.addWidget(self.slit_width_combo)
        hbl2.addWidget(self.slit_width_units)

        self.slit_length_label = QLabel('Slit Length')
        self.slit_length_input = QLineEdit()
        self.slit_length_combo = QComboBox()
        self.slit_length_units = QLabel('arcsec')

        hbl3 = QHBoxLayout()
        hbl3.addWidget(self.slit_length_label)
        hbl3.addWidget(self.slit_length_input)
        hbl3.addWidget(self.slit_length_combo)
        hbl3.addWidget(self.slit_length_units)

        self.okButton = QPushButton('Apply')
        self.okButton.clicked.connect(self.apply)
        self.okButton.setDefault(True)

        self.cancelButton = QPushButton('Cancel')
        self.cancelButton.clicked.connect(self.cancel)

        hbl4 = QHBoxLayout()
        hbl4.addWidget(self.cancelButton)
        hbl4.addWidget(self.okButton)

        vbl = QVBoxLayout()
        vbl.addLayout(hbl1)
        vbl.addLayout(hbl2)
        vbl.addLayout(hbl3)
        vbl.addLayout(hbl4)
        self.setLayout(vbl)
        self.vbl = vbl

        self._load_selections()
        self._populate_combo()
        self.update_info(0)

        self.show()

    def _load_selections(self):
        """Load preconfigured slit shapes from yaml file"""
        file_path = os.path.join(os.path.dirname(__file__), 'saved_slits.yaml')
        with open(file_path) as f:
            self.slit_dict = yaml.load(f)

    def _populate_combo(self, default_index=0):
        """Populate combo box with slit types"""
        name_list = [self._mosviz_table_option_text] + \
                    [self.slit_dict[s]['name'] for s in sorted(self.slit_dict)] + \
                    ['Custom']

        key_list = ['default'] + [s for s in sorted(self.slit_dict)] + ['custom']

        combo_input = [(name, key) for name, key in zip(name_list, key_list)]
        update_combobox(self.slit_type_combo, combo_input, default_index=default_index)

    @property
    def width(self):
        if self.slit_width_combo.isVisible():
            width = self.slit_width_combo.currentData()
        else:
            width = self.slit_width_input.text()
        return u.Quantity(width)

    @property
    def length(self):
#.........这里部分代码省略.........
开发者ID:spacetelescope,项目名称:mosviz,代码行数:103,代码来源:slit_selection_ui.py


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