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


Python QComboBox.width方法代码示例

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


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

示例1: populate_unit_layout

# 需要导入模块: from qtpy.QtWidgets import QComboBox [as 别名]
# 或者: from qtpy.QtWidgets.QComboBox import width [as 别名]
    def populate_unit_layout(self, unit_layout, gui=None):
        """
        Populate horizontal layout (living on conversion gui)
        with appropriate widgets. Set wave attribute to current
        wavelength.

        Layouts:
            10^[QLineEdit] X [QComboBox] / [QComboBox]
                        or
            10^[QLineEdit] X [QComboBox]

        :param unit_layout: (QHBoxLayout) Horizontal layout
        :param gui: conversion gui
        :return: updated unit_layout
        """

        power = self._get_current_power()

        unit_layout.addWidget(QLabel("10^"))
        power_input = QLineEdit(str(power))
        power_input.setFixedWidth(30)
        self.power_input = power_input
        power_input.textChanged.connect(self._update_message)
        unit_layout.addWidget(power_input)

        unit_layout.addWidget(QLabel("   X   "))

        flux_unit_str = self.spectral_flux_density.to_string()
        flux_options = FLUX_UNIT_REGISTRY.compose_unit_list(current_unit=flux_unit_str)
        if flux_unit_str in flux_options:
            index = flux_options.index(flux_unit_str)
        else:
            index = find_unit_index(flux_options, flux_unit_str)
            if index is None:
                flux_options.append(flux_unit_str)
                index = flux_options.index(flux_unit_str)
        flux_combo = QComboBox()
        flux_combo.addItems(flux_options)
        flux_combo.setCurrentIndex(index)
        flux_combo.currentIndexChanged.connect(self._on_flux_combo_change)
        flux_combo.currentIndexChanged.connect(self._update_message)
        self.flux_combo = flux_combo
        unit_layout.addWidget(flux_combo)

        if self.area is not None:
            division = QLabel("   /   ")
            unit_layout.addWidget(division)

            area_str = self.area.to_string()

            no_pixel_area = self.pixel_area is None

            if self.area.decompose() == u.pix.decompose() and no_pixel_area:
                area_options = AREA_UNIT_REGISTRY.compose_unit_list(pixel_only=True)
            elif 'solid angle' in self.area.physical_type and no_pixel_area:
                area_options = AREA_UNIT_REGISTRY.compose_unit_list(solid_angle_only=True)
            else:
                area_options = AREA_UNIT_REGISTRY.compose_unit_list()

            if area_str in area_options:
                index = area_options.index(area_str)
            else:
                index = find_unit_index(area_options, area_str)
                if index is None:
                    area_options.append(area_str)
                    index = area_options.index(area_str)
            area_combo = QComboBox()
            area_combo.width()
            area_combo.addItems(area_options)
            area_combo.setCurrentIndex(index)
            area_combo.currentIndexChanged.connect(self._update_message)
            self.area_combo = area_combo
            unit_layout.addWidget(area_combo)
        unit_layout.addStretch(1)
        unit_layout.setSpacing(0)

        if self.message_box is not None:
            self._update_message()

        return unit_layout
开发者ID:spacetelescope,项目名称:cube-tools,代码行数:82,代码来源:flux_units_gui.py


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