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


Python CodeEditor.toPlainText方法代码示例

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


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

示例1: get_indent_fix

# 需要导入模块: from spyderlib.widgets.sourcecode.codeeditor import CodeEditor [as 别名]
# 或者: from spyderlib.widgets.sourcecode.codeeditor.CodeEditor import toPlainText [as 别名]
def get_indent_fix(text):
    app = qapplication()
    editor = CodeEditor(parent=None)
    editor.setup_editor(language='Python')

    editor.set_text(text)
    cursor = editor.textCursor()
    cursor.movePosition(QTextCursor.End)
    editor.setTextCursor(cursor)
    editor.fix_indent()
    return to_text_string(editor.toPlainText())
开发者ID:DLlearn,项目名称:spyder,代码行数:13,代码来源:test_autoindent.py

示例2: Demo

# 需要导入模块: from spyderlib.widgets.sourcecode.codeeditor import CodeEditor [as 别名]
# 或者: from spyderlib.widgets.sourcecode.codeeditor.CodeEditor import toPlainText [as 别名]
class Demo(QWidget):
    def __init__(self):
        super(Demo, self).__init__()
        self.code_editor = CodeEditor(self)
        self.code_editor.setup_editor(
            language = "python",
            font = QFont("Courier New")
        )
        run_sc = QShortcut(QKeySequence("F5"), self, self.run) 

        self.shell = InternalShell(self, {"demo":self},
            multithreaded = False,
            max_line_count = 3000,
            font = QFont("Courier new", 10),
            message='caonima'
        )

        self.dict_editor = DictEditorWidget(self, {})
        self.dict_editor.editor.set_filter(self.filter_namespace) 
        self.dict_editor.set_data(self.shell.interpreter.namespace) 
        vbox = QVBoxLayout()
        vbox.addWidget(self.code_editor)
        vbox.addWidget(self.shell)

        hbox = QHBoxLayout()
        hbox.addWidget(self.dict_editor)
        hbox.addLayout(vbox)

        self.setLayout(hbox)
        self.resize(800, 600)

    def filter_namespace(self, data):
        result = {}
        support_types = [np.ndarray, int, float, str, tuple, dict, list]
        for key, value in data.items():
            if not key.startswith("__") and type(value) in support_types:
                result[key] = value
        return result

    def run(self):
        code = str(self.code_editor.toPlainText())
        namespace = self.shell.interpreter.namespace
        exec (code,namespace )  
        self.dict_editor.set_data(namespace) 
开发者ID:UpSea,项目名称:midProjects,代码行数:46,代码来源:useOfSpyderShell.py

示例3: PropertiesWidget

# 需要导入模块: from spyderlib.widgets.sourcecode.codeeditor import CodeEditor [as 别名]
# 或者: from spyderlib.widgets.sourcecode.codeeditor.CodeEditor import toPlainText [as 别名]
class PropertiesWidget(QWidget):
    def __init__(self, parent):
        QWidget.__init__(self, parent)
        font = QFont(get_family(MONOSPACE), 10, QFont.Normal)
        
        info_icon = QLabel()
        icon = get_std_icon('MessageBoxInformation').pixmap(24, 24)
        info_icon.setPixmap(icon)
        info_icon.setFixedWidth(32)
        info_icon.setAlignment(Qt.AlignTop)

        self.service_status_label = QLabel()
        self.service_status_label.setWordWrap(True)
        self.service_status_label.setAlignment(Qt.AlignTop)
        self.service_status_label.setFont(font)

        self.desc_label = QLabel()
        self.desc_label.setWordWrap(True)
        self.desc_label.setAlignment(Qt.AlignTop)
        self.desc_label.setFont(font)

        group_desc = QGroupBox("Description", self)
        layout = QHBoxLayout()
        layout.addWidget(info_icon)
        layout.addWidget(self.desc_label)
        layout.addStretch()
        layout.addWidget(self.service_status_label  )

        group_desc.setLayout(layout)
        
        self.editor = CodeEditor(self)
        self.editor.setup_editor(linenumbers=True, font=font)
        self.editor.setReadOnly(False)
        group_code = QGroupBox("Source code", self)
        layout = QVBoxLayout()
        layout.addWidget(self.editor)
        group_code.setLayout(layout)
        
        self.enable_button = QPushButton(get_icon("apply.png"),
                                      "Enable", self)

        self.save_button = QPushButton(get_icon("filesave.png"),
                                      "Save", self)

        self.edit_datadog_conf_button = QPushButton(get_icon("edit.png"),
                                      "Edit agent settings", self)

        self.disable_button = QPushButton(get_icon("delete.png"),
                                      "Disable", self)


        self.view_log_button = QPushButton(get_icon("txt.png"), 
                                      "View log", self)

        self.menu_button = QPushButton(get_icon("settings.png"),
                                      "Manager", self)



        hlayout = QHBoxLayout()
        hlayout.addWidget(self.save_button)
        hlayout.addStretch()
        hlayout.addWidget(self.enable_button)
        hlayout.addStretch()
        hlayout.addWidget(self.disable_button)
        hlayout.addStretch()
        hlayout.addWidget(self.edit_datadog_conf_button)
        hlayout.addStretch()
        hlayout.addWidget(self.view_log_button)
        hlayout.addStretch()
        hlayout.addWidget(self.menu_button)
        
        vlayout = QVBoxLayout()
        vlayout.addWidget(group_desc)
        vlayout.addWidget(group_code)
        vlayout.addLayout(hlayout)
        self.setLayout(vlayout)

        self.current_file = None
        
    def set_item(self, check):
        self.current_file = check
        self.desc_label.setText(check.get_description())
        self.editor.set_text_from_file(check.file_path)
        check.content = self.editor.toPlainText().__str__()
        if check.enabled:
            self.disable_button.setEnabled(True)
            self.enable_button.setEnabled(False)
        else:
            self.disable_button.setEnabled(False)
            self.enable_button.setEnabled(True)

    def set_datadog_conf(self, datadog_conf):
        self.current_file = datadog_conf
        self.desc_label.setText(datadog_conf.get_description())
        self.editor.set_text_from_file(datadog_conf.file_path)
        datadog_conf.content = self.editor.toPlainText().__str__()
        self.disable_button.setEnabled(False)
        self.enable_button.setEnabled(False)

#.........这里部分代码省略.........
开发者ID:arthurnn,项目名称:dd-agent,代码行数:103,代码来源:gui.py


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