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


Python QComboBox.setMinimumWidth方法代码示例

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


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

示例1: MomentMapsGUI

# 需要导入模块: from qtpy.QtWidgets import QComboBox [as 别名]
# 或者: from qtpy.QtWidgets.QComboBox import setMinimumWidth [as 别名]
class MomentMapsGUI(QDialog):
    def __init__(self, data, data_collection, parent=None):
        super(MomentMapsGUI, self).__init__(parent)

        # Get the data_components (e.g., FLUX, DQ, ERROR etc)
        # Using list comprehension to keep the order of the component_ids
        self.data_components = [str(x).strip() for x in data.component_ids() if not x in data.coordinate_components]

        self.data = data
        self.data_collection = data_collection
        self.parent = parent

        self.label = ''

        self.calculateButton = None
        self.cancelButton = None

    def display(self):
        """
        Create the popup box with the calculation input area and buttons.

        :return:
        """
        self.setWindowFlags(self.windowFlags() | Qt.Tool)
        self.setWindowTitle("Create Moment Map")

        boldFont = QtGui.QFont()
        boldFont.setBold(True)

        # Create calculation label and input box
        self.data_label = QLabel("Data:")
        self.data_label.setFixedWidth(100)
        self.data_label.setAlignment((Qt.AlignRight | Qt.AlignTop))
        self.data_label.setFont(boldFont)

        self.data_combobox = QComboBox()
        self.data_combobox.addItems([str(x).strip() for x in self.data.component_ids() if not x in self.data.coordinate_components])
        self.data_combobox.setMinimumWidth(200)

        hbl1 = QHBoxLayout()
        hbl1.addWidget(self.data_label)
        hbl1.addWidget(self.data_combobox)

        # Create calculation label and input box
        self.order_label = QLabel("Order:")
        self.order_label.setFixedWidth(100)
        self.order_label.setAlignment((Qt.AlignRight | Qt.AlignTop))
        self.order_label.setFont(boldFont)

        self.order_combobox = QComboBox()
        self.order_combobox.addItems(["1", "2", "3", "4", "5", "6", "7", "8"])
        self.order_combobox.setMinimumWidth(200)

        hbl2 = QHBoxLayout()
        hbl2.addWidget(self.order_label)
        hbl2.addWidget(self.order_combobox)

        # Create Calculate and Cancel buttons
        self.calculateButton = QPushButton("Calculate")
        self.calculateButton.clicked.connect(self.calculate_callback)
        self.calculateButton.setDefault(True)

        self.cancelButton = QPushButton("Cancel")
        self.cancelButton.clicked.connect(self.cancel_callback)

        hbl5 = QHBoxLayout()
        hbl5.addStretch(1)
        hbl5.addWidget(self.cancelButton)
        hbl5.addWidget(self.calculateButton)

        # Add calculation and buttons to popup box
        vbl = QVBoxLayout()
        vbl.addLayout(hbl1)
        vbl.addLayout(hbl2)
        vbl.addLayout(hbl5)

        self.setLayout(vbl)
        self.setMaximumWidth(700)
        self.show()

    def do_calculation(self, order, data_name):
        # Grab spectral-cube
        import spectral_cube
        cube = spectral_cube.SpectralCube(self.data[data_name], wcs=self.data.coords.wcs)

        cube_moment = cube.moment(order=order, axis=0)

        self.label = '{}-moment-{}'.format(data_name, order)

        # Add new overlay/component to cubeviz. We add this both to the 2D
        # container Data object and also as an overlay. In future we might be
        # able to use the 2D container Data object for the overlays directly.
        add_to_2d_container(self.parent, self.data, cube_moment.value, cube_moment.unit, self.label)

        # Going to pass in just the value into the overlay as the units aren't
        # currently used for the overlay area.  BUT, this is probably not the
        # best way to do this.
        self.parent.add_overlay(cube_moment.value, self.label, display_now=False)

    def calculate_callback(self):
#.........这里部分代码省略.........
开发者ID:spacetelescope,项目名称:cube-tools,代码行数:103,代码来源:moment_maps.py

示例2: LineListsWindow

