本文整理汇总了Python中AnyQt.QtWidgets.QLabel.setOpenExternalLinks方法的典型用法代码示例。如果您正苦于以下问题:Python QLabel.setOpenExternalLinks方法的具体用法?Python QLabel.setOpenExternalLinks怎么用?Python QLabel.setOpenExternalLinks使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AnyQt.QtWidgets.QLabel
的用法示例。
在下文中一共展示了QLabel.setOpenExternalLinks方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setupUi
# 需要导入模块: from AnyQt.QtWidgets import QLabel [as 别名]
# 或者: from AnyQt.QtWidgets.QLabel import setOpenExternalLinks [as 别名]
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)
示例2: MessagesWidget
# 需要导入模块: from AnyQt.QtWidgets import QLabel [as 别名]
# 或者: from AnyQt.QtWidgets.QLabel import setOpenExternalLinks [as 别名]
class MessagesWidget(QWidget):
"""
An iconified multiple message display area.
`MessagesWidget` displays a short message along with an icon. If there
are multiple messages they are summarized. The user can click on the
widget to display the full message text in a popup view.
"""
#: Signal emitted when an embedded html link is clicked
#: (if `openExternalLinks` is `False`).
linkActivated = Signal(str)
#: Signal emitted when an embedded html link is hovered.
linkHovered = Signal(str)
Severity = Severity
#: General informative message.
Information = Severity.Information
#: A warning message severity.
Warning = Severity.Warning
#: An error message severity.
Error = Severity.Error
Message = Message
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
def sizeHint(self):
sh = super().sizeHint()
h = self.style().pixelMetric(QStyle.PM_SmallIconSize)
if all(m.isEmpty() for m in self.messages()):
sh.setWidth(0)
return sh.expandedTo(QSize(0, h + 2))
def minimumSizeHint(self):
msh = super().minimumSizeHint()
h = self.style().pixelMetric(QStyle.PM_SmallIconSize)
if all(m.isEmpty() for m in self.messages()):
msh.setWidth(0)
else:
msh.setWidth(h + 2)
return msh.expandedTo(QSize(0, h + 2))
def setOpenExternalLinks(self, state):
# type: (bool) -> None
"""
If `True` then `linkActivated` signal will be emitted when the user
clicks on an html link in a message, otherwise links are opened
using `QDesktopServices.openUrl`
"""
# TODO: update popup if open
self.__openExternalLinks = state
self.__textlabel.setOpenExternalLinks(state)
def openExternalLinks(self):
# type: () -> bool
"""
#.........这里部分代码省略.........