本文整理汇总了Python中AnyQt.QtWidgets.QLabel类的典型用法代码示例。如果您正苦于以下问题:Python QLabel类的具体用法?Python QLabel怎么用?Python QLabel使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了QLabel类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_dock_standalone
def test_dock_standalone(self):
widget = QWidget()
layout = QHBoxLayout()
widget.setLayout(layout)
layout.addStretch(1)
widget.show()
dock = CollapsibleDockWidget()
layout.addWidget(dock)
list_view = QListView()
list_view.setModel(QStringListModel(["a", "b"], list_view))
label = QLabel("A label. ")
label.setWordWrap(True)
dock.setExpandedWidget(label)
dock.setCollapsedWidget(list_view)
dock.setExpanded(True)
self.app.processEvents()
def toogle():
dock.setExpanded(not dock.expanded())
self.singleShot(2000, toogle)
toogle()
self.app.exec_()
示例2: __setupUi
def __setupUi(self):
layout = QVBoxLayout()
label = QLabel(self)
pixmap, _ = config.splash_screen()
label.setPixmap(pixmap)
layout.addWidget(label, Qt.AlignCenter)
name = QApplication.applicationName()
version = QApplication.applicationVersion()
text = ABOUT_TEMPLATE.format(
name=escape(name),
version=escape(version),
)
# TODO: Also list all known add-on versions??.
text_label = QLabel(text)
layout.addWidget(text_label, Qt.AlignCenter)
buttons = QDialogButtonBox(
QDialogButtonBox.Close, Qt.Horizontal, self)
layout.addWidget(buttons)
buttons.rejected.connect(self.accept)
layout.setSizeConstraint(QVBoxLayout.SetFixedSize)
self.setLayout(layout)
示例3: __init__
def __init__(self, parent=None, icon=QIcon(), text="", wordWrap=False,
textFormat=Qt.AutoText, standardButtons=NoButton, **kwargs):
super().__init__(parent, **kwargs)
self.__text = text
self.__icon = QIcon()
self.__wordWrap = wordWrap
self.__standardButtons = MessageWidget.NoButton
self.__buttons = []
layout = QHBoxLayout()
layout.setContentsMargins(8, 0, 8, 0)
self.__iconlabel = QLabel(objectName="icon-label")
self.__iconlabel.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)
self.__textlabel = QLabel(objectName="text-label", text=text,
wordWrap=wordWrap, textFormat=textFormat)
if sys.platform == "darwin":
self.__textlabel.setAttribute(Qt.WA_MacSmallSize)
layout.addWidget(self.__iconlabel)
layout.addWidget(self.__textlabel)
self.setLayout(layout)
self.setIcon(icon)
self.setStandardButtons(standardButtons)
示例4: __setupUi
def __setupUi(self):
layout = QVBoxLayout()
label = QLabel(self)
pixmap, _ = config.splash_screen()
label.setPixmap(pixmap)
layout.addWidget(label, Qt.AlignCenter)
try:
from Orange.version import version
from Orange.version import git_revision
except ImportError:
dist = pkg_resources.get_distribution("Orange3")
version = dist.version
git_revision = "Unknown"
text = ABOUT_TEMPLATE.format(version=version,
git_revision=git_revision[:7])
# TODO: Also list all known add-on versions.
text_label = QLabel(text)
layout.addWidget(text_label, Qt.AlignCenter)
buttons = QDialogButtonBox(QDialogButtonBox.Close,
Qt.Horizontal,
self)
layout.addWidget(buttons)
buttons.rejected.connect(self.accept)
layout.setSizeConstraint(QVBoxLayout.SetFixedSize)
self.setLayout(layout)
示例5: __setupUi
def __setupUi(self):
vlayout = QVBoxLayout()
vlayout.setContentsMargins(0, 0, 0, 0)
top_layout = QVBoxLayout(objectName="top-layout")
margin = self.__margin
top_layout.setContentsMargins(margin, margin, margin, margin)
# Optional heading label
self.__heading = QLabel(
self, objectName="heading", visible=False
)
# Horizontal row with full text description and a large preview
# image.
hlayout = QHBoxLayout()
hlayout.setContentsMargins(0, 0, 0, 0)
self.__label = QLabel(
self, objectName="description-label",
wordWrap=True, alignment=Qt.AlignTop | Qt.AlignLeft
)
self.__label.setWordWrap(True)
self.__label.setFixedSize(220, PREVIEW_SIZE[1])
self.__label.setMinimumWidth(PREVIEW_SIZE[0] // 2)
self.__label.setMaximumHeight(PREVIEW_SIZE[1])
self.__image = QSvgWidget(self, objectName="preview-image")
self.__image.setFixedSize(*PREVIEW_SIZE)
self.__imageFrame = DropShadowFrame(self)
self.__imageFrame.setWidget(self.__image)
hlayout.addWidget(self.__label)
hlayout.addWidget(self.__image)
# Path text below the description and image
path_layout = QHBoxLayout()
path_layout.setContentsMargins(0, 0, 0, 0)
path_label = QLabel("<b>{0!s}</b>".format(self.tr("Path:")), self,
objectName="path-label")
self.__path = TextLabel(self, objectName="path-text")
path_layout.addWidget(path_label)
path_layout.addWidget(self.__path)
top_layout.addWidget(self.__heading)
top_layout.addLayout(hlayout)
top_layout.addLayout(path_layout)
vlayout.addLayout(top_layout)
# An list view with small preview icons.
self.__previewList = LinearIconView(
objectName="preview-list-view",
wordWrap=True
)
self.__previewList.doubleClicked.connect(self.__onDoubleClicked)
vlayout.addWidget(self.__previewList)
self.setLayout(vlayout)
示例6: __init__
def __init__(self, master):
QWidget.__init__(self)
gui.OWComponent.__init__(self, master)
self.master = master
self.preprocessor = master.preprocessor
self.value = getattr(self.preprocessor, self.attribute)
# Title bar.
title_holder = QWidget()
title_holder.setSizePolicy(QSizePolicy.MinimumExpanding,
QSizePolicy.Fixed)
title_holder.setStyleSheet("""
.QWidget {
background: qlineargradient( x1:0 y1:0, x2:0 y2:1,
stop:0 #F8F8F8, stop:1 #C8C8C8);
border-bottom: 1px solid #B3B3B3;
}
""")
self.titleArea = QHBoxLayout()
self.titleArea.setContentsMargins(10, 5, 10, 5)
self.titleArea.setSpacing(0)
title_holder.setLayout(self.titleArea)
self.title_label = QLabel(self.title)
self.title_label.mouseDoubleClickEvent = self.on_toggle
self.title_label.setStyleSheet('font-size: 12px; border: 2px solid red;')
self.titleArea.addWidget(self.title_label)
self.off_label = QLabel('[disabled]')
self.off_label.setStyleSheet('color: #B0B0B0; margin-left: 5px;')
self.titleArea.addWidget(self.off_label)
self.off_label.hide()
self.titleArea.addStretch()
# Root.
self.rootArea = QVBoxLayout()
self.rootArea.setContentsMargins(0, 0, 0, 0)
self.rootArea.setSpacing(0)
self.setLayout(self.rootArea)
self.rootArea.addWidget(title_holder)
self.contents = QWidget()
contentArea = QVBoxLayout()
contentArea.setContentsMargins(15, 10, 15, 10)
self.contents.setLayout(contentArea)
self.rootArea.addWidget(self.contents)
self.method_layout = self.Layout()
self.setup_method_layout()
self.contents.layout().addLayout(self.method_layout)
if self.toggle_enabled:
self.on_off_button = OnOffButton(enabled=self.enabled)
self.on_off_button.stateChanged.connect(self.on_toggle)
self.on_off_button.setContentsMargins(0, 0, 0, 0)
self.titleArea.addWidget(self.on_off_button)
self.display_widget(update_master_width=False)
示例7: __init__
def __init__(self, parent=None, openExternalLinks=False,
defaultStyleSheet="", **kwargs):
kwargs.setdefault(
"sizePolicy",
QSizePolicy(QSizePolicy.Minimum, QSizePolicy.Minimum)
)
super().__init__(parent, **kwargs)
self.__openExternalLinks = openExternalLinks # type: bool
self.__messages = OrderedDict() # type: Dict[Hashable, Message]
#: The full (joined all messages text - rendered as html), displayed
#: in a tooltip.
self.__fulltext = ""
#: The full text displayed in a popup. Is empty if the message is
#: short
self.__popuptext = ""
#: Leading icon
self.__iconwidget = IconWidget(
sizePolicy=QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)
)
#: Inline message text
self.__textlabel = QLabel(
wordWrap=False,
textInteractionFlags=Qt.LinksAccessibleByMouse,
openExternalLinks=self.__openExternalLinks,
sizePolicy=QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Minimum)
)
#: Indicator that extended contents are accessible with a click on the
#: widget.
self.__popupicon = QLabel(
sizePolicy=QSizePolicy(QSizePolicy.Maximum, QSizePolicy.Maximum),
text="\N{VERTICAL ELLIPSIS}",
visible=False,
)
self.__textlabel.linkActivated.connect(self.linkActivated)
self.__textlabel.linkHovered.connect(self.linkHovered)
self.setLayout(QHBoxLayout())
self.layout().setContentsMargins(2, 1, 2, 1)
self.layout().setSpacing(0)
self.layout().addWidget(self.__iconwidget)
self.layout().addSpacing(4)
self.layout().addWidget(self.__textlabel)
self.layout().addWidget(self.__popupicon)
self.__textlabel.setAttribute(Qt.WA_MacSmallSize)
self.__defaultStyleSheet = defaultStyleSheet
self.anim = QPropertyAnimation(self.__iconwidget, b"opacity")
self.anim.setDuration(350)
self.anim.setStartValue(1)
self.anim.setKeyValueAt(0.5, 0)
self.anim.setEndValue(1)
self.anim.setEasingCurve(QEasingCurve.OutQuad)
self.anim.setLoopCount(5)
示例8: update_legend
def update_legend(self, colors, labels):
layout = self.legend.layout()
while self.legend_items:
w = self.legend_items.pop()
layout.removeWidget(w)
w.deleteLater()
for row, (color, label) in enumerate(zip(colors, labels)):
icon = QLabel()
p = QPixmap(12, 12)
p.fill(color)
icon.setPixmap(p)
label = QLabel(label)
layout.addWidget(icon, row, 0)
layout.addWidget(label, row, 1, alignment=Qt.AlignLeft)
self.legend_items += (icon, label)
示例9: __init__
def __init__(self, parent=None):
super().__init__(parent)
self.errorLabel = QLabel(
textInteractionFlags=Qt.TextSelectableByMouse,
wordWrap=True,
)
self.errorLabel.setSizePolicy(
QSizePolicy.Expanding,
QSizePolicy.Expanding
)
self.controlArea.layout().addWidget(self.errorLabel)
示例10: DummyOWWidget
class DummyOWWidget(widget.OWWidget):
"""
Dummy OWWidget used to report import/init errors in the canvas.
"""
name = "Placeholder"
# Fake settings handler that preserves the settings
class DummySettingsHandler(settings.SettingsHandler):
def pack_data(self, widget):
return getattr(widget, "_settings", {})
def initialize(self, widget, data=None):
widget._settings = data
settings.SettingsHandler.initialize(self, widget, None)
# specifically disable persistent global defaults
def write_defaults(self):
pass
def read_defaults(self):
pass
settingsHandler = DummySettingsHandler()
want_main_area = False
def __init__(self, parent=None):
super().__init__(parent)
self.errorLabel = QLabel(
textInteractionFlags=Qt.TextSelectableByMouse,
wordWrap=True,
)
self.errorLabel.setSizePolicy(
QSizePolicy.Expanding,
QSizePolicy.Expanding
)
self.controlArea.layout().addWidget(self.errorLabel)
def setErrorMessage(self, message):
self.errorLabel.setText(message)
self.error(message)
示例11: mousePressEvent
def mousePressEvent(self, event):
if event.button() == Qt.LeftButton:
if self.__popuptext:
popup = QMenu(self)
label = QLabel(
self, textInteractionFlags=Qt.TextBrowserInteraction,
openExternalLinks=self.__openExternalLinks,
)
label.setText(self.__styled(self.__defaultStyleSheet,
self.__popuptext))
label.linkActivated.connect(self.linkActivated)
label.linkHovered.connect(self.linkHovered)
action = QWidgetAction(popup)
action.setDefaultWidget(label)
popup.addAction(action)
popup.popup(event.globalPos(), action)
event.accept()
return
else:
super().mousePressEvent(event)
示例12: setupUi
def setupUi(self):
self.setLayout(QVBoxLayout())
self.layout().setContentsMargins(0, 0, 0, 0)
self.layout().setSpacing(0)
self.__mainLayout = QVBoxLayout()
self.__mainLayout.setContentsMargins(0, 40, 0, 40)
self.__mainLayout.setSpacing(65)
self.layout().addLayout(self.__mainLayout)
self.setStyleSheet(WELCOME_WIDGET_BUTTON_STYLE)
bottom_bar = QWidget(objectName="bottom-bar")
bottom_bar_layout = QHBoxLayout()
bottom_bar_layout.setContentsMargins(20, 10, 20, 10)
bottom_bar.setLayout(bottom_bar_layout)
bottom_bar.setSizePolicy(QSizePolicy.MinimumExpanding,
QSizePolicy.Maximum)
check = QCheckBox(self.tr("Show at startup"), bottom_bar)
check.setChecked(False)
self.__showAtStartupCheck = check
feedback = QLabel(
'<a href="http://orange.biolab.si/survey/long.html">Help us improve!</a>')
feedback.setTextInteractionFlags(Qt.TextBrowserInteraction)
feedback.setOpenExternalLinks(True)
bottom_bar_layout.addWidget(check, alignment=Qt.AlignVCenter | \
Qt.AlignLeft)
bottom_bar_layout.addWidget(feedback, alignment=Qt.AlignVCenter | \
Qt.AlignRight)
self.layout().addWidget(bottom_bar, alignment=Qt.AlignBottom,
stretch=1)
self.setSizeGripEnabled(False)
self.setFixedSize(620, 390)
示例13: __setupUi
def __setupUi(self):
vlayout = QVBoxLayout()
vlayout.setContentsMargins(0, 0, 0, 0)
top_layout = QHBoxLayout()
top_layout.setContentsMargins(12, 12, 12, 12)
# Top row with full text description and a large preview
# image.
self.__label = QLabel(self, objectName="description-label",
wordWrap=True,
alignment=Qt.AlignTop | Qt.AlignLeft)
self.__label.setWordWrap(True)
self.__label.setFixedSize(220, PREVIEW_SIZE[1])
self.__image = QSvgWidget(self, objectName="preview-image")
self.__image.setFixedSize(*PREVIEW_SIZE)
self.__imageFrame = DropShadowFrame(self)
self.__imageFrame.setWidget(self.__image)
# Path text below the description and image
path_layout = QHBoxLayout()
path_layout.setContentsMargins(12, 0, 12, 0)
path_label = QLabel("<b>{0!s}</b>".format(self.tr("Path:")), self,
objectName="path-label")
self.__path = TextLabel(self, objectName="path-text")
path_layout.addWidget(path_label)
path_layout.addWidget(self.__path)
self.__selectAction = \
QAction(self.tr("Select"), self,
objectName="select-action",
)
top_layout.addWidget(self.__label, 1,
alignment=Qt.AlignTop | Qt.AlignLeft)
top_layout.addWidget(self.__image, 1,
alignment=Qt.AlignTop | Qt.AlignRight)
vlayout.addLayout(top_layout)
vlayout.addLayout(path_layout)
# An list view with small preview icons.
self.__previewList = LinearIconView(objectName="preview-list-view")
self.__previewList.doubleClicked.connect(self.__onDoubleClicked)
vlayout.addWidget(self.__previewList)
self.setLayout(vlayout)
示例14: test_dock_standalone
def test_dock_standalone(self):
widget = QWidget()
layout = QHBoxLayout()
widget.setLayout(layout)
layout.addStretch(1)
widget.show()
dock = CollapsibleDockWidget()
layout.addWidget(dock)
list_view = QListView()
list_view.setModel(QStringListModel(["a", "b"], list_view))
label = QLabel("A label. ")
label.setWordWrap(True)
dock.setExpandedWidget(label)
dock.setCollapsedWidget(list_view)
dock.setExpanded(True)
dock.setExpanded(False)
timer = QTimer(dock, interval=200)
timer.timeout.connect(lambda: dock.setExpanded(not dock.expanded()))
timer.start()
示例15: __init__
def __init__(self):
super().__init__()
self.domain = None
self.dataset = None
self.clf_dataset = None
self.color_label = QLabel("Target class: ")
combo = self.color_combo = gui.OrangeComboBox()
combo.setSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.Fixed)
combo.setSizeAdjustPolicy(
QComboBox.AdjustToMinimumContentsLengthWithIcon)
combo.setMinimumContentsLength(8)
combo.activated[int].connect(self.color_changed)
self.display_box.layout().addRow(self.color_label, combo)