本文整理汇总了Python中PyQt5.QtWidgets.QTextBrowser.setPalette方法的典型用法代码示例。如果您正苦于以下问题:Python QTextBrowser.setPalette方法的具体用法?Python QTextBrowser.setPalette怎么用?Python QTextBrowser.setPalette使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt5.QtWidgets.QTextBrowser
的用法示例。
在下文中一共展示了QTextBrowser.setPalette方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: SourceViewer
# 需要导入模块: from PyQt5.QtWidgets import QTextBrowser [as 别名]
# 或者: from PyQt5.QtWidgets.QTextBrowser import setPalette [as 别名]
class SourceViewer(QDialog):
def __init__(self, browser):
super(SourceViewer, self).__init__(browser.parentWidget())
layout = QVBoxLayout()
layout.setContentsMargins(4, 4, 4, 4)
self.setLayout(layout)
self.urlLabel = QLabel(wordWrap=True)
layout.addWidget(self.urlLabel)
self.textbrowser = QTextBrowser()
layout.addWidget(self.textbrowser)
self.urlLabel.setSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred)
self.textbrowser.setLineWrapMode(QTextBrowser.NoWrap)
app.settingsChanged.connect(self.readSettings)
self.readSettings()
app.translateUI(self)
qutil.saveDialogSize(self, "helpbrowser/sourceviewer/size", QSize(400, 300))
def translateUI(self):
self.setWindowTitle(app.caption(_("LilyPond Source")))
def readSettings(self):
data = textformats.formatData('editor')
self.textbrowser.setPalette(data.palette())
self.textbrowser.setFont(data.font)
highlighter.highlight(self.textbrowser.document())
def showReply(self, reply):
reply.setParent(self)
self.urlLabel.setText(reply.url().toString())
self._reply = reply
reply.finished.connect(self.loadingFinished)
self.textbrowser.clear()
self.show()
def loadingFinished(self):
data = self._reply.readAll()
self._reply.close()
self._reply.deleteLater()
del self._reply
self.textbrowser.clear()
self.textbrowser.setText(str(data, 'utf-8', 'replace'))
highlighter.highlight(self.textbrowser.document())
示例2: Widget
# 需要导入模块: from PyQt5.QtWidgets import QTextBrowser [as 别名]
# 或者: from PyQt5.QtWidgets.QTextBrowser import setPalette [as 别名]
#.........这里部分代码省略.........
self.applyAction.setText(_("A&pply"))
self.applyAction.setToolTip(_("Apply the current snippet."))
self.importAction.setText(_("&Import..."))
self.importAction.setToolTip(_("Import snippets from a file."))
self.exportAction.setText(_("E&xport..."))
self.exportAction.setToolTip(_("Export snippets to a file."))
self.restoreAction.setText(_("Restore &Built-in Snippets..."))
self.restoreAction.setToolTip(
_("Restore deleted or changed built-in snippets."))
self.helpAction.setText(_("&Help"))
self.searchEntry.setToolTip(_(
"Enter text to search in the snippets list.\n"
"See \"What's This\" for more information."))
self.searchEntry.setWhatsThis(''.join(map("<p>{0}</p>\n".format, (
_("Enter text to search in the snippets list, and "
"press Enter to apply the currently selected snippet."),
_("If the search text fully matches the value of the '{name}' variable "
"of a snippet, that snippet is selected.").format(name="name"),
_("If the search text starts with a colon ':', the rest of the "
"search text filters snippets that define the given variable. "
"After a space a value can also be entered, snippets will then "
"match if the value of the given variable contains the text after "
"the space."),
_("E.g. entering {menu} will show all snippets that are displayed "
"in the insert menu.").format(menu="<code>:menu</code>"),
))))
def sizeHint(self):
return self.parent().mainwindow().size() / 4
def readSettings(self):
data = textformats.formatData('editor')
self.textView.setFont(data.font)
self.textView.setPalette(data.palette())
def showContextMenu(self, pos):
"""Called when the user right-clicks the tree view."""
self.menuButton.menu().popup(self.treeView.viewport().mapToGlobal(pos))
def slotReturnPressed(self):
"""Called when the user presses Return in the search entry. Applies current snippet."""
name = self.currentSnippet()
if name:
view = self.parent().mainwindow().currentView()
insert.insert(name, view)
self.parent().hide() # make configurable?
view.setFocus()
def slotEscapePressed(self):
"""Called when the user presses ESC in the search entry. Hides the panel."""
self.parent().hide()
self.parent().mainwindow().currentView().setFocus()
def slotDoubleClicked(self, index):
name = self.treeView.model().name(index)
view = self.parent().mainwindow().currentView()
insert.insert(name, view)
def slotAdd(self):
"""Called when the user wants to add a new snippet."""
edit.Edit(self, None)
def slotEdit(self):
"""Called when the user wants to edit a snippet."""
name = self.currentSnippet()
if name: