本文整理汇总了Python中qtpy.QtWidgets.QComboBox.setMaximumWidth方法的典型用法代码示例。如果您正苦于以下问题:Python QComboBox.setMaximumWidth方法的具体用法?Python QComboBox.setMaximumWidth怎么用?Python QComboBox.setMaximumWidth使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类qtpy.QtWidgets.QComboBox
的用法示例。
在下文中一共展示了QComboBox.setMaximumWidth方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: SelectSmoothing
# 需要导入模块: from qtpy.QtWidgets import QComboBox [as 别名]
# 或者: from qtpy.QtWidgets.QComboBox import setMaximumWidth [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)
#.........这里部分代码省略.........