本文整理汇总了Python中qtpy.QtWidgets.QLabel.setStyleSheet方法的典型用法代码示例。如果您正苦于以下问题:Python QLabel.setStyleSheet方法的具体用法?Python QLabel.setStyleSheet怎么用?Python QLabel.setStyleSheet使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类qtpy.QtWidgets.QLabel
的用法示例。
在下文中一共展示了QLabel.setStyleSheet方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: SearchLineEdit
# 需要导入模块: from qtpy.QtWidgets import QLabel [as 别名]
# 或者: from qtpy.QtWidgets.QLabel import setStyleSheet [as 别名]
class SearchLineEdit(QLineEdit):
"""Line edit search widget with icon and remove all button"""
def __init__(self, parent=None, icon=True):
super(SearchLineEdit, self).__init__(parent)
self.setTextMargins(1, 0, 20, 0)
if icon:
self.setTextMargins(18, 0, 20, 0)
self._label = QLabel(self)
self._pixmap_icon = QPixmap(get_image_path('conda_search.png'))
self._label.setPixmap(self._pixmap_icon)
self._label.setStyleSheet('''border: 0px; padding-bottom: 0px;
padding-left: 2px;''')
self._pixmap = QPixmap(get_image_path('conda_del.png'))
self.button_clear = QToolButton(self)
self.button_clear.setIcon(QIcon(self._pixmap))
self.button_clear.setIconSize(QSize(18, 18))
self.button_clear.setCursor(Qt.ArrowCursor)
self.button_clear.setStyleSheet("""QToolButton
{background: transparent;
padding-right: 2px; border: none; margin:0px; }""")
self.button_clear.setVisible(False)
# Layout
self._layout = QHBoxLayout(self)
self._layout.addWidget(self.button_clear, 0, Qt.AlignRight)
self._layout.setSpacing(0)
self._layout.setContentsMargins(0, 2, 2, 0)
# Signals and slots
self.button_clear.clicked.connect(self.clear_text)
self.textChanged.connect(self._toggle_visibility)
self.textEdited.connect(self._toggle_visibility)
def _toggle_visibility(self):
""" """
if len(self.text()) == 0:
self.button_clear.setVisible(False)
else:
self.button_clear.setVisible(True)
def sizeHint(self):
return QSize(200, self._pixmap_icon.height())
# Public api
# ----------
def clear_text(self):
""" """
self.setText('')
self.setFocus()
示例2: __init__
# 需要导入模块: from qtpy.QtWidgets import QLabel [as 别名]
# 或者: from qtpy.QtWidgets.QLabel import setStyleSheet [as 别名]
def __init__(self, parent, username, password, token, remember=False,
remember_token=False):
QDialog.__init__(self, parent)
title = _("Sign in to Github")
self.resize(415, 375)
self.setWindowTitle(title)
self.setWindowFlags(
self.windowFlags() & ~Qt.WindowContextHelpButtonHint)
# Header
html = ('<html><head/><body><p align="center">'
'{title}</p></body></html>')
lbl_html = QLabel(html.format(title=title))
lbl_html.setStyleSheet('font-size: 16px;')
# Tabs
self.tabs = QTabWidget()
# Basic form layout
basic_form_layout = QFormLayout()
basic_form_layout.setContentsMargins(-1, 0, -1, -1)
basic_lbl_msg = QLabel(_("For regular users, i.e. users <b>without</b>"
" two-factor authentication enabled"))
basic_lbl_msg.setWordWrap(True)
basic_lbl_msg.setAlignment(Qt.AlignJustify)
lbl_user = QLabel(_("Username:"))
basic_form_layout.setWidget(0, QFormLayout.LabelRole, lbl_user)
self.le_user = QLineEdit()
self.le_user.textChanged.connect(self.update_btn_state)
basic_form_layout.setWidget(0, QFormLayout.FieldRole, self.le_user)
basic_form_layout.addRow("", QWidget())
lbl_password = QLabel(_("Password: "))
basic_form_layout.setWidget(2, QFormLayout.LabelRole, lbl_password)
self.le_password = QLineEdit()
self.le_password.setEchoMode(QLineEdit.Password)
self.le_password.textChanged.connect(self.update_btn_state)
basic_form_layout.setWidget(2, QFormLayout.FieldRole, self.le_password)
self.cb_remember = None
# Check if we are not in Python 2 and Linux because
# there's no keyring backend there
valid_py_os = not (PY2 and sys.platform.startswith('linux'))
if self.is_keyring_available() and valid_py_os:
self.cb_remember = QCheckBox(_("Remember me"))
self.cb_remember.setToolTip(_("Spyder will save your credentials "
"safely"))
self.cb_remember.setChecked(remember)
basic_form_layout.setWidget(4, QFormLayout.FieldRole,
self.cb_remember)
# Basic auth tab
basic_auth = QWidget()
basic_layout = QVBoxLayout()
basic_layout.addSpacerItem(QSpacerItem(QSpacerItem(0, 8)))
basic_layout.addWidget(basic_lbl_msg)
basic_layout.addSpacerItem(
QSpacerItem(QSpacerItem(0, 50, vPolicy=QSizePolicy.Expanding)))
basic_layout.addLayout(basic_form_layout)
basic_layout.addSpacerItem(
QSpacerItem(QSpacerItem(0, 50, vPolicy=QSizePolicy.Expanding)))
basic_auth.setLayout(basic_layout)
self.tabs.addTab(basic_auth, _("Password Only"))
# Token form layout
token_form_layout = QFormLayout()
token_form_layout.setContentsMargins(-1, 0, -1, -1)
token_lbl_msg = QLabel(_("For users <b>with</b> two-factor "
"authentication enabled, or who prefer a "
"per-app token authentication.<br><br>"
"You can go <b><a href=\"{}\">here</a></b> "
"and click \"Generate token\" at the bottom "
"to create a new token to use for this, with "
"the appropriate permissions.").format(
TOKEN_URL))
token_lbl_msg.setOpenExternalLinks(True)
token_lbl_msg.setWordWrap(True)
token_lbl_msg.setAlignment(Qt.AlignJustify)
lbl_token = QLabel("Token: ")
token_form_layout.setWidget(1, QFormLayout.LabelRole, lbl_token)
self.le_token = QLineEdit()
self.le_token.setEchoMode(QLineEdit.Password)
self.le_token.textChanged.connect(self.update_btn_state)
token_form_layout.setWidget(1, QFormLayout.FieldRole, self.le_token)
self.cb_remember_token = None
# Same validation as with cb_remember
if self.is_keyring_available() and valid_py_os:
self.cb_remember_token = QCheckBox(_("Remember token"))
self.cb_remember_token.setToolTip(_("Spyder will save your "
"token safely"))
self.cb_remember_token.setChecked(remember_token)
token_form_layout.setWidget(3, QFormLayout.FieldRole,
self.cb_remember_token)
#.........这里部分代码省略.........
示例3: __init__
# 需要导入模块: from qtpy.QtWidgets import QLabel [as 别名]
# 或者: from qtpy.QtWidgets.QLabel import setStyleSheet [as 别名]
def __init__(self, parent=None, is_report=False):
QDialog.__init__(self, parent)
self.is_report = is_report
self.setWindowTitle(_("Issue reporter"))
self.setModal(True)
# To save the traceback sent to the internal console
self.error_traceback = ""
# Dialog main label
if self.is_report:
title = _("Please fill the following information")
else:
title = _("Spyder has encountered an internal problem!")
main_label = QLabel(
_("<h3>{title}</h3>"
"Before reporting this problem, <i>please</i> consult our "
"comprehensive "
"<b><a href=\"{trouble_url}\">Troubleshooting Guide</a></b> "
"which should help solve most issues, and search for "
"<b><a href=\"{project_url}\">known bugs</a></b> "
"matching your error message or problem description for a "
"quicker solution."
).format(title=title, trouble_url=__trouble_url__,
project_url=__project_url__))
main_label.setOpenExternalLinks(True)
main_label.setWordWrap(True)
main_label.setAlignment(Qt.AlignJustify)
main_label.setStyleSheet('font-size: 12px;')
# Issue title
self.title = QLineEdit()
self.title.textChanged.connect(self._contents_changed)
self.title_chars_label = QLabel(_("{} more characters "
"to go...").format(TITLE_MIN_CHARS))
form_layout = QFormLayout()
form_layout.setFieldGrowthPolicy(QFormLayout.ExpandingFieldsGrow)
red_asterisk = '<font color="Red">*</font>'
title_label = QLabel(_("<b>Title</b>: {}").format(red_asterisk))
form_layout.setWidget(0, QFormLayout.LabelRole, title_label)
form_layout.setWidget(0, QFormLayout.FieldRole, self.title)
# Description
steps_header = QLabel(
_("<b>Steps to reproduce:</b> {}").format(red_asterisk))
steps_text = QLabel(_("Please enter a detailed step-by-step "
"description (in English) of what led up to "
"the problem below. Issue reports without a "
"clear way to reproduce them will be closed."))
steps_text.setWordWrap(True)
steps_text.setAlignment(Qt.AlignJustify)
steps_text.setStyleSheet('font-size: 12px;')
# Field to input the description of the problem
self.input_description = DescriptionWidget(self)
# Only allow to submit to Github if we have a long enough description
self.input_description.textChanged.connect(self._contents_changed)
# Widget to show errors
self.details = ShowErrorWidget(self)
self.details.set_pythonshell_font(get_font())
self.details.hide()
# Label to show missing chars
self.initial_chars = len(self.input_description.toPlainText())
self.desc_chars_label = QLabel(_("{} more characters "
"to go...").format(DESC_MIN_CHARS))
# Checkbox to dismiss future errors
self.dismiss_box = QCheckBox(_("Hide all future errors during this "
"session"))
if self.is_report:
self.dismiss_box.hide()
# Dialog buttons
gh_icon = ima.icon('github')
self.submit_btn = QPushButton(gh_icon, _('Submit to Github'))
self.submit_btn.setEnabled(False)
self.submit_btn.clicked.connect(self._submit_to_github)
self.details_btn = QPushButton(_('Show details'))
self.details_btn.clicked.connect(self._show_details)
if self.is_report:
self.details_btn.hide()
self.close_btn = QPushButton(_('Close'))
if self.is_report:
self.close_btn.clicked.connect(self.reject)
# Buttons layout
buttons_layout = QHBoxLayout()
buttons_layout.addWidget(self.submit_btn)
buttons_layout.addWidget(self.details_btn)
buttons_layout.addWidget(self.close_btn)
# Main layout
layout = QVBoxLayout()
layout.addWidget(main_label)
#.........这里部分代码省略.........