コード例 #1
0
ファイル: text_editor.py プロジェクト: rjcmarkelz/openalea
    def __init__(self, parent=None):
        super(RichTextEditor, self).__init__(parent)

        self.completer = DictionaryCompleter(parent=self)

        self.editor = self._default_editor(parent=self)
        self.editor.textChanged.connect(self.textChanged.emit)
        # self.editor.setCompleter(self.completer)

        self.goto_widget = GoToWidget(parent=self.editor)
        self.search_widget = SearchWidget(parent=self.editor)

        self.layout = QtGui.QVBoxLayout()
        self.layout.setContentsMargins(0, 0, 0, 0)
        self.layout.addWidget(self.editor)
        self.layout.addWidget(self.search_widget)
        self.setLayout(self.layout)

        self.search_widget.hide()
コード例 #2
0
ファイル: text_editor.py プロジェクト: gbaty/openalea
    def __init__(self, parent=None):
        super(RichTextEditor, self).__init__(parent)

        self.completer = DictionaryCompleter(parent=self)

        self.editor = self._default_editor(parent=self)
        self.editor.textChanged.connect(self.textChanged.emit)
        # self.editor.setCompleter(self.completer)

        self.goto_widget = GoToWidget(parent=self.editor)
        self.search_widget = SearchWidget(parent=self.editor)

        self.layout = QtGui.QVBoxLayout()
        self.layout.setContentsMargins(0, 0, 0, 0)
        self.layout.addWidget(self.editor)
        self.layout.addWidget(self.search_widget)
        self.setLayout(self.layout)

        self.search_widget.hide()
コード例 #3
0
ファイル: text_editor.py プロジェクト: gbaty/openalea
class RichTextEditor(QtGui.QWidget):
    textChanged = QtCore.Signal()

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

        self.completer = DictionaryCompleter(parent=self)

        self.editor = self._default_editor(parent=self)
        self.editor.textChanged.connect(self.textChanged.emit)
        # self.editor.setCompleter(self.completer)

        self.goto_widget = GoToWidget(parent=self.editor)
        self.search_widget = SearchWidget(parent=self.editor)

        self.layout = QtGui.QVBoxLayout()
        self.layout.setContentsMargins(0, 0, 0, 0)
        self.layout.addWidget(self.editor)
        self.layout.addWidget(self.search_widget)
        self.setLayout(self.layout)

        self.search_widget.hide()

    def _default_editor(self, *args, **kwargs):
        return TextEditor(*args, **kwargs)

    def actions(self):
        """
        :return: list of actions to set in the menu.
        """
        return None

    def mainMenu(self):
        return "Project"

    def set_text(self, txt):
        """
        Set text in the editor

        :param text: text you want to set
        """
        self.editor.set_text(txt)

    set_script = set_text

    def get_selected_text(self):
        return self.editor.get_selected_text()

    def get_text(self, start='sof', end='eof'):
        """
        Return a part of the text.

        :param start: is the begining of what you want to get
        :param end: is the end of what you want to get
        :return: text which is contained in the editor between 'start' and 'end'
        """
        return self.editor.get_text(start=start, end=end)

    def get_code(self, start='sof', end='eof'):
        return self.get_text(start=start, end=end)

    def replace_tab(self):
        return self.editor.replace_tab()

    def goto(self):
        self.goto_widget.show()

    def comment(self):
        self.editor.comment()

    def uncomment(self):
        self.editor.uncomment()

    def undo(self):
        self.editor.undo()

    def redo(self):
        self.editor.redo()

    def search(self):
        if self.search_widget.hiden:
            cursor = self.editor.textCursor()
            cursor.setPosition(0)
            self.editor.setTextCursor(cursor)

            self.search_widget.show()
            # self.search_widget.raise_()
            self.search_widget.lineEdit.setFocus()
            txt = self.get_selected_text()
            self.search_widget.lineEdit.setText(txt)
            self.search_widget.hiden = False
        else:
            self.search_widget.hide()
            self.search_widget.hiden = True
コード例 #4
0
ファイル: text_editor.py プロジェクト: rjcmarkelz/openalea
class RichTextEditor(QtGui.QWidget):
    textChanged = QtCore.Signal()

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

        self.completer = DictionaryCompleter(parent=self)

        self.editor = self._default_editor(parent=self)
        self.editor.textChanged.connect(self.textChanged.emit)
        # self.editor.setCompleter(self.completer)

        self.goto_widget = GoToWidget(parent=self.editor)
        self.search_widget = SearchWidget(parent=self.editor)

        self.layout = QtGui.QVBoxLayout()
        self.layout.setContentsMargins(0, 0, 0, 0)
        self.layout.addWidget(self.editor)
        self.layout.addWidget(self.search_widget)
        self.setLayout(self.layout)

        self.search_widget.hide()

    def _default_editor(self, *args, **kwargs):
        return TextEditor(*args, **kwargs)

    def actions(self):
        """
        :return: list of actions to set in the menu.
        """
        return None

    def mainMenu(self):
        return "Project"

    def set_text(self, txt):
        """
        Set text in the editor

        :param text: text you want to set
        """
        self.editor.set_text(txt)

    set_script = set_text

    def get_selected_text(self):
        return self.editor.get_selected_text()

    def get_text(self, start='sof', end='eof'):
        """
        Return a part of the text.

        :param start: is the begining of what you want to get
        :param end: is the end of what you want to get
        :return: text which is contained in the editor between 'start' and 'end'
        """
        return self.editor.get_text(start=start, end=end)

    def get_code(self, start='sof', end='eof'):
        return self.get_text(start=start, end=end)

    def replace_tab(self):
        return self.editor.replace_tab()

    def goto(self):
        self.goto_widget.show()

    def comment(self):
        self.editor.comment()

    def uncomment(self):
        self.editor.uncomment()

    def undo(self):
        self.editor.undo()

    def redo(self):
        self.editor.redo()

    def search(self):
        if self.search_widget.hiden:
            cursor = self.editor.textCursor()
            cursor.setPosition(0)
            self.editor.setTextCursor(cursor)

            self.search_widget.show()
            # self.search_widget.raise_()
            self.search_widget.lineEdit.setFocus()
            txt = self.get_selected_text()
            self.search_widget.lineEdit.setText(txt)
            self.search_widget.hiden = False
        else:
            self.search_widget.hide()
            self.search_widget.hiden = True