本文整理匯總了Python中qgis.PyQt.QtWidgets.QTextBrowser類的典型用法代碼示例。如果您正苦於以下問題:Python QTextBrowser類的具體用法?Python QTextBrowser怎麽用?Python QTextBrowser使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了QTextBrowser類的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: LessonFinishedDialog
class LessonFinishedDialog(QDialog):
def __init__(self, lesson):
super(LessonFinishedDialog, self).__init__(iface.mainWindow())
self.reopen = False
self.lesson = lesson
self.setWindowTitle("Lesson finished")
self.verticalLayout = QVBoxLayout()
self.verticalLayout.setSpacing(10)
self.verticalLayout.setMargin(10)
txt = "<p>Congratulations! You have correctly finished this lesson.</p>"
if lesson.nextLessons:
txt += "<p>We recommend you the following lessons to continue:</p><ul>"
for i, nextLesson in enumerate(lesson.nextLessons):
txt+="<li><a href='%i'>%s</a>" % (i, nextLesson[1])
txt += "</ul><p>If you don't want to run more lessons, just <a href='exit'>close this dialog.</a></p>"
txt += "<p>If you want to run another lesson, click <a href='reopen'>here</a> to reopen the lesson selector</p>"
self.text = QTextBrowser()
self.text.anchorClicked.connect(self.linkClicked)
self.text.setHtml(txt)
self.text.setOpenLinks(False)
self.verticalLayout.addWidget(self.text)
self.setLayout(self.verticalLayout)
self.resize(400, 300)
self.nextLesson = None
def linkClicked(self, url):
if url.path() not in ["exit", "reopen"]:
self.nextLesson = lessonFromName(*self.lesson.nextLessons[int(url.path())])
if url.path() =="reopen":
self.reopen = True
self.close()
示例2: __init__
def __init__(self):
QtWidgets.QDialog.__init__(self)
self.setMinimumWidth(600)
self.setMinimumHeight(450)
self.helpFile = os.path.join(os.path.dirname(__file__),'README.html')
self.setWindowTitle('VectorBender')
txt = QTextBrowser()
txt.setReadOnly(True)
txt.setSearchPaths([os.path.dirname(__file__)])
txt.setOpenExternalLinks(True)
txt.setText( open(self.helpFile, 'r').read() )
cls = QPushButton('Close')
cls.pressed.connect(self.accept)
lay = QVBoxLayout()
lay.addWidget(txt)
lay.addWidget(cls)
self.setLayout(lay)
示例3: __init__
def __init__(self, parent=None):
QTextBrowser.__init__(self, parent)
self.setOpenLinks(False)
self.item = None
self.dirty = False
self._clear()
self._showPluginInfo()
self.anchorClicked.connect(self._linkClicked)
示例4: setHtml
def setHtml(self, html):
# convert special tags :)
html = unicode(html).replace('<warning>', '<img src=":/db_manager/warning"> ')
# add default style
html = u"""
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<style type="text/css">
.section { margin-top: 25px; }
table.header th { background-color: #dddddd; }
table.header td { background-color: #f5f5f5; }
table.header th, table.header td { padding: 0px 10px; }
table td { padding-right: 20px; }
.underline { text-decoration:underline; }
</style>
</head>
<body>
%s <br>
</body>
</html>
""" % html
# print ">>>>>\n", html, "\n<<<<<<"
return QTextBrowser.setHtml(self, html)
示例5: setupUi
def setupUi(self):
self.resize(800, 600)
self.setWindowTitle("Authorship")
layout = QVBoxLayout()
splitter = QSplitter(self)
splitter.setOrientation(Qt.Vertical)
self.table = QTableWidget(splitter)
self.table.setColumnCount(3)
self.table.setShowGrid(False)
self.table.verticalHeader().hide()
self.table.setHorizontalHeaderLabels(["Attribute", "Author", "Value"])
self.table.setRowCount(len(self.blamedata))
self.table.setSelectionBehavior(QAbstractItemView.SelectRows)
self.table.setSelectionMode(QAbstractItemView.SingleSelection);
self.table.selectionModel().selectionChanged.connect(self.selectionChanged)
for i, name in enumerate(self.blamedata.keys()):
values = self.blamedata[name]
self.table.setItem(i, 0, QTableWidgetItem(name));
self.table.setItem(i, 1, QTableWidgetItem(values[1].authorname));
self.table.setItem(i, 2, QTableWidgetItem(values[0]));
self.table.resizeRowsToContents()
self.table.horizontalHeader().setMinimumSectionSize(250)
self.table.horizontalHeader().setStretchLastSection(True)
self.text = QTextBrowser(splitter)
layout.addWidget(splitter)
self.setLayout(layout)
QMetaObject.connectSlotsByName(self)
示例6: BlameDialog
class BlameDialog(QDialog):
def __init__(self, repo, path):
QDialog.__init__(self, None, Qt.WindowSystemMenuHint | Qt.WindowTitleHint)
versions = repo.log(path = path, limit = 1)
if not versions:
raise GeoGigException("The selected feature is not versioned yet")
self.blamedata = repo.blame(path)
self.repo = repo
self.commitText = {}
self.setupUi()
def setupUi(self):
self.resize(800, 600)
self.setWindowTitle("Authorship")
layout = QVBoxLayout()
splitter = QSplitter(self)
splitter.setOrientation(Qt.Vertical)
self.table = QTableWidget(splitter)
self.table.setColumnCount(3)
self.table.setShowGrid(False)
self.table.verticalHeader().hide()
self.table.setHorizontalHeaderLabels(["Attribute", "Author", "Value"])
self.table.setRowCount(len(self.blamedata))
self.table.setSelectionBehavior(QAbstractItemView.SelectRows)
self.table.setSelectionMode(QAbstractItemView.SingleSelection);
self.table.selectionModel().selectionChanged.connect(self.selectionChanged)
for i, name in enumerate(self.blamedata.keys()):
values = self.blamedata[name]
self.table.setItem(i, 0, QTableWidgetItem(name));
self.table.setItem(i, 1, QTableWidgetItem(values[1].authorname));
self.table.setItem(i, 2, QTableWidgetItem(values[0]));
self.table.resizeRowsToContents()
self.table.horizontalHeader().setMinimumSectionSize(250)
self.table.horizontalHeader().setStretchLastSection(True)
self.text = QTextBrowser(splitter)
layout.addWidget(splitter)
self.setLayout(layout)
QMetaObject.connectSlotsByName(self)
def selectionChanged(self):
idx = self.table.currentRow()
commit = self.blamedata[self.table.item(idx, 0).text()][1]
self.text.setText(str(commit))
示例7: Info
class Info(QDialog):
info = []
@classmethod
def showInfo(cls, plugin, html, gmlid, parent):
info = Info(plugin, html, gmlid, parent)
info.setAttribute(Qt.WA_DeleteOnClose)
info.setModal(False)
cls.info.append(info)
info.show()
def __init__(self, plugin, html, gmlid, parent):
QDialog.__init__(self, parent)
self.resize(QSize(740, 580))
self.setWindowTitle(u"Flurstücksnachweis")
self.plugin = plugin
self.gmlid = gmlid
self.tbEigentuemer = QTextBrowser(self)
self.tbEigentuemer.setHtml(html)
self.tbEigentuemer.setContextMenuPolicy(Qt.NoContextMenu)
layout = QVBoxLayout(self)
layout.addWidget(self.tbEigentuemer)
self.setLayout(layout)
self.restoreGeometry(QSettings("norBIT", "norGIS-ALKIS-Erweiterung").value("infogeom", QByteArray(), type=QByteArray))
self.move(self.pos() + QPoint(16, 16) * len(self.info))
def print_(self):
printer = QPrinter()
dlg = QPrintDialog(printer)
if dlg.exec_() == QDialog.Accepted:
self.tbEigentuemer.print_(printer)
def contextMenuEvent(self, e):
menu = QMenu(self)
action = QAction("Drucken", self)
action.triggered.connect(self.print_)
menu.addAction(action)
menu.exec_(e.globalPos())
def closeEvent(self, e):
QSettings("norBIT", "norGIS-ALKIS-Erweiterung").setValue("infogeom", self.saveGeometry())
self.info.remove(self)
self.plugin.clearHighlight()
QDialog.closeEvent(self, e)
def event(self, e):
if e.type() == QEvent.WindowActivate:
self.plugin.highlight(where="gml_id='{}'".format(self.gmlid))
return QDialog.event(self, e)
示例8: __init__
def __init__(self, plugin, html, gmlid, parent):
QDialog.__init__(self, parent)
self.resize(QSize(740, 580))
self.setWindowTitle(u"Flurstücksnachweis")
self.plugin = plugin
self.gmlid = gmlid
self.tbEigentuemer = QTextBrowser(self)
self.tbEigentuemer.setHtml(html)
self.tbEigentuemer.setContextMenuPolicy(Qt.NoContextMenu)
layout = QVBoxLayout(self)
layout.addWidget(self.tbEigentuemer)
self.setLayout(layout)
self.restoreGeometry(QSettings("norBIT", "norGIS-ALKIS-Erweiterung").value("infogeom", QByteArray(), type=QByteArray))
self.move(self.pos() + QPoint(16, 16) * len(self.info))
示例9: ModelerParametersDialog
#.........這裏部分代碼省略.........
label = QLabel(output.description + '<'
+ output.__class__.__name__ + '>')
item = QLineEdit()
if hasattr(item, 'setPlaceholderText'):
item.setPlaceholderText(ModelerParametersDialog.ENTER_NAME)
self.verticalLayout.addWidget(label)
self.verticalLayout.addWidget(item)
self.valueItems[output.name] = item
label = QLabel(' ')
self.verticalLayout.addWidget(label)
label = QLabel(self.tr('Parent algorithms'))
self.dependenciesPanel = self.getDependenciesPanel()
self.verticalLayout.addWidget(label)
self.verticalLayout.addWidget(self.dependenciesPanel)
self.verticalLayout.addStretch(1000)
self.setLayout(self.verticalLayout)
self.setPreviousValues()
self.setWindowTitle(self._alg.name)
self.verticalLayout2 = QVBoxLayout()
self.verticalLayout2.setSpacing(2)
self.verticalLayout2.setMargin(0)
self.tabWidget = QTabWidget()
self.tabWidget.setMinimumWidth(300)
self.paramPanel = QWidget()
self.paramPanel.setLayout(self.verticalLayout)
self.scrollArea = QScrollArea()
self.scrollArea.setWidget(self.paramPanel)
self.scrollArea.setWidgetResizable(True)
self.tabWidget.addTab(self.scrollArea, self.tr('Parameters'))
self.txtHelp = QTextBrowser()
html = None
isText, algHelp = self._alg.help()
if algHelp is not None:
algHelp = algHelp if isText else QUrl(algHelp)
try:
if isText:
self.txtHelp.setHtml(algHelp)
else:
html = self.tr('<p>Downloading algorithm help... Please wait.</p>')
self.txtHelp.setHtml(html)
self.reply = QgsNetworkAccessManager.instance().get(QNetworkRequest(algHelp))
self.reply.finished.connect(self.requestFinished)
except:
self.txtHelp.setHtml(self.tr('<h2>No help available for this algorithm</h2>'))
self.tabWidget.addTab(self.txtHelp, 'Help')
self.verticalLayout2.addWidget(self.tabWidget)
self.verticalLayout2.addWidget(self.buttonBox)
self.setLayout(self.verticalLayout2)
self.buttonBox.accepted.connect(self.okPressed)
self.buttonBox.rejected.connect(self.cancelPressed)
QMetaObject.connectSlotsByName(self)
def requestFinished(self):
"""Change the webview HTML content"""
reply = self.sender()
if reply.error() != QNetworkReply.NoError:
html = self.tr('<h2>No help available for this algorithm</h2><p>{}</p>'.format(reply.errorString()))
else:
html = str(reply.readAll())