当前位置: 首页>>代码示例>>Python>>正文


Python QTextBrowser.setHtml方法代码示例

本文整理汇总了Python中PyQt5.QtWidgets.QTextBrowser.setHtml方法的典型用法代码示例。如果您正苦于以下问题:Python QTextBrowser.setHtml方法的具体用法?Python QTextBrowser.setHtml怎么用?Python QTextBrowser.setHtml使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PyQt5.QtWidgets.QTextBrowser的用法示例。


在下文中一共展示了QTextBrowser.setHtml方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: slotButtonShowDiff

# 需要导入模块: from PyQt5.QtWidgets import QTextBrowser [as 别名]
# 或者: from PyQt5.QtWidgets.QTextBrowser import setHtml [as 别名]
 def slotButtonShowDiff(self):
     """Called when the user clicks Show Difference."""
     docs = self.selectedDocuments() or self.allDocuments()
     if not docs:
         return
     d = docs[0]
     if documentwatcher.DocumentWatcher.instance(d).isdeleted():
         return
     
     filename = d.url().toLocalFile()
     try:
         with open(filename, 'rb') as f:
             disktext = util.decode(f.read())
     except (IOError, OSError):
         return
     
     currenttext = d.toPlainText()
     
     html = htmldiff.htmldiff(
         currenttext, disktext, 
         _("Current Document"), _("Document on Disk"), numlines=5)
     dlg = widgets.dialog.Dialog(self, buttons=('close',))
     view = QTextBrowser(lineWrapMode=QTextBrowser.NoWrap)
     view.setHtml(html)
     dlg.setMainWidget(view)
     dlg.setWindowTitle(app.caption("Differences"))
     dlg.setMessage(_(
         "Document: {url}\n"
         "Difference between the current document and the file on disk:").format(
             url=filename))
     dlg.setWindowModality(Qt.NonModal)
     dlg.setAttribute(Qt.WA_QuitOnClose, False)
     dlg.setAttribute(Qt.WA_DeleteOnClose)
     qutil.saveDialogSize(dlg, "externalchanges/diff/dialog/size", QSize(600, 300))
     dlg.show()
开发者ID:AlexSchr,项目名称:frescobaldi,代码行数:37,代码来源:widget.py

示例2: PreviewWidgetColor

# 需要导入模块: from PyQt5.QtWidgets import QTextBrowser [as 别名]
# 或者: from PyQt5.QtWidgets.QTextBrowser import setHtml [as 别名]
class PreviewWidgetColor(QGroupBox):
    def __init__(self, parent=None):
        super().__init__(parent)
        self.setTitle(self.tr("Preview"))
        self.setMaximumHeight(120)
        self.parent = parent

        vboxLayout = QVBoxLayout(self)
        self.previewGroupBox = QGroupBox(self)
        self.previewGroupBox.setObjectName("previewGroupBox")
        vboxLayout.addWidget(self.previewGroupBox)

        self.horizontalLayout = QHBoxLayout(self.previewGroupBox)
        self.verticalLayout = QVBoxLayout()
        self.horizontalLayout.addLayout(self.verticalLayout)

        self.previewLabel = QLabel(self.previewGroupBox)
        self.previewLabel.setText(self.tr("Window Text"))
        self.previewLabel.setObjectName("previewLabel")
        self.verticalLayout.addWidget(self.previewLabel)

        self.previewPushButton = QPushButton(self.previewGroupBox)
        self.previewPushButton.setText(self.tr("Button"))
        self.previewPushButton.setObjectName("previewPushButton")
        self.verticalLayout.addWidget(self.previewPushButton)

        self.previewTextBrowser = QTextBrowser(self.previewGroupBox)
        self.previewTextBrowser.setObjectName("previewTextBrowser")

        css = iniToCss(os.path.join("/usr/share/color-schemes", self.parent.children()[1].currentItem().colorSchemeName))

        self.previewTextBrowser.setHtml("""<style>#unclicked {color : rgb(%s);}
        #clicked {color : rgb(%s);}</style>"""%(css[1][0],css[1][1]) +
        self.tr("""<p>Normal text <a id='unclicked' href='#'>link</a> <a id='clicked' href='#'>visited</a></p>"""))


        self.horizontalLayout.addWidget(self.previewTextBrowser)


        self.previewPushButton.installEventFilter(self.previewGroupBox)
        self.previewPushButton.setFocusPolicy(Qt.NoFocus)

        self.previewTextBrowser.installEventFilter(self.previewGroupBox)
        self.previewTextBrowser.setFocusPolicy(Qt.NoFocus)
        self.previewTextBrowser.setTextInteractionFlags(Qt.NoTextInteraction)

    def eventFilter(self, obj, event):
        if self.previewPushButton:
            if event.type() == QEvent.MouseButtonRelease:
                return True
            elif event.type() == QEvent.MouseButtonPress:
                return True
            elif event.type() == QEvent.MouseButtonDblClick:
                return True

            else:
                return False
        else:
            super().eventFilter(obj, event)
