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


Python QPlainTextEdit.toPlainText方法代码示例

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


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

示例1: PackageTab

# 需要导入模块: from PyQt5.QtWidgets import QPlainTextEdit [as 别名]
# 或者: from PyQt5.QtWidgets.QPlainTextEdit import toPlainText [as 别名]
class PackageTab(QWidget):
    configChanged = pyqtSignal()
    def __init__(self):
        super(QWidget, self).__init__()
        layout = QFormLayout()
        self.setLayout(layout)

        self.buildDependencies = QPlainTextEdit()
        self.buildDependencies.textChanged.connect(self.buildDependenciesChanged)
        self.buildDependencies.setMinimumHeight(70)
        layout.addRow('Build Dependencies', self.buildDependencies)

        self.runDependencies = QPlainTextEdit()
        self.runDependencies.textChanged.connect(self.runDependenciesChanged)
        self.runDependencies.setMinimumHeight(70)
        layout.addRow('Run Dependencies', self.runDependencies)

    def buildDependenciesChanged(self):
        if self.config is not None:
            self.config.setBuildDependencies(self.buildDependencies.toPlainText())
            self.configChanged.emit()

    def runDependenciesChanged(self):
        if self.config is not None:
            self.config.setRunDependencies(self.runDependencies.toPlainText())
            self.configChanged.emit()

    def setConfig(self, config):
        self.config = config
        self.buildDependencies.setPlainText(self.config.getBuildDependenciesAsText())
        self.runDependencies.setPlainText(self.config.getRunDependenciesAsText())
开发者ID:Diegojnb,项目名称:JdeRobot,代码行数:33,代码来源:rosconfigdialog.py

示例2: ScriptsPage

# 需要导入模块: from PyQt5.QtWidgets import QPlainTextEdit [as 别名]
# 或者: from PyQt5.QtWidgets.QPlainTextEdit import toPlainText [as 别名]
class ScriptsPage(QtWidgets.QWizardPage):
    def __init__(self, Wizard, parent=None):
        super(ScriptsPage, self).__init__(parent)

        self.base = Wizard.base

        self.setTitle(self.tr("Scripts page"))
        self.setSubTitle(self.tr("Write scripts"))

        prepareLabel = QLabel("%prepare: ")
        self.prepareEdit = QPlainTextEdit()

        buildLabel = QLabel("%build: ")
        self.buildEdit = QPlainTextEdit()

        installLabel = QLabel("%install: ")
        self.installEdit = QPlainTextEdit()

        checkLabel = QLabel("%check: ")
        self.checkEdit = QPlainTextEdit()

        buildArchLabel = QLabel("BuildArch: ")
        self.buildArchCheckbox = QCheckBox("noarch")

        grid = QGridLayout()
        grid.addWidget(prepareLabel, 0, 0)
        grid.addWidget(self.prepareEdit, 0, 1)
        grid.addWidget(buildLabel, 1, 0)
        grid.addWidget(self.buildEdit, 1, 1)
        grid.addWidget(installLabel, 2, 0)
        grid.addWidget(self.installEdit, 2, 1)
        grid.addWidget(checkLabel, 3, 0)
        grid.addWidget(self.checkEdit, 3, 1)
        grid.addWidget(buildArchLabel, 4, 0)
        grid.addWidget(self.buildArchCheckbox, 4, 1)
        self.setLayout(grid)

    def validatePage(self):
        self.base.spec.scripts['%prep'] = Command(self.prepareEdit.toPlainText())
        self.base.spec.scripts['%build'] = Command(self.buildEdit.toPlainText())
        self.base.spec.scripts['%install'] = Command(self.installEdit.toPlainText())
        self.base.spec.scripts['%check'] = Command(self.checkEdit.toPlainText())
        if self.buildArchCheckbox.isChecked():
            self.base.spec.tags['BuildArch'] = "noarch"
        else:
            self.base.spec.tags.pop('BuildArch', None)
        return True

    def nextId(self):
        return Wizard.PageRequires
开发者ID:khuno,项目名称:rpg,代码行数:52,代码来源:wizard.py

示例3: CommentEditor

