本文整理汇总了Python中qtpy.QtWidgets.QLabel.setMinimumWidth方法的典型用法代码示例。如果您正苦于以下问题:Python QLabel.setMinimumWidth方法的具体用法?Python QLabel.setMinimumWidth怎么用?Python QLabel.setMinimumWidth使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类qtpy.QtWidgets.QLabel
的用法示例。
在下文中一共展示了QLabel.setMinimumWidth方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: FadingTipBox
# 需要导入模块: from qtpy.QtWidgets import QLabel [as 别名]
# 或者: from qtpy.QtWidgets.QLabel import setMinimumWidth [as 别名]
class FadingTipBox(FadingDialog):
""" """
def __init__(self, parent, opacity, duration, easing_curve, tour=None):
super(FadingTipBox, self).__init__(parent, opacity, duration,
easing_curve)
self.holder = self.anim # needed for qt to work
self.parent = parent
self.tour = tour
self.frames = None
self.color_top = QColor.fromRgb(230, 230, 230)
self.color_back = QColor.fromRgb(255, 255, 255)
self.offset_shadow = 0
self.fixed_width = 300
self.key_pressed = None
self.setAttribute(Qt.WA_TranslucentBackground)
self.setWindowFlags(Qt.Dialog | Qt.FramelessWindowHint |
Qt.WindowStaysOnTopHint)
self.setModal(False)
# Widgets
def toolbutton(icon):
bt = QToolButton()
bt.setAutoRaise(True)
bt.setIcon(icon)
return bt
self.button_close = toolbutton(ima.icon("tour.close"))
self.button_home = toolbutton(ima.icon("tour.home"))
self.button_previous = toolbutton(ima.icon("tour.previous"))
self.button_end = toolbutton(ima.icon("tour.end"))
self.button_next = toolbutton(ima.icon("tour.next"))
self.button_run = QPushButton(_('Run code'))
self.button_disable = None
self.button_current = QToolButton()
self.label_image = QLabel()
self.label_title = QLabel()
self.combo_title = QComboBox()
self.label_current = QLabel()
self.label_content = QLabel()
self.label_content.setMinimumWidth(self.fixed_width)
self.label_content.setMaximumWidth(self.fixed_width)
self.label_current.setAlignment(Qt.AlignCenter)
self.label_content.setWordWrap(True)
self.widgets = [self.label_content, self.label_title,
self.label_current, self.combo_title,
self.button_close, self.button_run, self.button_next,
self.button_previous, self.button_end,
self.button_home, self.button_current]
arrow = get_image_path('hide.png')
self.stylesheet = '''QComboBox {
padding-left: 5px;
background-color: rgbs(230,230,230,100%);
border-width: 0px;
border-radius: 0px;
min-height:20px;
max-height:20px;
}
QComboBox::drop-down {
subcontrol-origin: padding;
subcontrol-position: top left;
border-width: 0px;
}
QComboBox::down-arrow {
image: url(''' + arrow + ''');
}
'''
# Windows fix, slashes should be always in unix-style
self.stylesheet = self.stylesheet.replace('\\', '/')
self.setFocusPolicy(Qt.StrongFocus)
for widget in self.widgets:
widget.setFocusPolicy(Qt.NoFocus)
widget.setStyleSheet(self.stylesheet)
layout_top = QHBoxLayout()
layout_top.addWidget(self.combo_title)
layout_top.addStretch()
layout_top.addWidget(self.button_close)
layout_top.addSpacerItem(QSpacerItem(self.offset_shadow,
self.offset_shadow))
layout_content = QHBoxLayout()
layout_content.addWidget(self.label_content)
layout_content.addWidget(self.label_image)
layout_content.addSpacerItem(QSpacerItem(5, 5))
layout_run = QHBoxLayout()
#.........这里部分代码省略.........
示例2: DimensionMDE
# 需要导入模块: from qtpy.QtWidgets import QLabel [as 别名]
# 或者: from qtpy.QtWidgets.QLabel import setMinimumWidth [as 别名]
class DimensionMDE(Dimension):
binningChanged = Signal()
"""
MDEventWorkspace has additional properties for either number_of_bins or thickness
from mantidqt.widgets.sliceviewer.dimensionwidget import DimensionMDE
from qtpy.QtWidgets import QApplication
app = QApplication([])
window = DimensionMDE({'minimum':-1.1, 'number_of_bins':11, 'width':0.2, 'name':'Dim0', 'units':'A'})
window.show()
app.exec_()
"""
def __init__(self, dim_info, number=0, state=State.NONE, parent=None):
# hack in a number_of_bins for MDEventWorkspace
dim_info['number_of_bins'] = 1000
dim_info['width'] = (dim_info['maximum']-dim_info['minimum'])/1000
self.spinBins = QSpinBox()
self.spinBins.setRange(2,9999)
self.spinBins.setValue(100)
self.spinBins.hide()
self.spinBins.setMinimumWidth(110)
self.spinThick = QDoubleSpinBox()
self.spinThick.setRange(0.001,999)
self.spinThick.setValue(0.1)
self.spinThick.setSingleStep(0.1)
self.spinThick.setDecimals(3)
self.spinThick.setMinimumWidth(110)
self.rebinLabel = QLabel("thick")
self.rebinLabel.setMinimumWidth(44)
super(DimensionMDE, self).__init__(dim_info, number, state, parent)
self.spinBins.valueChanged.connect(self.binningChanged)
self.spinThick.valueChanged.connect(self.valueChanged)
self.layout.addWidget(self.spinBins)
self.layout.addWidget(self.spinThick)
self.layout.addWidget(self.rebinLabel)
def get_bins(self):
return int(self.spinBins.value())
def get_thickness(self):
return float(self.spinThick.value())
def set_state(self, state):
super(DimensionMDE, self).set_state(state)
if self.state == State.X:
self.spinBins.show()
self.spinThick.hide()
self.rebinLabel.setText('bins')
elif self.state == State.Y:
self.spinBins.show()
self.spinThick.hide()
self.rebinLabel.setText('bins')
elif self.state == State.NONE:
self.spinBins.hide()
self.spinThick.show()
self.rebinLabel.setText('thick')
else:
self.spinBins.hide()
self.spinThick.hide()
self.rebinLabel.hide()
示例3: BaseTimerStatus
# 需要导入模块: from qtpy.QtWidgets import QLabel [as 别名]
# 或者: from qtpy.QtWidgets.QLabel import setMinimumWidth [as 别名]
class BaseTimerStatus(StatusBarWidget):
"""Status bar widget base for widgets that update based on timers."""
TITLE = None
TIP = None
def __init__(self, parent, statusbar):
"""Status bar widget base for widgets that update based on timers."""
super(BaseTimerStatus, self).__init__(parent, statusbar)
# Widgets
self.label = QLabel(self.TITLE)
self.value = QLabel()
# Widget setup
self.setToolTip(self.TIP)
self.value.setAlignment(Qt.AlignRight)
self.value.setFont(self.label_font)
fm = self.value.fontMetrics()
self.value.setMinimumWidth(fm.width('000%'))
# Layout
layout = self.layout()
layout.addWidget(self.label)
layout.addWidget(self.value)
layout.addSpacing(20)
# Setup
if self.is_supported():
self.timer = QTimer()
self.timer.timeout.connect(self.update_label)
self.timer.start(2000)
else:
self.timer = None
self.hide()
def set_interval(self, interval):
"""Set timer interval (ms)."""
if self.timer is not None:
self.timer.setInterval(interval)
def import_test(self):
"""Raise ImportError if feature is not supported."""
raise NotImplementedError
def is_supported(self):
"""Return True if feature is supported."""
try:
self.import_test()
return True
except ImportError:
return False
def get_value(self):
"""Return value (e.g. CPU or memory usage)."""
raise NotImplementedError
def update_label(self):
"""Update status label widget, if widget is visible."""
if self.isVisible():
self.value.setText('%d %%' % self.get_value())
示例4: SelectSmoothing
# 需要导入模块: from qtpy.QtWidgets import QLabel [as 别名]
# 或者: from qtpy.QtWidgets.QLabel 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)
#.........这里部分代码省略.........