开发者ID:KaOSx,项目名称:kaptan,代码行数:61,代码来源:tabwidget.py

示例3: CheckInputWidget

# 需要导入模块: from PyQt5.QtWidgets import QTextBrowser [as 别名]
# 或者: from PyQt5.QtWidgets.QTextBrowser import setHtml [as 别名]
class CheckInputWidget(QWidget, MooseWidget):
    """
    Runs the executable with "--check-input" on the input file and stores the results.
    Signals:
        needInputFile: Emitted when we need the input file. Argument is the path where the input file will be written.
    """
    needInputFile = pyqtSignal(str)

    def __init__(self, **kwds):
        super(CheckInputWidget, self).__init__(**kwds)

        self.input_file = "peacock_check_input.i"
        self.top_layout = WidgetUtils.addLayout(vertical=True)
        self.setLayout(self.top_layout)
        self.output = QTextBrowser(self)
        self.output.setStyleSheet("QTextBrowser { background: black; color: white; }")
        self.output.setReadOnly(True)
        self.top_layout.addWidget(self.output)
        self.button_layout = WidgetUtils.addLayout()
        self.top_layout.addLayout(self.button_layout)
        self.hide_button = WidgetUtils.addButton(self.button_layout, self, "Hide", lambda: self.hide())
        self.check_button = WidgetUtils.addButton(self.button_layout, self, "Check", self._check)
        self.resize(800, 500)
        self.setup()
        self.path = None

    def cleanup(self):
        try:
            os.remove(self.input_file)
        except:
            pass

    def check(self, path):
        """
        Runs the executable with "--check-input" and adds the output to the window
        Input:
            path[str]: Path to the executable
        """
        self.path = path
        self._check()

    def _check(self):
        """
        Runs the executable with "--check-input" and adds the output to the window
        """
        input_file = os.path.abspath(self.input_file)
        self.needInputFile.emit(input_file)
        self.output.clear()
        try:
            args = ["-i", input_file, "--check-input"]
            output = ExeLauncher.runExe(self.path, args, print_errors=False)
            output_html = TerminalUtils.terminalOutputToHtml(output)
            self.output.setHtml("<pre>%s</pre>" % output_html)
        except Exception as e:
            output_html = TerminalUtils.terminalOutputToHtml(str(e))
            self.output.setHtml("<pre>%s</pre>" % output_html)
        self.cleanup()
开发者ID:aeslaughter,项目名称:moose,代码行数:59,代码来源:CheckInputWidget.py

示例4: error_report_main