# 需要导入模块: from PyQt5.QtWidgets import QPlainTextEdit [as 别名]
# 或者: from PyQt5.QtWidgets.QPlainTextEdit import toPlainText [as 别名]
class CommentEditor(QWidget):
    textChanged = pyqtSignal()

    def __init__(self, comments=""):
        """
        Just holds a TextEdit and a label
        """
        super(CommentEditor, self).__init__()
        self.top_layout = WidgetUtils.addLayout(vertical=True)
        self.setLayout(self.top_layout)
        self.editor = QPlainTextEdit(self)
        self.editor.resize(10, 10)
        self.editor.setSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred)
        self.editor.setPlainText(comments)
        self.label = WidgetUtils.addLabel(self.top_layout, self, "Comment")
        self.top_layout.addWidget(self.editor)
        self.setSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred)
        self.setMinimumSize(0, 20)
        self.editor.textChanged.connect(self.textChanged)

    def setComments(self, comments):
        self.editor.setPlainText(comments)

    def getComments(self):
        return str(self.editor.toPlainText())
开发者ID:FHilty,项目名称:moose,代码行数:27,代码来源:CommentEditor.py

示例4: EditRelationDialog

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

    sendData = pyqtSignal(list)

    def __init__(self, rname, parent=None):
        super().__init__(parent)
        self._rname = rname
        self.setWindowTitle(self.tr("Editor - {}".format(rname)))
        self.resize(400, 300)
        self.setModal(True)
        vbox = QVBoxLayout(self)
        desc = QLabel(
            self.tr("Ingresar los datos separados por comas y las tuplas\n"
                    "separadas por un salto de línea."))
        vbox.addWidget(desc)
        self._editor = QPlainTextEdit()
        font, size = CONFIG.get("fontFamily"), CONFIG.get("fontSize")
        if font is None:
            font, size = CONFIG._get_font()
        f = QFont(font, size)
        self._editor.setFont(f)
        vbox.addWidget(self._editor)
        self._editor.setCursorWidth(3)
        self._editor.setPlaceholderText("1,Gabriel,Python")

        hbox = QHBoxLayout()
        hbox.addStretch(1)
        btn_accept = QPushButton(self.tr("Agregar Tuplas"))
        btn_accept.setIcon(
            self.style().standardIcon(QStyle.SP_DialogApplyButton))
        hbox.addWidget(btn_accept)
        btn_cancel = QPushButton(self.tr("Cancelar"))
        btn_cancel.setIcon(
            self.style().standardIcon(QStyle.SP_DialogCancelButton))
        hbox.addWidget(btn_cancel)

        vbox.addLayout(hbox)

        btn_cancel.clicked.connect(self.close)
        btn_accept.clicked.connect(self._on_accept)

    def _on_accept(self):
        central = Pireal.get_service("central")
        table_widget = central.get_active_db().table_widget
        relation = table_widget.relations[self._rname]
        lines = self._editor.toPlainText().splitlines()
        tuples = [tuple(t.split(",")) for t in lines]
        for e, t in enumerate(tuples):
            if len(t) != relation.degree():
                QMessageBox.critical(
                    self,
                    "Error",
                    self.tr("La relación <b>{}</b> es de grado <b>{}</b>.<br> "
                            "Ingresaste <b>{}</b> datos a la "
                            "tupla <b>{}</b> :/".format(
                                self._rname,
                                relation.degree(), len(t), e + 1)))
                return
        self.sendData.emit(tuples)
        self.close()
开发者ID:yoshitomimaehara,项目名称:pireal,代码行数:62,代码来源:edit_relation_dialog.py

示例5: CreateTaskDialog

# 需要导入模块: from PyQt5.QtWidgets import QPlainTextEdit [as 别名]
# 或者: from PyQt5.QtWidgets.QPlainTextEdit import toPlainText [as 别名]
class CreateTaskDialog(OkCancelDialog):
    """
    Dialog with input fields to create a new task.
    """

    accepted = pyqtSignal(str, str, name="accepted")

    def __init__(self, *args, **kwargs):
        # Add the layout.
        layout = QFormLayout()
        super().__init__("Create a new task", layout, *args, **kwargs)

        # Add the input fields.
        self.input_title = QLineEdit()
        layout.addRow("Title:", self.input_title)
        self.input_description = QPlainTextEdit()
        layout.addRow("Description:", self.input_description)

    def accept(self):
        """
        Accept the dialog if the title is non-empty.
        """
        title = self.input_title.text()
        description = self.input_description.toPlainText()
        if len(title) == 0:
            self.show_error("Title must not be empty.")
        else:
            self.accepted.emit(title, description)
            self.close()
