本文整理汇总了Python中qutebrowser.config.style.get_stylesheet函数的典型用法代码示例。如果您正苦于以下问题:Python get_stylesheet函数的具体用法?Python get_stylesheet怎么用?Python get_stylesheet使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_stylesheet函数的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: set_mode_active
def set_mode_active(self, mode, val):
"""Setter for self.{insert,command,caret}_active.
Re-set the stylesheet after setting the value, so everything gets
updated by Qt properly.
"""
if mode == usertypes.KeyMode.insert:
log.statusbar.debug("Setting insert_active to {}".format(val))
self._insert_active = val
if mode == usertypes.KeyMode.command:
log.statusbar.debug("Setting command_active to {}".format(val))
self._command_active = val
elif mode == usertypes.KeyMode.caret:
webview = objreg.get('tabbed-browser', scope='window',
window=self._win_id).currentWidget()
log.statusbar.debug("Setting caret_mode - val {}, selection "
"{}".format(val, webview.selection_enabled))
if val:
if webview.selection_enabled:
self._set_mode_text("{} selection".format(mode.name))
self._caret_mode = CaretMode.selection
else:
self._set_mode_text(mode.name)
self._caret_mode = CaretMode.on
else:
self._caret_mode = CaretMode.off
self.setStyleSheet(style.get_stylesheet(self.STYLESHEET))
开发者ID:Konubinix,项目名称:qutebrowser,代码行数:27,代码来源:bar.py
示例2: __init__
def __init__(self, level, text, parent=None):
super().__init__(text, parent)
self.setAttribute(Qt.WA_StyledBackground, True)
stylesheet = """
padding-top: 2px;
padding-bottom: 2px;
"""
if level == usertypes.MessageLevel.error:
stylesheet += """
background-color: {{ color['messages.bg.error'] }};
color: {{ color['messages.fg.error'] }};
font: {{ font['messages.error'] }};
border-bottom: 1px solid {{ color['messages.border.error'] }};
"""
elif level == usertypes.MessageLevel.warning:
stylesheet += """
background-color: {{ color['messages.bg.warning'] }};
color: {{ color['messages.fg.warning'] }};
font: {{ font['messages.warning'] }};
border-bottom:
1px solid {{ color['messages.border.warning'] }};
"""
elif level == usertypes.MessageLevel.info:
stylesheet += """
background-color: {{ color['messages.bg.info'] }};
color: {{ color['messages.fg.info'] }};
font: {{ font['messages.info'] }};
border-bottom: 1px solid {{ color['messages.border.info'] }}
"""
else: # pragma: no cover
raise ValueError("Invalid level {!r}".format(level))
# We don't bother with set_register_stylesheet here as it's short-lived
# anyways.
self.setStyleSheet(style.get_stylesheet(stylesheet))
开发者ID:haitaka,项目名称:qutebrowser,代码行数:34,代码来源:messageview.py
示例3: set_mode_active
def set_mode_active(self, mode, val):
"""Setter for self.{insert,command,caret}_active.
Re-set the stylesheet after setting the value, so everything gets
updated by Qt properly.
"""
if mode == usertypes.KeyMode.insert:
log.statusbar.debug("Setting insert flag to {}".format(val))
self._color_flags.insert = val
if mode == usertypes.KeyMode.command:
log.statusbar.debug("Setting command flag to {}".format(val))
self._color_flags.command = val
elif mode in [usertypes.KeyMode.prompt, usertypes.KeyMode.yesno]:
log.statusbar.debug("Setting prompt flag to {}".format(val))
self._color_flags.prompt = val
elif mode == usertypes.KeyMode.caret:
tab = objreg.get('tabbed-browser', scope='window',
window=self._win_id).currentWidget()
log.statusbar.debug("Setting caret flag - val {}, selection "
"{}".format(val, tab.caret.selection_enabled))
if val:
if tab.caret.selection_enabled:
self._set_mode_text("{} selection".format(mode.name))
self._color_flags.caret = ColorFlags.CaretMode.selection
else:
self._set_mode_text(mode.name)
self._color_flags.caret = ColorFlags.CaretMode.on
else:
self._color_flags.caret = ColorFlags.CaretMode.off
self.setStyleSheet(style.get_stylesheet(self.STYLESHEET))
开发者ID:phansch,项目名称:qutebrowser,代码行数:30,代码来源:bar.py
示例4: _set_prompt_active
def _set_prompt_active(self, val):
"""Setter for self.prompt_active.
Re-set the stylesheet after setting the value, so everything gets
updated by Qt properly.
"""
log.statusbar.debug("Setting prompt_active to {}".format(val))
self._prompt_active = val
self.setStyleSheet(style.get_stylesheet(self.STYLESHEET))
开发者ID:Konubinix,项目名称:qutebrowser,代码行数:9,代码来源:bar.py
示例5: test_get_stylesheet
def test_get_stylesheet(config_stub):
config_stub.data = {
'colors': {'completion.bg': 'black'},
'fonts': {'completion': 'foo'},
'foo': {'bar': 'baz'},
}
template = "{{ color['completion.bg'] }}\n{{ font['completion'] }}"
rendered = style.get_stylesheet(template)
assert rendered == 'background-color: black;\nfont: foo;'
开发者ID:ProtractorNinja,项目名称:qutebrowser,代码行数:9,代码来源:test_style.py
示例6: _update_url
def _update_url(self):
"""Update the displayed URL if the url or the hover url changed."""
if self._hover_url is not None:
self.setText(self._hover_url)
self._urltype = UrlType.hover
elif self._normal_url is not None:
self.setText(self._normal_url)
self._urltype = self._normal_url_type
else:
self.setText('')
self._urltype = UrlType.normal
self.setStyleSheet(style.get_stylesheet(self.STYLESHEET))
开发者ID:larryhynes,项目名称:qutebrowser,代码行数:12,代码来源:url.py
示例7: test_get_stylesheet
def test_get_stylesheet(config_stub, template, expected):
config_stub.data = {
'colors': {
'completion.bg': 'black',
'completion.fg': 'red',
},
'fonts': {
'completion': 'foo',
},
'foo': {'bar': 'baz'},
}
rendered = style.get_stylesheet(template)
assert rendered == expected
开发者ID:AdaJass,项目名称:qutebrowser,代码行数:13,代码来源:test_style.py
示例8: _get_textdoc
def _get_textdoc(self, index):
"""Create the QTextDocument of an item.
Args:
index: The QModelIndex of the item to draw.
"""
# FIXME we probably should do eliding here. See
# qcommonstyle.cpp:viewItemDrawText
# https://github.com/The-Compiler/qutebrowser/issues/118
text_option = QTextOption()
if self._opt.features & QStyleOptionViewItem.WrapText:
text_option.setWrapMode(QTextOption.WordWrap)
else:
text_option.setWrapMode(QTextOption.ManualWrap)
text_option.setTextDirection(self._opt.direction)
text_option.setAlignment(QStyle.visualAlignment(
self._opt.direction, self._opt.displayAlignment))
if self._doc is not None:
self._doc.deleteLater()
self._doc = QTextDocument(self)
self._doc.setDefaultFont(self._opt.font)
self._doc.setDefaultTextOption(text_option)
self._doc.setDefaultStyleSheet(style.get_stylesheet("""
.highlight {
color: {{ color['completion.match.fg'] }};
}
"""))
self._doc.setDocumentMargin(2)
if index.parent().isValid():
pattern = index.model().pattern
columns_to_filter = index.model().srcmodel.columns_to_filter
if index.column() in columns_to_filter and pattern:
repl = r'<span class="highlight">\g<0></span>'
text = re.sub(re.escape(pattern).replace(r'\ ', r'|'),
repl, self._opt.text, flags=re.IGNORECASE)
self._doc.setHtml(text)
else:
self._doc.setPlainText(self._opt.text)
else:
self._doc.setHtml(
'<span style="font: {};">{}</span>'.format(
html.escape(config.get('fonts', 'completion.category')),
html.escape(self._opt.text)))
开发者ID:Dietr1ch,项目名称:qutebrowser,代码行数:45,代码来源:completiondelegate.py
示例9: _set_error
def _set_error(self, val):
"""Setter for self.error, so it can be used as Qt property.
Re-set the stylesheet after setting the value, so everything gets
updated by Qt properly.
"""
if self._error == val:
# This gets called a lot (e.g. if the completion selection was
# changed), and setStyleSheet is relatively expensive, so we ignore
# this if there's nothing to change.
return
log.statusbar.debug("Setting error to {}".format(val))
self._error = val
self.setStyleSheet(style.get_stylesheet(self.STYLESHEET))
if val:
# If we got an error while command/prompt was shown, raise the text
# widget.
self._stack.setCurrentWidget(self.txt)
开发者ID:anweshknayak,项目名称:qutebrowser,代码行数:18,代码来源:bar.py
示例10: _get_textdoc
def _get_textdoc(self, index):
"""Create the QTextDocument of an item.
Args:
index: The QModelIndex of the item to draw.
"""
# FIXME we probably should do eliding here. See
# qcommonstyle.cpp:viewItemDrawText
text_option = QTextOption()
if self._opt.features & QStyleOptionViewItem.WrapText:
text_option.setWrapMode(QTextOption.WordWrap)
else:
text_option.setWrapMode(QTextOption.ManualWrap)
text_option.setTextDirection(self._opt.direction)
text_option.setAlignment(QStyle.visualAlignment(
self._opt.direction, self._opt.displayAlignment))
self._doc = QTextDocument(self)
if index.parent().isValid():
self._doc.setPlainText(self._opt.text)
else:
self._doc.setHtml('<b>{}</b>'.format(html.escape(self._opt.text)))
self._doc.setDefaultFont(self._opt.font)
self._doc.setDefaultTextOption(text_option)
self._doc.setDefaultStyleSheet(style.get_stylesheet("""
.highlight {
{{ color['completion.match.fg'] }}
}
"""))
self._doc.setDocumentMargin(2)
if index.column() == 0:
marks = index.data(basecompletion.Role.marks)
if marks is None:
return
for mark in marks:
cur = QTextCursor(self._doc)
cur.setPosition(mark[0])
cur.setPosition(mark[1], QTextCursor.KeepAnchor)
txt = cur.selectedText()
cur.removeSelectedText()
cur.insertHtml('<span class="highlight">{}</span>'.format(
html.escape(txt)))
开发者ID:har5ha,项目名称:qutebrowser,代码行数:43,代码来源:completiondelegate.py
示例11: _set_severity
def _set_severity(self, severity):
"""Set the severity for the current message.
Re-set the stylesheet after setting the value, so everything gets
updated by Qt properly.
Args:
severity: A Severity member.
"""
if self._severity == severity:
# This gets called a lot (e.g. if the completion selection was
# changed), and setStyleSheet is relatively expensive, so we ignore
# this if there's nothing to change.
return
log.statusbar.debug("Setting severity to {}".format(severity))
self._severity = severity
self.setStyleSheet(style.get_stylesheet(self.STYLESHEET))
if severity != Severity.normal:
# If we got an error while command/prompt was shown, raise the text
# widget.
self._stack.setCurrentWidget(self.txt)
开发者ID:Konubinix,项目名称:qutebrowser,代码行数:21,代码来源:bar.py
示例12: _get_textdoc
def _get_textdoc(self, index):
"""Create the QTextDocument of an item.
Args:
index: The QModelIndex of the item to draw.
"""
# FIXME we probably should do eliding here. See
# qcommonstyle.cpp:viewItemDrawText
# https://github.com/The-Compiler/qutebrowser/issues/118
text_option = QTextOption()
if self._opt.features & QStyleOptionViewItem.WrapText:
text_option.setWrapMode(QTextOption.WordWrap)
else:
text_option.setWrapMode(QTextOption.ManualWrap)
text_option.setTextDirection(self._opt.direction)
text_option.setAlignment(QStyle.visualAlignment(
self._opt.direction, self._opt.displayAlignment))
self._doc = QTextDocument(self)
self._doc.setDefaultFont(self._opt.font)
self._doc.setDefaultTextOption(text_option)
self._doc.setDefaultStyleSheet(style.get_stylesheet("""
.highlight {
{{ color['completion.match.fg'] }}
}
"""))
self._doc.setDocumentMargin(2)
if index.parent().isValid():
pattern = index.model().pattern
if index.column() == 0 and pattern:
text = self._opt.text.replace(
pattern,
'<span class="highlight">{}</span>'.format(pattern))
self._doc.setHtml(text)
else:
self._doc.setPlainText(self._opt.text)
else:
self._doc.setHtml('<b>{}</b>'.format(html.escape(self._opt.text)))
开发者ID:HalosGhost,项目名称:qutebrowser,代码行数:39,代码来源:completiondelegate.py
注:本文中的qutebrowser.config.style.get_stylesheet函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论