# 需要导入模块: from PyQt5.QtWidgets import QTextBrowser [as 别名]
# 或者: from PyQt5.QtWidgets.QTextBrowser import setHtml [as 别名]
def error_report_main():
    error_message = sys.stdin.read()
    error_message = "<pre>{}</pre>".format(html.escape(error_message).replace("\n", "<br>"))

    app = QApplication(sys.argv)

    if sys.platform == 'darwin':
        # workaround macOS QTBUG-61562
        from brickv.mac_pasteboard_mime_fixed import MacPasteboardMimeFixed
        mac_pasteboard_mime_fixed = MacPasteboardMimeFixed()

    window = QMainWindow()
    window.setWindowTitle('Error - Brick Viewer ' + config.BRICKV_VERSION)
    window.setWindowIcon(QIcon(load_pixmap('brickv-icon.png')))

    widget = QWidget()
    window.setCentralWidget(widget)
    widget.setLayout(QHBoxLayout())

    icon = QLabel()
    icon.setPixmap(QMessageBox.standardIcon(QMessageBox.Critical))
    icon.setAlignment(Qt.AlignHCenter | Qt.AlignTop)
    widget.layout().addWidget(icon)

    right_widget = QWidget()
    right_widget.setLayout(QVBoxLayout())
    right_widget.layout().setContentsMargins(0, 0, 0, 0)

    label = QLabel("Please report this error to <a href='mailto:[email protected]'>[email protected]</a>.<br/><br/>" +
                   "If you know what caused the error and could work around it, please report it anyway. This allows us to improve the error messages.")
    label.setWordWrap(True)
    label.setOpenExternalLinks(True)
    right_widget.layout().addWidget(label)

    tb = QTextBrowser()
    tb.setHtml(error_message)
    right_widget.layout().addWidget(tb)

    cbox = QCheckBox("Show this message again")
    cbox.setChecked(True)
    right_widget.layout().addWidget(cbox)

    btn = QPushButton("Close")
    btn.clicked.connect(lambda event: app.exit())
    right_widget.layout().addWidget(btn)

    widget.layout().addWidget(right_widget)
    window.setMinimumSize(640, 400)
    window.resize(950, 600)
    window.show()

    app.exec_()

    return int(cbox.isChecked())
开发者ID:Tinkerforge,项目名称:brickv,代码行数:56,代码来源:main.py

示例5: add_text

# 需要导入模块: from PyQt5.QtWidgets import QTextBrowser [as 别名]
# 或者: from PyQt5.QtWidgets.QTextBrowser import setHtml [as 别名]
    def add_text(self):
        self.process_text()
        text = QTextBrowser()
        text.setHtml(self.text)
        text.setOpenLinks(False)
        # text.moveCursor(QTextCursor.End)
        text.setMinimumWidth(500)
        text.setMaximumWidth(500)
        text.document().setTextWidth(500)
        text.setMinimumHeight((text.document().size().height())+5)
        text.setSizePolicy(QSizePolicy.Preferred, QSizePolicy.Expanding)

        text.anchorClicked.connect(self.link_clicked)

        self.lay.addWidget(text, 1, 1, 1, 3)
开发者ID:grsakea,项目名称:pyt,代码行数:17,代码来源:gtweet.py

示例6: report_fatal_error

# 需要导入模块: from PyQt5.QtWidgets import QTextBrowser [as 别名]
# 或者: from PyQt5.QtWidgets.QTextBrowser import setHtml [as 别名]
    def report_fatal_error(self, title, message, trace):
        trace = '<pre>{}</pre>'.format(html.escape(trace).replace('\n', '<br>'))

        label_title = QLabel(title)

        font = label_title.font()
        font.setBold(True)
        label_title.setFont(font)

        label_message = QLabel('Error: ' + message)
        browser_trace = QTextBrowser()
        browser_trace.setHtml(trace)

        layout = QVBoxLayout(self)
        layout.addWidget(label_title)
        layout.addWidget(label_message)
        layout.addWidget(browser_trace)
开发者ID:Tinkerforge,项目名称:brickv,代码行数:19,代码来源:red.py

示例7: Browser