开发者ID:dagophil,项目名称:mesme,代码行数:31,代码来源:create_task_dialog.py

示例6: Window

# 需要导入模块: from PyQt5.QtWidgets import QPlainTextEdit [as 别名]
# 或者: from PyQt5.QtWidgets.QPlainTextEdit import toPlainText [as 别名]
class Window(QWidget):

    def __init__(self):
        super().__init__()

        # Make widgets #################

        self.edit = QPlainTextEdit()
        self.btn = QPushButton("Print")

        self.edit.setPlaceholderText("Type something here and press the 'Print' button")

        # Set button slot ##############

        self.btn.clicked.connect(self.printText)

        # Set the layout ###############

        vbox = QVBoxLayout()

        vbox.addWidget(self.edit)
        vbox.addWidget(self.btn)

        self.setLayout(vbox)

    def printText(self):
        print(self.edit.toPlainText())
开发者ID:jeremiedecock,项目名称:snippets,代码行数:29,代码来源:widget_QPlainTextEdit.py

示例7: GalleryListEdit

# 需要导入模块: from PyQt5.QtWidgets import QPlainTextEdit [as 别名]
# 或者: from PyQt5.QtWidgets.QPlainTextEdit import toPlainText [as 别名]
class GalleryListEdit(misc.BasePopup):
    apply = pyqtSignal()
    def __init__(self, parent=None):
        super().__init__(parent, blur=False)
        main_layout = QFormLayout(self.main_widget)
        self.name_edit = QLineEdit(self)
        main_layout.addRow("Name:", self.name_edit)
        self.filter_edit = QPlainTextEdit(self)
        self.filter_edit.setPlaceholderText("tag1, namespace:tag2, namespace2:[tag1, tag2] ...")
        self.filter_edit.setFixedHeight(100)
        what_is_filter = misc.ClickedLabel("What is Filter/Enforce? (Hover)")
        what_is_filter.setToolTip(app_constants.WHAT_IS_FILTER)
        what_is_filter.setToolTipDuration(9999999999)
        self.enforce = QCheckBox(self)
        self.regex = QCheckBox(self)
        self.case = QCheckBox(self)
        self.strict = QCheckBox(self)
        main_layout.addRow(what_is_filter)
        main_layout.addRow("Filter", self.filter_edit)
        main_layout.addRow("Enforce", self.enforce)
        main_layout.addRow("Regex", self.regex)
        main_layout.addRow("Case sensitive", self.case)
        main_layout.addRow("Match whole terms", self.strict)
        main_layout.addRow(self.buttons_layout)
        self.add_buttons("Close")[0].clicked.connect(self.hide)
        self.add_buttons("Apply")[0].clicked.connect(self.accept)
        old_v = self.width()
        self.adjustSize()
        self.resize(old_v, self.height())

    def set_list(self, gallery_list, item):
        self.gallery_list = gallery_list
        self.name_edit.setText(gallery_list.name)
        self.enforce.setChecked(gallery_list.enforce)
        self.regex.setChecked(gallery_list.regex)
        self.case.setChecked(gallery_list.case)
        self.strict.setChecked(gallery_list.strict)
        self.item = item
        if gallery_list.filter:
            self.filter_edit.setPlainText(gallery_list.filter)
        else:
            self.filter_edit.setPlainText('')

    def accept(self):
        name = self.name_edit.text()
        self.item.setText(name)
        self.gallery_list.name = name
        self.gallery_list.filter = self.filter_edit.toPlainText()
        self.gallery_list.enforce = self.enforce.isChecked()
        self.gallery_list.regex = self.regex.isChecked()
        self.gallery_list.case = self.case.isChecked()
        self.gallery_list.strict = self.strict.isChecked()
        gallerydb.execute(gallerydb.ListDB.modify_list, True, self.gallery_list)
        self.apply.emit()
        self.hide()
