本文整理匯總了Python中PyQt5.QtWidgets.QTextBrowser方法的典型用法代碼示例。如果您正苦於以下問題:Python QtWidgets.QTextBrowser方法的具體用法?Python QtWidgets.QTextBrowser怎麽用?Python QtWidgets.QTextBrowser使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類PyQt5.QtWidgets
的用法示例。
在下文中一共展示了QtWidgets.QTextBrowser方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: __init__
# 需要導入模塊: from PyQt5 import QtWidgets [as 別名]
# 或者: from PyQt5.QtWidgets import QTextBrowser [as 別名]
def __init__(self):
"""MainWindow constructor."""
super().__init__()
# Main UI code goes here
main = qtw.QTextBrowser(minimumWidth=800, minimumHeight=600)
self.setCentralWidget(main)
# Must come before the HTML is inserted
main.document().setDefaultStyleSheet(
'body {color: #333; font-size: 14px;} '
'h2 {background: #CCF; color: #443;} '
'h1 {background: #001133; color: white;} '
)
# TextBrowser background is a widget style, not a document style
main.setStyleSheet('background-color: #EEF;')
with open('fight_fighter2.html', 'r') as fh:
main.insertHtml(fh.read())
main.setOpenExternalLinks(True)
# End main UI code
self.show()
示例2: setupUi
# 需要導入模塊: from PyQt5 import QtWidgets [as 別名]
# 或者: from PyQt5.QtWidgets import QTextBrowser [as 別名]
def setupUi(self, DocDlg):
DocDlg.setObjectName("DocDlg")
DocDlg.resize(714, 454)
self.verticalLayout = QtWidgets.QVBoxLayout(DocDlg)
self.verticalLayout.setContentsMargins(6, 6, 6, 6)
self.verticalLayout.setSpacing(6)
self.verticalLayout.setObjectName("verticalLayout")
self.textMain = QtWidgets.QTextBrowser(DocDlg)
self.textMain.setStyleSheet("")
self.textMain.setLineWrapMode(QtWidgets.QTextEdit.NoWrap)
self.textMain.setOpenExternalLinks(True)
self.textMain.setObjectName("textMain")
self.verticalLayout.addWidget(self.textMain)
self.buttonBox = QtWidgets.QDialogButtonBox(DocDlg)
self.buttonBox.setOrientation(QtCore.Qt.Horizontal)
self.buttonBox.setStandardButtons(QtWidgets.QDialogButtonBox.Close)
self.buttonBox.setObjectName("buttonBox")
self.verticalLayout.addWidget(self.buttonBox)
self.retranslateUi(DocDlg)
self.buttonBox.accepted.connect(DocDlg.accept)
self.buttonBox.rejected.connect(DocDlg.reject)
QtCore.QMetaObject.connectSlotsByName(DocDlg)
示例3: mouseMoveEvent
# 需要導入模塊: from PyQt5 import QtWidgets [as 別名]
# 或者: from PyQt5.QtWidgets import QTextBrowser [as 別名]
def mouseMoveEvent(self, event):
# Compare mouse positions
# This allows to filter out scrolling
# from a normal mouseEvent
QtWidgets.QTextBrowser.mouseMoveEvent(self, event)
if not self.mousePosition:
self.mousePosition = event.pos()
return
current_position = event.pos()
if current_position == self.mousePosition or self.parent.sideDock.isVisible():
return
else:
self.mousePosition = event.pos()
self.parent.navBar.show()
if self.annotation_mode:
self.viewport().setCursor(QtCore.Qt.IBeamCursor)
else:
self.viewport().setCursor(QtCore.Qt.ArrowCursor)
self.parent.mouseHideTimer.start(2000)
示例4: open_log
# 需要導入模塊: from PyQt5 import QtWidgets [as 別名]
# 或者: from PyQt5.QtWidgets import QTextBrowser [as 別名]
def open_log(self):
info_log = QTextBrowser()
info_log.setObjectName('TextFileEdit')
info_log.setStyleSheet(self.window().styleSheet())
info_log.setWindowTitle('Raw output')
# Sets value to None when closed
info_log.closeEvent = lambda _, inflog=info_log: setattr(self, '_open_window', None)
# If a window already has been opened
if self._open_window is not None:
try:
self._open_window.close()
except:
pass
self._open_window = info_log
info_log.setText('\n'.join(self.process.debug_log))
info_log.show()
示例5: __init__
# 需要導入模塊: from PyQt5 import QtWidgets [as 別名]
# 或者: from PyQt5.QtWidgets import QTextBrowser [as 別名]
def __init__(self):
super(TracebackWindow, self).__init__()
self.framelist = []
self.ret_add = 0x0
self.setWindowTitle("Traceback")
self.setLayout(QtWidgets.QVBoxLayout())
self._layout = self.layout()
# Creates the rich text viewer that displays the traceback
self._textBrowser = QtWidgets.QTextBrowser()
self._textBrowser.setOpenLinks(False)
self._textBrowser.setFont(QFontDatabase.systemFont(QFontDatabase.FixedFont))
self._layout.addWidget(self._textBrowser)
# Creates the button that displays the return address
self._ret = QtWidgets.QPushButton()
self._ret.setFlat(True)
self._layout.addWidget(self._ret)
self.resize(self.width(), int(self.height() * 0.5))
self.setObjectName('Traceback_Window')
示例6: resizeEvent
# 需要導入模塊: from PyQt5 import QtWidgets [as 別名]
# 或者: from PyQt5.QtWidgets import QTextBrowser [as 別名]
def resizeEvent(self, event=None):
QtWidgets.QTextBrowser.resizeEvent(self, event)
self.resizeTimer.start(100)
示例7: mouseReleaseEvent
# 需要導入模塊: from PyQt5 import QtWidgets [as 別名]
# 或者: from PyQt5.QtWidgets import QTextBrowser [as 別名]
def mouseReleaseEvent(self, event):
# This takes care of annotation placement
# and addition to the list that holds all current annotations
if not self.current_annotation:
QtWidgets.QTextBrowser.mouseReleaseEvent(self, event)
return
self.place_annotation(self.current_annotation)
self.toggle_annotation_mode()
示例8: PopulateForm
# 需要導入模塊: from PyQt5 import QtWidgets [as 別名]
# 或者: from PyQt5.QtWidgets import QTextBrowser [as 別名]
def PopulateForm(self):
self.layout = QtWidgets.QVBoxLayout()
self.browser = QtWidgets.QTextBrowser()
self.browser.setLineWrapMode(QtWidgets.QTextEdit.NoWrap)
self.browser.setHtml(self.text)
self.browser.setReadOnly(True)
self.browser.setFontWeight(12)
self.layout.addWidget(self.browser)
self.parent.setLayout(self.layout)
示例9: setupUi
# 需要導入模塊: from PyQt5 import QtWidgets [as 別名]
# 或者: from PyQt5.QtWidgets import QTextBrowser [as 別名]
def setupUi(self, CmdConsoleDlg):
CmdConsoleDlg.setObjectName("CmdConsoleDlg")
CmdConsoleDlg.resize(468, 334)
self.verticalLayout = QtWidgets.QVBoxLayout(CmdConsoleDlg)
self.verticalLayout.setObjectName("verticalLayout")
self.edtCmdLog = QtWidgets.QTextBrowser(CmdConsoleDlg)
font = QtGui.QFont()
font.setFamily("Courier New")
font.setPointSize(12)
font.setKerning(False)
self.edtCmdLog.setFont(font)
self.edtCmdLog.setLineWrapMode(QtWidgets.QTextEdit.WidgetWidth)
self.edtCmdLog.setObjectName("edtCmdLog")
self.verticalLayout.addWidget(self.edtCmdLog)
self.label = QtWidgets.QLabel(CmdConsoleDlg)
self.label.setObjectName("label")
self.verticalLayout.addWidget(self.label)
self.edtCommand = QtWidgets.QLineEdit(CmdConsoleDlg)
self.edtCommand.setClearButtonEnabled(True)
self.edtCommand.setObjectName("edtCommand")
self.verticalLayout.addWidget(self.edtCommand)
self.buttonBox = QtWidgets.QDialogButtonBox(CmdConsoleDlg)
self.buttonBox.setOrientation(QtCore.Qt.Horizontal)
self.buttonBox.setStandardButtons(QtWidgets.QDialogButtonBox.Close)
self.buttonBox.setObjectName("buttonBox")
self.verticalLayout.addWidget(self.buttonBox)
self.retranslateUi(CmdConsoleDlg)
self.buttonBox.accepted.connect(CmdConsoleDlg.accept)
self.buttonBox.rejected.connect(CmdConsoleDlg.reject)
QtCore.QMetaObject.connectSlotsByName(CmdConsoleDlg)
示例10: __init__
# 需要導入模塊: from PyQt5 import QtWidgets [as 別名]
# 或者: from PyQt5.QtWidgets import QTextBrowser [as 別名]
def __init__(self, text, details, parent=None):
super().__init__(parent=parent)
self.setMinimumHeight(300)
self.layout = QtWidgets.QVBoxLayout(self)
self.setLayout(self.layout)
label = QtWidgets.QLabel(text, self)
self.layout.addWidget(label)
browser = QtWidgets.QTextBrowser(self)
browser.setText(details)
self.layout.addWidget(browser)
示例11: get_QTextBrowser
# 需要導入模塊: from PyQt5 import QtWidgets [as 別名]
# 或者: from PyQt5.QtWidgets import QTextBrowser [as 別名]
def get_QTextBrowser():
"""QTextBrowser getter."""
try:
import PySide.QtGui as QtGui
return QtGui.QTextBrowser
except ImportError:
import PyQt5.QtWidgets as QtWidgets
return QtWidgets.QTextBrowser
示例12: initUI
# 需要導入模塊: from PyQt5 import QtWidgets [as 別名]
# 或者: from PyQt5.QtWidgets import QTextBrowser [as 別名]
def initUI(self):
self.statsBox = QtWidgets.QTextBrowser(self)
#self.updateBtn = QtGui.QPushButton("Update", self)
#self.updateBtn.clicked.connect(self.calcStats)
layout = QtWidgets.QVBoxLayout()
layout.addWidget(self.statsBox)
#layout.addWidget(self.updateBtn)
self.setLayout(layout)
示例13: setupUi
# 需要導入模塊: from PyQt5 import QtWidgets [as 別名]
# 或者: from PyQt5.QtWidgets import QTextBrowser [as 別名]
def setupUi(self, MainWindow):
MainWindow.setObjectName("MainWindow")
MainWindow.resize(1279, 677)
self.centralwidget = QtWidgets.QWidget(MainWindow)
self.centralwidget.setObjectName("centralwidget")
self.tableWidget = QtWidgets.QTableWidget(self.centralwidget)
self.tableWidget.setGeometry(QtCore.QRect(150, 80, 441, 331))
self.tableWidget.setObjectName("tableWidget")
self.tableWidget.setColumnCount(0)
self.tableWidget.setRowCount(0)
self.pushButton = QtWidgets.QPushButton(self.centralwidget) # 生成相對應的對象
self.pushButton.setGeometry(QtCore.QRect(310, 510, 171, 61))# 確定該對象的位置以及大小
self.pushButton.setObjectName("pushButton") # 設置名字,加載對象
self.checkBox = QtWidgets.QCheckBox(self.centralwidget)
self.checkBox.setGeometry(QtCore.QRect(870, 530, 91, 19))
self.checkBox.setObjectName("checkBox")
self.textBrowser = QtWidgets.QTextBrowser(self.centralwidget)
self.textBrowser.setGeometry(QtCore.QRect(750, 90, 421, 321))
self.textBrowser.setObjectName("textBrowser")
MainWindow.setCentralWidget(self.centralwidget)
self.menubar = QtWidgets.QMenuBar(MainWindow)
self.menubar.setGeometry(QtCore.QRect(0, 0, 1279, 23))
self.menubar.setObjectName("menubar")
MainWindow.setMenuBar(self.menubar)
self.statusbar = QtWidgets.QStatusBar(MainWindow)
self.statusbar.setObjectName("statusbar")
MainWindow.setStatusBar(self.statusbar)
self.retranslateUi(MainWindow)
QtCore.QMetaObject.connectSlotsByName(MainWindow)
示例14: __init__
# 需要導入模塊: from PyQt5 import QtWidgets [as 別名]
# 或者: from PyQt5.QtWidgets import QTextBrowser [as 別名]
def __init__(self, *args, **kwargs):
super(Window, self).__init__(*args, **kwargs)
layout = QVBoxLayout(self)
self.button1 = QPushButton('已連接', self, clicked=self.doTest)
self.button2 = QPushButton('未連接', self)
self.retView = QTextBrowser(self)
layout.addWidget(self.button1)
layout.addWidget(self.button2)
layout.addWidget(self.retView)
示例15: setupUi
# 需要導入模塊: from PyQt5 import QtWidgets [as 別名]
# 或者: from PyQt5.QtWidgets import QTextBrowser [as 別名]
def setupUi(self, PasteDialog):
PasteDialog.setObjectName("PasteDialog")
PasteDialog.resize(400, 300)
self.gridLayout = QtWidgets.QGridLayout(PasteDialog)
self.gridLayout.setObjectName("gridLayout")
self.verticalLayout = QtWidgets.QVBoxLayout()
self.verticalLayout.setObjectName("verticalLayout")
self.textBrowser = QtWidgets.QTextBrowser(PasteDialog)
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.textBrowser.sizePolicy().hasHeightForWidth())
self.textBrowser.setSizePolicy(sizePolicy)
self.textBrowser.setAcceptRichText(False)
self.textBrowser.setTextInteractionFlags(QtCore.Qt.LinksAccessibleByKeyboard|QtCore.Qt.LinksAccessibleByMouse|QtCore.Qt.TextBrowserInteraction|QtCore.Qt.TextEditable|QtCore.Qt.TextEditorInteraction|QtCore.Qt.TextSelectableByKeyboard|QtCore.Qt.TextSelectableByMouse)
self.textBrowser.setOpenLinks(False)
self.textBrowser.setObjectName("textBrowser")
self.verticalLayout.addWidget(self.textBrowser)
spacerItem = QtWidgets.QSpacerItem(20, 40, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding)
self.verticalLayout.addItem(spacerItem)
self.horizontalLayout = QtWidgets.QHBoxLayout()
self.horizontalLayout.setObjectName("horizontalLayout")
spacerItem1 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
self.horizontalLayout.addItem(spacerItem1)
self.buttonImport = QtWidgets.QPushButton(PasteDialog)
self.buttonImport.setObjectName("buttonImport")
self.horizontalLayout.addWidget(self.buttonImport)
self.buttonCancel = QtWidgets.QPushButton(PasteDialog)
self.buttonCancel.setObjectName("buttonCancel")
self.horizontalLayout.addWidget(self.buttonCancel)
self.buttonOk = QtWidgets.QPushButton(PasteDialog)
self.buttonOk.setObjectName("buttonOk")
self.horizontalLayout.addWidget(self.buttonOk)
self.verticalLayout.addLayout(self.horizontalLayout)
self.gridLayout.addLayout(self.verticalLayout, 0, 0, 1, 1)
self.retranslateUi(PasteDialog)
QtCore.QMetaObject.connectSlotsByName(PasteDialog)