# 需要导入模块: from PyQt5.QtWidgets import QTextBrowser [as 别名]
# 或者: from PyQt5.QtWidgets.QTextBrowser import setHtml [as 别名]
class Browser(QWidget):
	def __init__(self,parent_,url,cname,fname):
		super(Browser,self).__init__(parent_)
		self.parent_=parent_
		self.initUI(url,cname,fname)

	def initUI(self,url,cname,fname):
		lbl = QLabel()
		lbl.setText('Forum News - '+cname)
		lbl.setObjectName('hlbl')
		self.browser = QTextBrowser()
		self.browser.document().setDefaultStyleSheet('p{font-size:12px;} div{margin-left:20px;}')

		f = open(url,'r')
		ftext = '<div><br><h3><b>%s</b></h3>'%fname + str(f.read())+'<br></div>'
		self.browser.setHtml(ftext)
		self.browser.setFrameStyle(QFrame.NoFrame)

		self.backBtn = QPushButton(QIcon(':/Assets/close2.png'),'Close')
		self.backBtn.setObjectName('backBtn')
		self.backBtn.clicked.connect(partial(self.parent_.closeTextBrowser))
		frame = topFrame(self.backBtn,lbl)
		frame.setObjectName('nFrameEven')


		self.widget = QWidget(self)
		self.vbox = QVBoxLayout()
		self.vbox.setSpacing(3)
		self.vbox.addWidget(frame)
		self.vbox.addWidget(self.browser)

		self.vbox.setContentsMargins(0,0,0,0)
		self.widget.setLayout(self.vbox)
		self.scroll = QScrollArea(self)
		self.scroll.setWidget(self.widget)
		self.scroll.setWidgetResizable(True)
		self.scroll.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff)
		self.scroll.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff)

		vbox1 = QVBoxLayout()
		vbox1.setContentsMargins(0,0,0,0)
		vbox1.setSpacing(0)

		vbox1.addWidget(self.scroll)
		self.setLayout(vbox1)
开发者ID:AkshayAgarwal007,项目名称:Moodly,代码行数:47,代码来源:view.py

示例8: AbouteInfo

# 需要导入模块: from PyQt5.QtWidgets import QTextBrowser [as 别名]
# 或者: from PyQt5.QtWidgets.QTextBrowser import setHtml [as 别名]
class AbouteInfo(QDialog):
    def __init__(self, htmlfile, name):
        super(AbouteInfo, self).__init__()
        self.text = QTextBrowser()
        text = open(htmlfile).read()
        self.text.setHtml(text)
        self.text.setOpenExternalLinks(True)
        self.cancelbutton = QPushButton("&Close")
        self.setGeometry(100, 100, 700, 700)
        buttonlayout = QHBoxLayout()
        buttonlayout.addStretch()
        buttonlayout.addWidget(self.cancelbutton)
        layout = QVBoxLayout()
        layout.addWidget(self.text)
        layout.addLayout(buttonlayout)
        self.setLayout(layout)
        self.setWindowTitle("PyBigPixel Creator {0}-- {1}".format(__version__, name))
        self.cancelbutton.clicked.connect(self.close)
开发者ID:SWE-JSAM,项目名称:PyBigPixel-creator,代码行数:20,代码来源:pybigpixel.py

示例9: About_Dialog

# 需要导入模块: from PyQt5.QtWidgets import QTextBrowser [as 别名]
# 或者: from PyQt5.QtWidgets.QTextBrowser import setHtml [as 别名]
class About_Dialog(QDialog):
    def __init__(self):
        super(About_Dialog, self).__init__()
        self.setupUi()

    def setupUi(self):
        self.setObjectName("Dialog")
        self.setFixedSize(464, 257)
        icon = QIcon()
        icon.addPixmap(QPixmap("./resource/weather-thunder.png"), QIcon.Normal, QIcon.Off)
        self.setWindowIcon(icon)
        self.setSizeGripEnabled(False)
        self.setModal(True)
        self.textBrowser = QTextBrowser(self)
        self.textBrowser.setGeometry(QRect(0, 130, 491, 192))
        self.textBrowser.setObjectName("textBrowser")
        self.label = QLabel(self)
        self.label.setGeometry(QRect(0, 0, 641, 131))
        self.label.setText("")
        self.label.setPixmap(QPixmap("./resource/about.jpg"))
        self.label.setScaledContents(True)
        self.label.setObjectName("label")

        self.retranslateUi()
        QMetaObject.connectSlotsByName(self)
        self.show()

    def retranslateUi(self):
        _translate = QCoreApplication.translate
        self.setWindowTitle(_translate("Dialog", "关于"))
        self.textBrowser.setHtml(_translate("Dialog", "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\" \"http://www.w3.org/TR/REC-html40/strict.dtd\">\n"
"<html><head><meta name=\"qrichtext\" content=\"1\" /><style type=\"text/css\">\n"
"p, li { white-space: pre-wrap; }\n"
"</style></head><body style=\" font-family:\'SimSun\'; font-size:9pt; font-weight:400; font-style:normal;\">\n"
"<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><span style=\" font-size:11pt; font-weight:600;\">绍兴防雷中心 雷电公报制图-v1.0</span></p>\n"
"<p style=\"-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:10pt; font-weight:600;\"><br /></p>\n"
"<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><span style=\" font-size:10pt;\">联系:[email protected]</span></p>\n"
"<p style=\"-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:10pt;\"><br /></p>\n"
"<p style=\"-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><br /></p>\n"
"<p align=\"center\" style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><span style=\" font-size:8pt;\">©绍兴防雷中心 All rights reserved</span></p></body></html>"))
开发者ID:LuckyBoy314,项目名称:LightningBulletin_v1,代码行数:42,代码来源:UI.py