开发者ID:Pewpews,项目名称:happypanda,代码行数:57,代码来源:misc_db.py

示例8: Ui_manual

# 需要导入模块: from PyQt5.QtWidgets import QPlainTextEdit [as 别名]
# 或者: from PyQt5.QtWidgets.QPlainTextEdit import toPlainText [as 别名]
class Ui_manual(QWidget):
    def __init__(self):

        super(Ui_manual, self).__init__()
        self.initUi(self)

    def initUi(self, manual):
        manual.setObjectName(_fromUtf8("manual"))
        manual.resize(588, 209)
        self.plainTextEdit = QPlainTextEdit(manual)
        self.plainTextEdit.setGeometry(QtCore.QRect(10, 50, 571, 121))
        self.plainTextEdit.setObjectName(_fromUtf8("plainTextEdit"))
        self.button_quit = QPushButton(manual)
        self.button_quit.setGeometry(QtCore.QRect(460, 170, 110, 32))
        self.button_quit.setObjectName(_fromUtf8("button_quit"))
        self.button_execute = QPushButton(manual)
        self.button_execute.setGeometry(QtCore.QRect(360, 170, 110, 32))
        self.button_execute.setObjectName(_fromUtf8("button_execute"))
        self.label = QLabel(manual)
        self.label.setGeometry(QtCore.QRect(10, 10, 561, 31))
        self.label.setObjectName(_fromUtf8("label"))

        self.retranslateUi(manual)
        QtCore.QMetaObject.connectSlotsByName(manual)

        #self.connect(self.button_quit, QtCore.SIGNAL("released()"), self.quit)
        #self.connect(self.button_execute, QtCore.SIGNAL("released()"), self.launchcmd)
        self.button_quit.clicked.connect(self.quit)
        self.button_execute.clicked.connect(self.launchcmd)

    def quit (self) :
        self.close()

    def launchcmd (self) :
        cmd=self.plainTextEdit.toPlainText()
        cmd=str(cmd)
        allconn=cursor.connection()
        curs=allconn[0]
        data=allconn[1]
        try :
            curs.execute(cmd)
            data.commit()
            data.close()
            self.plainTextEdit.setPlainText('')
            QMessageBox.information(self, "Success", "Command executed sucessfully")
        except :
            QMessageBox.information(self, "Error", "Bad Command : Databse operation interrupted")



    def retranslateUi(self, manual):
        manual.setWindowTitle(_translate("manual", "Manual Input", None))
        self.button_quit.setText(_translate("manual", "Quit", None))
        self.button_execute.setText(_translate("manual", "Execute", None))
        self.label.setText(_translate("manual", "WARNING ! : Manual inputs are very dangerous and can lead to a dramatic database collapse !", None))
开发者ID:dedichan,项目名称:ChemDB,代码行数:57,代码来源:manual.py

示例9: __init__

# 需要导入模块: from PyQt5.QtWidgets import QPlainTextEdit [as 别名]
# 或者: from PyQt5.QtWidgets.QPlainTextEdit import toPlainText [as 别名]
class ConfigFile:
    def __init__(self, display_name, absolute_name, tab, deletable=True):
        self.display_name   = display_name # is unique
        self.absolute_name  = absolute_name # is also unique
        self.tab            = tab
        self.deletable      = deletable
        self.index          = -1
        self.modified       = False
        self.content        = None
        self.edit           = QPlainTextEdit()

        font = QFont('monospace')
        font.setStyleHint(QFont.TypeWriter)

        self.edit.setWordWrapMode(QTextOption.NoWrap)
        self.edit.setFont(font)
        self.edit.textChanged.connect(self.check_content)

    def check_content(self):
        self.set_modified(self.content != self.edit.toPlainText())

    def set_modified(self, modified):
        if self.modified == modified:
            return

        self.modified = modified

        self.tab.combo_config.setItemText(self.index, self.get_combo_item())
        self.tab.update_ui_state()

    def set_content(self, content):
        # FIXME: QPlainTextEdit does not preserve the original line endings, but
        #        converts all line endings to \n. this results in a difference
        #        between self.content and the content stored in the QPlainTextEdit
        #        even if the user did not edit the content. avoid this problem
        #        by converting all line endings to \n before setting the content
        #        of the QPlainTextEdit
        content = content.replace('\r\n', '\n')

        if self.content == None:
            self.edit.setPlainText(content)

        self.content = content

        self.check_content()

    def get_combo_item(self):
        if self.modified:
            return self.display_name + ' (modified)'
        else:
            return self.display_name

    def discard_changes(self):
        self.edit.setPlainText(self.content)
        self.set_modified(False)