# 需要导入模块: from qtpy.QtWidgets import QComboBox [as 别名]
# 或者: from qtpy.QtWidgets.QComboBox import setMinimumWidth [as 别名]
class LineListsWindow(QWidget):
    """
    The actual line lists widget.

    Parameters
    ----------
    hub : :class:`~specviz.core.Hub`
        The Hub object for the plugin.

    Signals
    -------
    erase_linelabels : Signal
        Fired when a line list is removed by user action.
    dismiss_linelists_window : Signal
        Fired when the entire widget is dismissed. This happens only
        when the corresponding plot widget is dismissed by user action.
    """

    erase_linelabels = Signal(pg.PlotWidget)
    dismiss_linelists_window = Signal()

    def __init__(self, hub, *args, **kwargs):
        super().__init__(*args, **kwargs)

        self.hub = hub

        self.wave_range = (None, None)

        loadUi(os.path.join(os.path.dirname(__file__), "ui", "linelists_window.ui"), self)

        # QtDesigner can't add a combo box to a tool bar...
        self.line_list_selector = QComboBox()
        self.line_list_selector.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)
        self.line_list_selector.setMinimumWidth(230)
        self.line_list_selector.setToolTip("Select line list from internal library")
        self.main_toolbar.addWidget(self.line_list_selector)

        # QtDesigner creates tabbed widgets with 2 tabs, and doesn't allow
        # removing then in the designer itself. Remove in here then.
        while self.tab_widget.count() > 0:
            self.tab_widget.removeTab(0)

        # Local references for often used objects.
        self.plot_window = self.hub.plot_window

        # Request that line lists be read from wherever are they sources.
        if not hasattr(self, 'linelists'):
            self._request_linelists()

            # Populate line list selector with internal line lists
            model = self.line_list_selector.model()
            item = QStandardItem("Select line list")
            font = QFont("Monospace")
            font.setStyleHint(QFont.TypeWriter)
            font.setPointSize(12)
            item.setFont(font)
            model.appendRow(item)
            for description in linelist.descriptions():
                item = QStandardItem(str(description))
                item.setFont(font)
                model.appendRow(item)

        self.line_labels_plotter = LineLabelsPlotter(self)

        # Connect controls to appropriate signals.

        self.draw_button.clicked.connect(
            lambda:self.line_labels_plotter._plot_linelists(
            table_views=self._get_table_views(),
            panes=self._get_panes(),
            units=self.hub.plot_widget.spectral_axis_unit,
            caller=self.line_labels_plotter))

        self.erase_button.clicked.connect(lambda:self.erase_linelabels.emit(self.plot_window.plot_widget))
        self.dismiss_button.clicked.connect(self.dismiss_linelists_window.emit)

        self.actionOpen.triggered.connect(lambda:self._open_linelist_file(file_name=None))
        self.actionExport.triggered.connect(lambda:self._export_to_file(file_name=None))
        self.line_list_selector.currentIndexChanged.connect(self._lineList_selection_change)
        self.tab_widget.tabCloseRequested.connect(self._on_tab_close)

        self.hub.plot_window.window_removed.connect(self.dismiss_linelists_window.emit)

    def dismiss(self):
        """
        The Dismiss button just clears the plug-in
        window from whatever line lists it's holding.
        """
        v = self.tab_widget.count()
        for index in range(v-1,-1,-1):
            self.tab_widget.removeTab(index)

    def _get_waverange_from_dialog(self, line_list):
        # there is a widget-wide wavelength range so as to preserve
        # the user definition from call to call. At the initial
        # call, the wave range is initialized with whatever range
        # is being displayed in the spectrum plot window.
        if self.wave_range[0] == None or self.wave_range[1] == None:
            self.wave_range = self._find_wavelength_range()

#.........这里部分代码省略.........
开发者ID:nmearl,项目名称:specviz,代码行数:103,代码来源:linelists_window.py

示例3: SelectSmoothing