示例10: Dialog

# 需要导入模块: from PyQt5.QtWidgets import QTextBrowser [as 别名]
# 或者: from PyQt5.QtWidgets.QTextBrowser import setHtml [as 别名]

#.........这里部分代码省略.........
        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()
    
    def setConvertedText(self, text=''):
        self._convertedtext = text
        self.buttons.button(QDialogButtonBox.Ok).setEnabled(bool(text))
        if text:
            self.diff.setHtml(htmldiff.htmldiff(
                self._text, text,
                _("Current Document"), _("Converted Document"),
                wrapcolumn=100))
        else:
            self.diff.clear()
            
    def setDiffText(self, text=''):
        if text:
            from_filename = "current"   # TODO: maybe use real filename here
            to_filename = "converted"   # but difflib can choke on non-ascii characters,
                                        # see https://github.com/wbsoft/frescobaldi/issues/674
            difflist = list(difflib.unified_diff(
                    self._text.split('\n'), text.split('\n'), 
                    from_filename, to_filename))
            diffHLstr = self.diffHighl(difflist)
            self.uni_diff.setHtml(diffHLstr)
        else:
            self.uni_diff.clear()
    
    def convertedText(self):
        return self._convertedtext or ''
    
    def setDocument(self, doc):
        v = documentinfo.docinfo(doc).version_string()
        if v:
            self.fromVersion.setText(v)
            self.reason.setText(_("(set in document)"))
        else:
            self.reason.clear()
        self._text = doc.toPlainText()
        self._encoding = doc.encoding() or 'UTF-8'
        self.setConvertedText()
开发者ID:AlexSchr,项目名称:frescobaldi,代码行数:70,代码来源:convert_ly.py

示例11: AboutWhat

# 需要导入模块: from PyQt5.QtWidgets import QTextBrowser [as 别名]
# 或者: from PyQt5.QtWidgets.QTextBrowser import setHtml [as 别名]