开发者ID:Tinkerforge,项目名称:brickv,代码行数:57,代码来源:red_tab_settings_openhab.py

示例10: RequiresPage

# 需要导入模块: from PyQt5.QtWidgets import QPlainTextEdit [as 别名]
# 或者: from PyQt5.QtWidgets.QPlainTextEdit import toPlainText [as 别名]
class RequiresPage(QtWidgets.QWizardPage):
    def __init__(self, Wizard, parent=None):
        super(RequiresPage, self).__init__(parent)

        self.base = Wizard.base

        self.setTitle(self.tr("Requires page"))
        self.setSubTitle(self.tr("Write requires and provides"))

        buildRequiresLabel = QLabel("BuildRequires: ")
        self.bRequiresEdit = QPlainTextEdit()
        self.bRequiresEdit.setMaximumHeight(40)

        requiresLabel = QLabel("Requires: ")
        self.requiresEdit = QPlainTextEdit()
        self.requiresEdit.setMaximumHeight(40)

        preovidesLabel = QLabel("Provides: ")
        self.previdesEdit = QPlainTextEdit()

        grid = QGridLayout()
        grid.addWidget(buildRequiresLabel, 0, 0)
        grid.addWidget(self.bRequiresEdit, 1, 0)
        grid.addWidget(requiresLabel, 2, 0)
        grid.addWidget(self.requiresEdit, 3, 0,)
        grid.addWidget(preovidesLabel, 4, 0)
        grid.addWidget(self.previdesEdit, 5, 0)
        self.setLayout(grid)

    def validatePage(self):
        self.base.spec.tags["BuildRequires"] = self.bRequiresEdit.toPlainText()
        self.base.spec.tags["Requires"] = self.requiresEdit.toPlainText()
        self.base.spec.tags["Provides"] = self.previdesEdit.toPlainText()
        self.base.build_project()
        self.base.run_compiled_analysis()
        self.base.install_project()
        self.base.run_installed_analysis()
        return True

    def nextId(self):
        return Wizard.PageSubpackages
开发者ID:khuno,项目名称:rpg,代码行数:43,代码来源:wizard.py

示例11: QMakePage

# 需要导入模块: from PyQt5.QtWidgets import QPlainTextEdit [as 别名]
# 或者: from PyQt5.QtWidgets.QPlainTextEdit import toPlainText [as 别名]
class QMakePage(QWidget):
    """ The GUI for the qmake page of a project. """

    # The page's label.
    label = "qmake"

    @property
    def project(self):
        """ The project property getter. """

        return self._project

    @project.setter
    def project(self, value):
        """ The project property setter. """

        if self._project != value:
            self._project = value

            blocked = self._qmake_edit.blockSignals(True)
            self._qmake_edit.setPlainText(self._project.qmake_configuration)
            self._qmake_edit.blockSignals(blocked)

    def __init__(self):
        """ Initialise the page. """

        super().__init__()

        self._project = None

        # Create the page's GUI.
        layout = QVBoxLayout()

        self._qmake_edit = QPlainTextEdit(
                whatsThis="Any text entered here will be appended to the "
                        "generated <tt>.pro</tt> that will be processed by "
                        "<tt>qmake</tt>.",
                textChanged=self._qmake_changed)
        layout.addWidget(self._qmake_edit)

        self.setLayout(layout)

    def _qmake_changed(self):

        self.project.qmake_configuration = self._qmake_edit.toPlainText()
        self.project.modified = True