# 需要导入模块: from qtpy.QtWidgets import QComboBox [as 别名]
# 或者: from qtpy.QtWidgets.QComboBox import setMinimumWidth [as 别名]
class SelectSmoothing(QDialog):
    """
    SelectSmoothing launches a GUI and executes smoothing.
    Any output is added to the input data as a new component.
    """

    def __init__(self, data, parent=None, smooth_cube=None,
                 allow_preview=False, allow_spectral_axes=False):
        super(SelectSmoothing, self).__init__(parent)
        self.setWindowFlags(self.windowFlags() | Qt.Tool)
        self.parent = parent
        self.title = "Smoothing Selection"

        self.data = data  # Glue data to be smoothed

        # Check if smooth object is the caller
        if smooth_cube is None:
            self.smooth_cube = SmoothCube(data=self.data)
        else:
            self.smooth_cube = smooth_cube

        self.allow_spectral_axes = allow_spectral_axes

        self.allow_preview = allow_preview
        self.is_preview_active = False  # Flag to show if smoothing preview is active

        self.abort_window = None  # Small window pop up when smoothing.

        self.component_id = None  # Glue data component to smooth over
        self.current_axis = None  # Selected smoothing_axis
        self.current_kernel_type = None  # Selected kernel type, a key in SmoothCube.kernel_registry
        self.current_kernel_name = None  # Name of selected kernel

        self._init_selection_ui()  # Format and show gui

    def _init_selection_ui(self):
        # LINE 1: Radio box spatial vs spectral axis
        self.axes_prompt = QLabel("Smoothing Axis:")
        self.axes_prompt.setMinimumWidth(150)

        self.spatial_radio = QRadioButton("Spatial")
        self.spatial_radio.setChecked(True)
        self.current_axis = "spatial"
        self.spatial_radio.toggled.connect(self.spatial_radio_checked)

        self.spectral_radio = QRadioButton("Spectral")
        self.spectral_radio.toggled.connect(self.spectral_radio_checked)

        # hbl is short for Horizontal Box Layout
        hbl1 = QHBoxLayout()
        hbl1.addWidget(self.axes_prompt)
        hbl1.addWidget(self.spatial_radio)
        hbl1.addWidget(self.spectral_radio)

        # LINE 2: Kernel Type prompt
        self.k_type_prompt = QLabel("Kernel Type:")
        self.k_type_prompt.setMinimumWidth(150)
        # Load kernel types + names and add to drop down
        self._load_options()
        self.combo = QComboBox()
        self.combo.setMinimumWidth(150)
        self.combo.addItems(self.options[self.current_axis])

        hbl2 = QHBoxLayout()
        hbl2.addWidget(self.k_type_prompt)
        hbl2.addWidget(self.combo)

        # LINE 3: Kernel size
        self.size_prompt = QLabel(self.smooth_cube.get_kernel_size_prompt(self.current_kernel_type))
        self.size_prompt.setWordWrap(True)
        self.size_prompt.setMinimumWidth(150)
        self.unit_label = QLabel(self.smooth_cube.get_kernel_unit(self.current_kernel_type))
        self.k_size = QLineEdit("1")  # Default Kernel size set here

        hbl3 = QHBoxLayout()
        hbl3.addWidget(self.size_prompt)
        hbl3.addWidget(self.k_size)
        hbl3.addWidget(self.unit_label)

        # LINE 4: Data component drop down
        self.component_prompt = QLabel("Data Component:")
        self.component_prompt.setWordWrap(True)
        self.component_prompt.setMinimumWidth(150)
        # Load component_ids and add to drop down

        # Add the data component labels to the drop down, with the ComponentID
        # set as the userData:

        if self.parent is not None and hasattr(self.parent, 'data_components'):
            labeldata = [(str(cid), cid) for cid in self.parent.data_components]
        else:
            labeldata = [(str(cid), cid) for cid in self.data.main_components()]

        self.component_combo = QComboBox()
        update_combobox(self.component_combo, labeldata)

        self.component_combo.setMaximumWidth(150)
        self.component_combo.setCurrentIndex(0)
        if self.allow_preview:
            self.component_combo.currentIndexChanged.connect(self.update_preview_button)
#.........这里部分代码省略.........
开发者ID:spacetelescope,项目名称:cube-tools,代码行数:103,代码来源:smoothing.py


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