#.........这里部分代码省略.........
               p1 {font-size: 16px;
                   font-family: "%s";
                   margin-right:50px;
                   margin-left:50px;
                   }
               </style>
               </head>
               <body>
               """ % (fontfamily, fontfamily)

        # ---- Banner

        html += """
                <p align="left">
                  <br><img src="file:///%s" width="%d"><br>
                </p>
                """ % (filename, width)

        # ---- Copyrights

        html += """
                <br>
                <p1 align="right">
                  GWHAT version %s released on %s<br>
                  Copyright 2014-2018
                  <a href="https://github.com/jnsebgosselin/gwhat/graphs/contributors">
                    GWHAT Project Contributors
                  </a>
                  <br>
                  Licensed under the terms of the GNU General Public License Version 3
                  <br>
                  <a href="%s">%s</a>
                  <br>
                  <br>
                  Created by Jean-S&eacute;bastien Gosselin
                  <br>
                  <a href="mailto:[email protected]">
                    [email protected]
                  </a>
                  <br>
                  <br>
                  Developped and maintained by Jean-S&eacute;bastien Gosselin
                  <br>
                  Institut National de la Recherche Scientifique<br>
                  Research Center Eau-Terre-Environnement, Quebec City,
                  QC, Canada<br>
                  <a href="http://www.ete.inrs.ca/">
                    http://www.ete.inrs.ca
                  </a>
                  <br>
                </p1>
                """ % (__version__, __date__,
                       __project_url__, __project_url__)

        # ---- License

        html += """
                <p align="justify">
                  %s is free software: you can redistribute it and/or
                  modify it under the terms
                  of the GNU General Public License as published by the
                  Free Software Foundation, either version 3 of the
                  License, or (at your option) any later version.
                </p>
                <p align="justify">
                  This program is distributed in the hope that it will be
                  useful, but WITHOUT ANY WARRANTY; without even the
                  implied warranty of MERCHANTABILITY or FITNESS FOR A
                  PARTICULAR PURPOSE. See the GNU General Public
                  License for more details.
                </p>
                <p align="justify">
                  You should have received a copy of the GNU General
                  Public License along with this program.  If not, see
                  <a href="http://www.gnu.org/licenses">
                    http://www.gnu.org/licenses
                  </a>.
                </p>
                </body>
                """ % __namever__

        self.AboutTextBox.setHtml(html)

    # =========================================================================

    def eventFilter(self, obj, event):
        # http://stackoverflow.com/questions/13788452/
        # pyqt-how-to-handle-event-without-inheritance

        # https://srinikom.github.io/pyside-docs/PySide/QtCore/QObject.
        # html#PySide.QtCore.PySide.QtCore.QObject.installEventFilter

        if event.type() == QEvent.FontChange:
            return True  # Eat the event to disable zooming
        else:
            return QWidget.eventFilter(self, obj, event)

    def show(self):
        super(AboutWhat, self).show()
        self.setFixedSize(self.size())
开发者ID:jnsebgosselin,项目名称:WHAT,代码行数:104,代码来源:about.py

示例12: About

# 需要导入模块: from PyQt5.QtWidgets import QTextBrowser [as 别名]
# 或者: from PyQt5.QtWidgets.QTextBrowser import setHtml [as 别名]
class About(QDialog):

    ICON = util.file_path(__file__, "icon.png")

    def __init__(self, parent=None):
        super().__init__(parent)

        self.setWindowModality(QtCore.Qt.ApplicationModal)
        self.setWindowTitle('About Linux Show Player')
        self.setMaximumSize(500, 420)
        self.setMinimumSize(500, 420)
        self.resize(500, 420)

        self.setLayout(QGridLayout())

        self.icon = QLabel(self)
        self.icon.setPixmap(QPixmap(self.ICON).scaled(100, 100,
                            transformMode=Qt.SmoothTransformation))
        self.layout().addWidget(self.icon, 0, 0)

        self.shortInfo = QLabel(self)
        self.shortInfo.setAlignment(Qt.AlignCenter)
        self.shortInfo.setText('<h2>Linux Show Player   ' +
                               str(lisp.__version__) + '</h2>'
                               'Copyright © Francesco Ceruti')
        self.layout().addWidget(self.shortInfo, 0, 1)

        self.layout().addWidget(QWidget(), 1, 0, 1, 2)

        # Informations tabs
        self.tabWidget = QTabWidget(self)
        self.layout().addWidget(self.tabWidget, 2, 0, 1, 2)

        self.info = QTextBrowser(self)
        self.info.setOpenExternalLinks(True)
        self.info.setHtml(self.INFO)
        self.tabWidget.addTab(self.info, 'Info')

        self.license = QTextBrowser(self)
        self.license.setOpenExternalLinks(True)
        self.license.setHtml(self.LICENSE)
        self.tabWidget.addTab(self.license, 'License')

        self.contributors = QTextBrowser(self)
        self.contributors.setOpenExternalLinks(True)
        self.contributors.setHtml(self.CONTRIBUTORS)
        self.tabWidget.addTab(self.contributors, 'Contributors')

        # Ok button
        self.buttons = QDialogButtonBox(QDialogButtonBox.Ok)
        self.buttons.accepted.connect(self.accept)
        self.layout().addWidget(self.buttons, 3, 1)

        self.layout().setColumnStretch(0, 1)
        self.layout().setColumnStretch(1, 3)

        self.layout().setRowStretch(0, 6)
        self.layout().setRowStretch(1, 1)
        self.layout().setRowStretch(2, 16)
        self.layout().setRowStretch(3, 3)

        self.buttons.setFocus()

    LICENSE = '''
<center>
    Linux Show Player is free software: you can redistribute it and/or
    modify it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.<br />
    <br />
    Linux Show Player is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.
</center>'''

    INFO = '''
<center><br />
    Linux Show Player is a cue-player designed for stage productions.<br \>
</center>
<center><br />
    Web site: <a href="http://linux-show-player.sourceforge.net">linux-show-player.sourceforge.net</a><br \>
    User group: <a href="http://groups.google.com/group/linux-show-player---users">groups.google.com</a><br \>
    Source code: <a href="https://github.com/FrancescoCeruti/linux-show-player">GitHub</a>
</center>'''

    CONTRIBUTORS = '''
开发者ID:tornel,项目名称:linux-show-player,代码行数:89,代码来源:about.py

示例13: LayoutSelect

# 需要导入模块: from PyQt5.QtWidgets import QTextBrowser [as 别名]
# 或者: from PyQt5.QtWidgets.QTextBrowser import setHtml [as 别名]
class LayoutSelect(QDialog):

    def __init__(self, parent=None):
        super().__init__(parent)

        self.filepath = ''
        self.layouts = {}

        self.setWindowModality(Qt.ApplicationModal)
        self.setWindowTitle('Layout selection')
        self.setMaximumSize(675, 300)
        self.setMinimumSize(675, 300)
        self.resize(675, 300)

        self.setLayout(QGridLayout(self))
        self.layout().setContentsMargins(5, 5, 5, 5)

        self.layoutBox = QComboBox(self)
        self.layout().addWidget(self.layoutBox, 0, 0)

        self.layButton = QPushButton(self)
        self.layButton.setText('Select layout')
        self.layout().addWidget(self.layButton, 0, 1)

        self.fileButton = QPushButton(self)
        self.fileButton.setText('Open file')
        self.layout().addWidget(self.fileButton, 0, 2)

        self.layout().setColumnStretch(0, 3)
        self.layout().setColumnStretch(1, 2)
        self.layout().setColumnStretch(2, 1)

        line = QFrame(self)
        line.setFrameShape(QFrame.HLine)
        line.setFrameShadow(QFrame.Sunken)
        self.layout().addWidget(line, 1, 0, 1, 3)

        self.description = QTextBrowser(self)
        self.layout().addWidget(self.description, 2, 0, 1, 3)

        for layout_class in layouts.get_layouts():
            self.layoutBox.addItem(layout_class.NAME)
            self.layouts[layout_class.NAME] = (layout_class,
                                               layout_class.DESCRIPTION)

        if self.layoutBox.count() == 0:
            raise Exception('No layout installed!')

        self.show_description(self.layoutBox.currentText())

        self.layoutBox.currentTextChanged.connect(self.show_description)
        self.layButton.clicked.connect(self.accept)
        self.fileButton.clicked.connect(self.open_file)

    def selected(self):
        return self.layouts[self.layoutBox.currentText()][0]

    def show_description(self, layout_name):
        self.description.setHtml('<center><h2>' + layout_name +
                                 '</h2></center><br>' +
                                 self.layouts[layout_name][1])

    def open_file(self):
        path, _ = QFileDialog.getOpenFileName(self, filter='*.lsp',
                                              directory=os.getenv('HOME'))
        self.filepath = path
        self.accept()

    def closeEvent(self, e):
        e.ignore()
开发者ID:chippey,项目名称:linux-show-player,代码行数:72,代码来源:layoutselect.py

示例14: PluginsManagerWidget

# 需要导入模块: from PyQt5.QtWidgets import QTextBrowser [as 别名]
# 或者: from PyQt5.QtWidgets.QTextBrowser import setHtml [as 别名]
class PluginsManagerWidget(QDialog):
    """Plugin Manager widget"""

    def __init__(self, parent):
        super(PluginsManagerWidget, self).__init__(parent, Qt.Dialog)
        self.setWindowTitle(translations.TR_PLUGIN_MANAGER)
        self.resize(700, 600)

        vbox = QVBoxLayout(self)
        self._tabs = QTabWidget()
        vbox.addWidget(self._tabs)
        self._txt_data = QTextBrowser()
        self._txt_data.setOpenLinks(False)
        vbox.addWidget(QLabel(translations.TR_PROJECT_DESCRIPTION))
        vbox.addWidget(self._txt_data)
        # Footer
        hbox = QHBoxLayout()
        btn_close = QPushButton(translations.TR_CLOSE)
        btnReload = QPushButton(translations.TR_RELOAD)
        hbox.addWidget(btn_close)
        hbox.addSpacerItem(QSpacerItem(1, 0, QSizePolicy.Expanding))
        hbox.addWidget(btnReload)
        vbox.addLayout(hbox)
        self.overlay = ui_tools.Overlay(self)
        self.overlay.hide()

        self._oficial_available = []
        self._community_available = []
        self._locals = []
        self._updates = []
        self._loading = True
        self._requirements = {}

        btnReload.clicked['bool'].connect(self._reload_plugins)
        self.thread = ThreadLoadPlugins(self)
        self.thread.finished.connect(self._load_plugins_data)
        self.thread.plugin_downloaded.connect(self._after_download_plugin)
        self.thread.plugin_manually_installed.connect(self._after_manual_install_plugin)
        self.thread.plugin_uninstalled.connect(self._after_uninstall_plugin)
        self._txt_data.anchorClicked['const QUrl&'].connect(self._open_link)
        btn_close.clicked['bool'].connect(self.close)
        self.overlay.show()
        self._reload_plugins()

    def show_plugin_info(self, data):
        """Takes data argument, format for HTML and display it"""
        plugin_description = data[2].replace('\n', '<br>')
        html = HTML_STYLE.format(name=data[0],
            version=data[1], description=plugin_description,
            author=data[3], link=data[4])
        self._txt_data.setHtml(html)

    def _open_link(self, url):
        """Takes an url argument and open the link on web browser"""
        link = url.toString()
        if link.startswith('/plugins/'):
            link = 'http://ninja-ide.org' + link
        webbrowser.open(link)

    def _reload_plugins(self):
        """Reload all plugins"""
        self.overlay.show()
        self._loading = True
        self.thread.runnable = self.thread.collect_data_thread
        self.thread.start()

    def _after_manual_install_plugin(self, plugin):
        """After installing, take plugin and add it to installedWidget items"""
        data = {}
        data['name'] = plugin[0]
        data['version'] = plugin[1]
        data['description'] = ''
        data['authors'] = ''
        data['home'] = ''
        self._installedWidget.add_table_items([data])

    def _after_download_plugin(self, plugin):
        """After installing, take plugin and add it to installedWidget items"""
        oficial_plugin = _get_plugin(plugin[0], self._oficial_available)
        community_plugin = _get_plugin(plugin[0], self._community_available)
        if oficial_plugin:
            self._installedWidget.add_table_items([oficial_plugin])
            self._availableOficialWidget.remove_item(plugin[0])
        elif community_plugin:
            self._installedWidget.add_table_items([community_plugin])
            self._availableCommunityWidget.remove_item(plugin[0])

    def _after_uninstall_plugin(self, plugin):
        """After uninstall plugin,make available plugin corresponding to type"""
        oficial_plugin = _get_plugin(plugin[0], self._oficial_available)
        community_plugin = _get_plugin(plugin[0], self._community_available)
        if oficial_plugin:
            self._availableOficialWidget.add_table_items([oficial_plugin])
            self._installedWidget.remove_item(plugin[0])
        elif community_plugin:
            self._availableCommunityWidget.add_table_items([community_plugin])
            self._installedWidget.remove_item(plugin[0])

    def _load_plugins_data(self):
        """Load all the plugins data"""
#.........这里部分代码省略.........
开发者ID:Salmista-94,项目名称:Ninja_3.0_PyQt5,代码行数:103,代码来源:plugins_manager.py


注:本文中的PyQt5.QtWidgets.QTextBrowser.setHtml方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。