开发者ID:GreatFruitOmsk,项目名称:pyqtdeploy,代码行数:48,代码来源:qmake_page.py

示例12: ScripletsPage

# 需要导入模块: from PyQt5.QtWidgets import QPlainTextEdit [as 别名]
# 或者: from PyQt5.QtWidgets.QPlainTextEdit import toPlainText [as 别名]
class ScripletsPage(QtWidgets.QWizardPage):
    def __init__(self, Wizard, parent=None):
        super(ScripletsPage, self).__init__(parent)

        self.base = Wizard.base

        self.setTitle(self.tr("Scriplets page"))
        self.setSubTitle(self.tr("Write scriplets"))

        pretransLabel = QLabel("%pretrans: ")
        self.pretransEdit = QPlainTextEdit()

        preLabel = QLabel("%pre: ")
        self.preEdit = QPlainTextEdit()

        postLabel = QLabel("%post: ")
        self.postEdit = QPlainTextEdit()

        postunLabel = QLabel("%postun: ")
        self.postunEdit = QPlainTextEdit()

        preunLabel = QLabel("%preun: ")
        self.preunEdit = QPlainTextEdit()

        posttransLabel = QLabel("%posttrans: ")
        self.posttransEdit = QPlainTextEdit()

        grid = QGridLayout()
        grid.addWidget(pretransLabel, 0, 0)
        grid.addWidget(self.pretransEdit, 0, 1)
        grid.addWidget(preLabel, 1, 0)
        grid.addWidget(self.preEdit, 1, 1,)
        grid.addWidget(postLabel, 2, 0)
        grid.addWidget(self.postEdit, 2, 1)
        grid.addWidget(postunLabel, 3, 0)
        grid.addWidget(self.postunEdit, 3, 1)
        grid.addWidget(preunLabel, 4, 0)
        grid.addWidget(self.preunEdit, 4, 1,)
        grid.addWidget(posttransLabel, 5, 0)
        grid.addWidget(self.posttransEdit, 5, 1)
        self.setLayout(grid)

    def validatePage(self):
        self.base.spec.scripts["%pretrans"] = self.pretransEdit.toPlainText()
        self.base.spec.scripts["%pre"] = self.preEdit.toPlainText()
        self.base.spec.scripts["%post"] = self.postEdit.toPlainText()
        self.base.spec.scripts["%postun"] = self.postunEdit.toPlainText()
        self.base.spec.scripts["%preun"] = self.preunEdit.toPlainText()
        self.base.spec.scripts["%posttrans"] = self.posttransEdit.toPlainText()
        return True

    def nextId(self):
        return Wizard.PageDocsChangelog
开发者ID:khuno,项目名称:rpg,代码行数:55,代码来源:wizard.py

示例13: TextpadWidget

# 需要导入模块: from PyQt5.QtWidgets import QPlainTextEdit [as 别名]
# 或者: from PyQt5.QtWidgets.QPlainTextEdit import toPlainText [as 别名]
class TextpadWidget(QFrame):
    def __init__(self, parent):
        QFrame.__init__(self, parent)
        self.textpad = QPlainTextEdit(self)
        self.setLayout(QHBoxLayout())
        self.layout().setContentsMargins(0, 0, 0, 0)
        self.layout().addWidget(self.textpad)

        self.setFrameStyle(QFrame.Box | QFrame.Sunken)
        self.setStyleSheet("QPlainTextEdit{background:transparent;}")

        settings = self.window().platform.getSettings()
        text = settings.value("textpad", "")
        self.textpad.setPlainText(text)

    def finalize(self):
        settings = self.window().platform.getSettings()
        settings.setValue("textpad", self.textpad.toPlainText())
开发者ID:hgoldfish,项目名称:quickpanel,代码行数:20,代码来源:textpad.py

示例14: UserElementSettings

