コード例 #1
0
def main():
    app = QtWidgets.QApplication(sys.argv)
    window = QtWidgets.QMainWindow()

    # code from the simple example
    editor = api.CodeEdit()
    editor.file.open(__file__)
    editor.modes.append(modes.CaretLineHighlighterMode())
    sh = modes.PygmentsSyntaxHighlighter(editor.document())
    editor.modes.append(sh)
    editor.panels.append(panels.SearchAndReplacePanel(),
                      api.Panel.Position.TOP)
    # make the code edit show whitespaces in dark gray
    editor.show_white_spaces = True
    editor.whitespaces_foreground = QtGui.QColor('#606020')

    # make a dark editor using the monokai theme
    sh.pygments_style = 'monokai'

    window.setCentralWidget(editor)
    window.show()

    app.exec_()

    editor.file.close()
    del editor
    del window
    del app
コード例 #2
0
ファイル: basic.py プロジェクト: zwadar/pyqode.core
def main():
    app = QtWidgets.QApplication(sys.argv)

    # create editor and window
    window = QtWidgets.QMainWindow()
    editor = api.CodeEdit()
    window.setCentralWidget(editor)

    # start the backend as soon as possible
    editor.backend.start('server.py')

    # append some modes and panels
    editor.modes.append(modes.CodeCompletionMode())
    editor.modes.append(modes.CaretLineHighlighterMode())
    editor.modes.append(modes.PygmentsSyntaxHighlighter(editor.document()))
    editor.panels.append(panels.SearchAndReplacePanel(),
                         api.Panel.Position.BOTTOM)

    # open a file
    editor.file.open(__file__)

    # run
    window.show()
    app.exec_()
    editor.file.close()
コード例 #3
0
def test_frozen_server():
    global backend_manager
    win = QtWidgets.QMainWindow()
    backend_manager = BackendManager(win)
    with pytest.raises(NotRunning):
        backend_manager.send_request(backend.echo_worker,
                                     'some data',
                                     on_receive=_on_receive)
    backend_manager.start('server.exe')
コード例 #4
0
ファイル: common.py プロジェクト: SunChuquin/pyqode.core
def setup_editor(modes=None, panels=None):
    global _window
    _window = QtWidgets.QMainWindow()
    _window.setMinimumSize(800, 600)
    editor = api.CodeEdit(_window)
    _window.setCentralWidget(editor)
    _window.show()
    if modes:
        for mode in modes:
            editor.modes.append(mode)
    if panels:
        for panel, position in panels:
            editor.panels.append(panel, position)
    return editor
コード例 #5
0
def main():
    app = QtWidgets.QApplication(sys.argv)

    # create editor and window
    window = QtWidgets.QMainWindow()
    editor = GenericCodeEdit()

    # open a file
    editor.file.open(__file__)
    window.setCentralWidget(editor)

    # run
    window.show()
    app.exec_()
    editor.file.close()
コード例 #6
0
def test_client_server():
    """
    Checks that the client-server works as expected. We will send
    a request using the echo worker and assert it has the same data as we send,
    providing assurance that the client-server communication and protocol is
    OK.

    Once the result has been received we quit the qt app.
    """
    global backend_manager
    win = QtWidgets.QMainWindow()
    backend_manager = BackendManager(win)
    with pytest.raises(NotRunning):
        backend_manager.send_request(backend.echo_worker,
                                     'some data',
                                     on_receive=_on_receive)
    backend_manager.start(os.path.join(os.getcwd(), 'server.py'))
    backend_manager._process.started.connect(_send_request)
    QTest.qWait(1000)
    backend_manager.stop()
    del backend_manager
    del win
コード例 #7
0
def main():
    app = QtWidgets.QApplication(sys.argv)
    window = QtWidgets.QMainWindow()

    # configure editor (see examples/simple/basic.py)
    editor = api.CodeEdit()
    editor.file.open(__file__)
    editor.modes.append(modes.CaretLineHighlighterMode())
    editor.modes.append(modes.PygmentsSyntaxHighlighter(editor.document()))
    editor.panels.append(panels.SearchAndReplacePanel(),
                         api.Panel.Position.TOP)
    window.setCentralWidget(editor)
    window.show()

    # Change action properties
    editor.action_duplicate_line.setShortcut('Ctrl+Shift+Down')
    editor.action_duplicate_line.setText('DUPLICATE LINE')

    app.exec_()
    editor.file.close()
    del editor
    del window
    del app
コード例 #8
0
    def store_file(self, file_path):
        with open(file_path, 'w') as f:
            f.write(self.get_text())

        self.clear_modified_flag()

    def get_lines(self):
        return max(1, self.blockCount())

    def clear_modified_flag(self):
        self.document().setModified(False)

    def set_modified_flag(self):
        self.document().setModified(True)

    @staticmethod
    def remove_file(file_path):
        if os.path.exists(file_path):
            os.remove(file_path)
        else:
            raise Exception('File does not exist to move/rename')


if __name__ == "__main__":
    app = QtWidgets.QApplication(sys.argv)
    window = QtWidgets.QMainWindow()
    editor = PyQodeEditor()
    window.setCentralWidget(editor)
    window.showMaximized()
    app.exec_()