本文整理汇总了Python中PyQt5.QtWidgets.QTextBrowser.setFont方法的典型用法代码示例。如果您正苦于以下问题:Python QTextBrowser.setFont方法的具体用法?Python QTextBrowser.setFont怎么用?Python QTextBrowser.setFont使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt5.QtWidgets.QTextBrowser
的用法示例。
在下文中一共展示了QTextBrowser.setFont方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: SourceViewer
# 需要导入模块: from PyQt5.QtWidgets import QTextBrowser [as 别名]
# 或者: from PyQt5.QtWidgets.QTextBrowser import setFont [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: __init__
# 需要导入模块: from PyQt5.QtWidgets import QTextBrowser [as 别名]
# 或者: from PyQt5.QtWidgets.QTextBrowser import setFont [as 别名]
def __init__(self, *args, **kwargs):
super(MainForm, self).__init__(*args, **kwargs)
self.resize(320, 360)
self.setWindowIcon(QIcon('./assets/eset_logo.png'))
self.setWindowTitle("ESET Key scraper")
self.label = QLabel(
"Keys for " + (KeyValue.get('evaluation_type') or 'EAV'))
self.label.setFixedSize(100, 20)
text_box = QTextBrowser()
text_box.setFont(QFont('Ubuntu mono', 12))
refresh_button = QPushButton("Refresh")
refresh_button.setFixedHeight(40)
settings_button = QPushButton()
settings_button.setFixedSize(60, 40)
settings_button.setIcon(QIcon('./assets/settings.png'))
layout = QGridLayout()
layout.addWidget(self.label, 1, 1, 1, 2)
layout.addWidget(text_box, 2, 1, 1, 2)
layout.addWidget(refresh_button, 3, 1)
layout.addWidget(settings_button, 3, 2)
refresh_button.clicked.connect(lambda: self.refresh(text_box))
settings_button.clicked.connect(self.show_settings)
self.setLayout(layout)
self.refresh(text_box)
示例3: Form
# 需要导入模块: from PyQt5.QtWidgets import QTextBrowser [as 别名]
# 或者: from PyQt5.QtWidgets.QTextBrowser import setFont [as 别名]
class Form(QDialog):
def __init__(self,parent=None):
super(Form,self).__init__(parent)
self.browser = QTextBrowser()
self.browser.setFont(QFont("Consolas",12,QFont.StyleItalic))
self.lineedit = QLineEdit('Type an express and press Enter')
self.lineedit.selectAll()
layout = QVBoxLayout()
layout.addWidget(self.browser)
layout.addWidget(self.lineedit)
self.setLayout(layout)
self.lineedit.setFocus()
# self.connect(self.lineedit,SIGNAL('returnPressed()'),self.updateUi)
self.lineedit.returnPressed.connect(self.updateUi)
self.setWindowTitle('Calculate')
def updateUi(self):
try:
text = self.lineedit.text()
self.browser.append('%s = %s' % (text, eval(text)))
except:
self.browser.append('%s is invalid!' % text)
示例4: Dialog
# 需要导入模块: from PyQt5.QtWidgets import QTextBrowser [as 别名]
# 或者: from PyQt5.QtWidgets.QTextBrowser import setFont [as 别名]
class Dialog(QDialog):
def __init__(self, parent=None):
super(Dialog, self).__init__(parent)
self._info = None
self._text = ''
self._convertedtext = ''
self._encoding = None
self.mainwindow = parent
self.fromVersionLabel = QLabel()
self.fromVersion = QLineEdit()
self.reason = QLabel()
self.toVersionLabel = QLabel()
self.toVersion = QLineEdit()
self.lilyChooser = lilychooser.LilyChooser()
self.messages = QTextBrowser()
self.diff = QTextBrowser(lineWrapMode=QTextBrowser.NoWrap)
self.uni_diff = QTextBrowser(lineWrapMode=QTextBrowser.NoWrap)
self.copyCheck = QCheckBox(checked=
QSettings().value('convert_ly/copy_messages', True, bool))
self.tabw = QTabWidget()
self.tabw.addTab(self.messages, '')
self.tabw.addTab(self.diff, '')
self.tabw.addTab(self.uni_diff, '')
self.buttons = QDialogButtonBox(
QDialogButtonBox.Reset | QDialogButtonBox.Save |
QDialogButtonBox.Ok | QDialogButtonBox.Cancel)
self.buttons.button(QDialogButtonBox.Ok).clicked .connect(self.accept)
self.buttons.rejected.connect(self.reject)
self.buttons.button(QDialogButtonBox.Reset).clicked.connect(self.run)
self.buttons.button(QDialogButtonBox.Save).clicked.connect(self.saveFile)
layout = QVBoxLayout()
self.setLayout(layout)
grid = QGridLayout()
grid.addWidget(self.fromVersionLabel, 0, 0)
grid.addWidget(self.fromVersion, 0, 1)
grid.addWidget(self.reason, 0, 2, 1, 3)
grid.addWidget(self.toVersionLabel, 1, 0)
grid.addWidget(self.toVersion, 1, 1)
grid.addWidget(self.lilyChooser, 1, 3, 1, 2)
layout.addLayout(grid)
layout.addWidget(self.tabw)
layout.addWidget(self.copyCheck)
layout.addWidget(widgets.Separator())
layout.addWidget(self.buttons)
app.translateUI(self)
qutil.saveDialogSize(self, 'convert_ly/dialog/size', QSize(600, 300))
app.settingsChanged.connect(self.readSettings)
self.readSettings()
self.finished.connect(self.saveCopyCheckSetting)
self.lilyChooser.currentIndexChanged.connect(self.slotLilyPondVersionChanged)
self.slotLilyPondVersionChanged()
def translateUI(self):
self.fromVersionLabel.setText(_("From version:"))
self.toVersionLabel.setText(_("To version:"))
self.copyCheck.setText(_("Save convert-ly messages in document"))
self.copyCheck.setToolTip(_(
"If checked, the messages of convert-ly are appended as a "
"comment to the end of the document."))
self.tabw.setTabText(0, _("&Messages"))
self.tabw.setTabText(1, _("&Changes"))
self.tabw.setTabText(2, _("&Diff"))
self.buttons.button(QDialogButtonBox.Reset).setText(_("Run Again"))
self.buttons.button(QDialogButtonBox.Save).setText(_("Save as file"))
self.setCaption()
def saveCopyCheckSetting(self):
QSettings().setValue('convert_ly/copy_messages', self.copyCheck.isChecked())
def readSettings(self):
font = textformats.formatData('editor').font
self.diff.setFont(font)
diffFont = QFont("Monospace")
diffFont.setStyleHint(QFont.TypeWriter)
self.uni_diff.setFont(diffFont)
def slotLilyPondVersionChanged(self):
self.setLilyPondInfo(self.lilyChooser.lilyPondInfo())
def setCaption(self):
version = self._info and self._info.versionString() or _("<unknown>")
title = _("Convert-ly from LilyPond {version}").format(version=version)
self.setWindowTitle(app.caption(title))
def setLilyPondInfo(self, info):
self._info = info
self.setCaption()
self.toVersion.setText(info.versionString())
self.setConvertedText()
self.setDiffText()
self.messages.clear()
#.........这里部分代码省略.........
示例5: Widget
# 需要导入模块: from PyQt5.QtWidgets import QTextBrowser [as 别名]
# 或者: from PyQt5.QtWidgets.QTextBrowser import setFont [as 别名]
#.........这里部分代码省略.........
self.deleteAction.setToolTip(_("Remove the selected snippets."))
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()
示例6: Example
# 需要导入模块: from PyQt5.QtWidgets import QTextBrowser [as 别名]
# 或者: from PyQt5.QtWidgets.QTextBrowser import setFont [as 别名]
class Example(QWidget):
def __init__(self):
super().__init__()
self.initUI()
self.comlist=[]
def initUI(self):
QToolTip.setFont(QFont('SansSerif', 40))
# grid = QGridLayout()
# self.setLayout(grid)
# names = ['NOT', 'AND', '0', '1',
# 'OR', 'XOR', '2', '3',
# '>', '<', '/', '*',
# '!=', '==', '+', '-',
# '(', ')', '@', 'DEL']
#
# positions = [(i,j) for i in range(5) for j in range(4)]
self.buno= QPushButton('NOT',self)
self.buno.resize(60,35)
self.buno.move(0*70+30,0*52+85)
self.buno.setFont(QFont('Calibri', 14, QFont.Normal))
self.buno.setStyleSheet("QPushButton{color:'#212121';background:'#e1e1e1'}")
self.buno.clicked.connect(self.commandBuno)
self.buand= QPushButton('AND',self)
self.buand.resize(60,35)
self.buand.move(1*70+30,0*52+85)
self.buand.setFont(QFont('Calibri', 14, QFont.Normal))
self.buand.setStyleSheet("QPushButton{color:'#212121';background:'#e1e1e1'}")
self.buand.clicked.connect(self.commandBuand)
self.bu0= QPushButton('0',self)
self.bu0.resize(60,35)
self.bu0.move(2*70+30,0*52+85)
self.bu0.setFont(QFont('Calibri', 14, QFont.Normal))
self.bu0.setStyleSheet("QPushButton{color:'#212121';background:'#e1e1e1'}")
self.bu0.clicked.connect(self.commandBu0)
self.bu1= QPushButton('1',self)
self.bu1.resize(60,35)
self.bu1.move(3*70+30,0*52+85)
self.bu1.setFont(QFont('Calibri', 14, QFont.Normal))
self.bu1.setStyleSheet("QPushButton{color:'#212121';background:'#e1e1e1'}")
self.bu1.clicked.connect(self.commandBu1)
self.buor= QPushButton('OR',self)
self.buor.resize(60,35)
self.buor.move(0*70+30,1*52+85)
self.buor.setFont(QFont('Calibri', 14, QFont.Normal))
self.buor.setStyleSheet("QPushButton{color:'#212121';background:'#e1e1e1'}")
self.buor.clicked.connect(self.commandBuor)
self.buxor= QPushButton('XOR',self)
self.buxor.resize(60,35)
self.buxor.move(1*70+30,1*52+85)
self.buxor.setFont(QFont('Calibri', 14, QFont.Normal))
self.buxor.setStyleSheet("QPushButton{color:'#212121';background:'#e1e1e1'}")
self.buxor.clicked.connect(self.commandBuxor)
self.bu2= QPushButton('2',self)
self.bu2.resize(60,35)
self.bu2.move(2*70+30,1*52+85)
self.bu2.setFont(QFont('Calibri', 14, QFont.Normal))
self.bu2.setStyleSheet("QPushButton{color:'#212121';background:'#e1e1e1'}")
self.bu2.clicked.connect(self.commandBu2)
self.bu3= QPushButton('3',self)
self.bu3.resize(60,35)
self.bu3.move(3*70+30,1*52+85)
self.bu3.setFont(QFont('Calibri', 14, QFont.Normal))
self.bu3.setStyleSheet("QPushButton{color:'#212121';background:'#e1e1e1'}")
self.bu3.clicked.connect(self.commandBu3)
self.bul= QPushButton('>',self)
self.bul.resize(60,35)
self.bul.move(0*70+30,2*52+85)
self.bul.setFont(QFont('Calibri', 14, QFont.Normal))
self.bul.setStyleSheet("QPushButton{color:'#212121';background:'#e1e1e1'}")
self.bul.clicked.connect(self.commandBul)
self.bus= QPushButton('<',self)
self.bus.resize(60,35)
self.bus.move(1*70+30,2*52+85)
self.bus.setFont(QFont('Calibri', 14, QFont.Normal))
self.bus.setStyleSheet("QPushButton{color:'#212121';background:'#e1e1e1'}")
self.bus.clicked.connect(self.commandBus)
self.bud= QPushButton('/',self)
self.bud.resize(60,35)
self.bud.move(2*70+30,2*52+85)
self.bud.setFont(QFont('Calibri', 14, QFont.Normal))
self.bud.setStyleSheet("QPushButton{color:'#212121';background:'#e1e1e1'}")
self.bud.clicked.connect(self.commandBud)
#.........这里部分代码省略.........