# 需要导入模块: from PyQt5.QtWidgets import QPlainTextEdit [as 别名]
# 或者: from PyQt5.QtWidgets.QPlainTextEdit import toPlainText [as 别名]
class UserElementSettings(SettingsSection):

    NAME = "Personalized"
    ELEMENT = UserElement

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

        self.id = Id

        self.groupBox = QGroupBox("User defined elements", self)
        self.groupBox.setGeometry(self.geometry())

        self.layout = QVBoxLayout(self.groupBox)

        self.textEdit = QPlainTextEdit(self.groupBox)
        self.layout.addWidget(self.textEdit)

        self.warning = QLabel(self.groupBox)
        self.warning.setText("Only for advanced user.")
        self.warning.setAlignment(QtCore.Qt.AlignCenter)
        self.warning.setStyleSheet("color: red; font-weight: bold")
        self.layout.addWidget(self.warning)

    def enable_check(self, enable):
        self.groupBox.setCheckable(enable)
        self.groupBox.setChecked(False)

    def set_configuration(self, conf):
        if conf is not None and self.id in conf:
            self.textEdit.setPlainText(conf[self.id]["bin"])

    def get_configuration(self):
        conf = {}

        if not (self.groupBox.isCheckable() and not self.groupBox.isChecked()):
            conf[self.id] = {"bin": self.textEdit.toPlainText().strip()}

        return conf
开发者ID:tornel,项目名称:linux-show-player,代码行数:41,代码来源:user_element.py

示例15: MyApp

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

#.........这里部分代码省略.........
		# self.hideBtn=setShortcut(QtGui.QKeySequence('Ctrl+B'))
		settingLayout.addLayout(hLayout)
		self.settingWindow.setLayout(settingLayout)
		# Qt.Tool的作用是  不在任务栏显示
		self.settingWindow.setWindowFlags(Qt.FramelessWindowHint|Qt.Tool\
			|Qt.X11BypassWindowManagerHint|Qt.Popup)
		self.roomName.show()
		self.createBtn.show()
		self.settingWindow.resize(160,26)
		self.settingWindow.show()


		# self.btnFire=QPushButton("Fire",self)
		# self.btnFire.resize(60,60)
		# self.btnFire.move(100,30)
		# self.btnFire.show()

		# self.btnLock=QPushButton("Lock",self)
		# self.btnLock.resize(40,40)
		# self.btnLock.move(self.screenWidth/2,30)
		# self.btnLock.setFlat(True)
		# self.btnLock.setIcon(QtGui.QIcon("tmpIcon.png"))
		# self.btnLock.show()



		# self.danmakuEditText=QPlainTextEdit(self)
		# self.danmakuEditText.resize(200,100)
		# self.danmakuEditText.move(100,100)
		# self.danmakuEditText.setBackgroundVisible(False)
		# self.danmakuEditText.show()

	def joinRoom(self):
		name=self.roomName.toPlainText()
		self.socketio.emit('join',name)

	def connect2Server(self):
		self.socketio=SocketIO('115.159.102.76/bulletgo_client',80,LoggingNamespace)
		self.registerEvents()
		# 开新线程监听服务器发来的消息,否则主线程被阻塞
		_thread.start_new_thread(self.socketio.wait,())

	def registerEvents(self):
		self.socketio.on('create_rsp',lambda rsp:self.handleIncomeBullet(rsp))
		self.socketio.on('bullet',lambda msg:self.handleIncomeBullet(msg))
		self.socketio.on('control_msg',lambda msg:print\
			('---control message---  : '+msg))
		self.socketio.on('sys_notification',lambda msg:print\
			('---system notification---  : '+msg))

	def handleIncomeBullet(self,bulletMsg):
		textsAndInfo=self.preProcessText(bulletMsg)
		if(len(textsAndInfo)>1):
			self.fireABullet(textsAndInfo[0],self.genQColorFromStr(textsAndInfo[1]))

	def createRoom_Nodejs(self,name):
		self.socketio.emit('create_room',name)

	def fireBtn(self):
		txt=self.danmakuEditText.toPlainText()
		tmpbullet=Bullet(txt,GLOBAL.ORANGE,random.randrange(9,16,2))
		self.bullets.append(tmpbullet)
		tmpbullet.prepare()
		# print(len(self.bullets))
		# testStr="line1\nline2\nline3"
		# textsAndInfo=self.preProcessText(testStr)
开发者ID:Envl,项目名称:BulletGo,代码行数:70,代码来源:BulletGo.py


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