def test_textdocument(): doc = gui.TextDocument("This is a test\nHello") for i in doc: repr(i) assert doc[1].text() == "Hello" assert len(doc) == 2 doc.set_text("test") doc.clear_stacks("undo_and_redo") with pytest.raises(InvalidParamError): doc.clear_stacks("test") # doc.add_resource("html") doc.set_default_cursor_move_style("logical") assert doc.get_default_cursor_move_style() == "logical" with pytest.raises(InvalidParamError): doc.set_default_cursor_move_style("test")
def __init__( self, text: str = "", parent: QtWidgets.QWidget | None = None, read_only: bool = False, ): super().__init__(parent) self._allow_wheel_zoom = False self.validator: QtGui.QValidator | None = None self.textChanged.connect(self._on_value_change) self.set_read_only(read_only) doc = gui.TextDocument(self) layout = widgets.PlainTextDocumentLayout(doc) doc.setDocumentLayout(layout) self.setDocument(doc) self.set_text(text)
from __future__ import annotations from prettyqt import core, gui from prettyqt.qt import QtGui QtGui.QTextObject.__bases__ = (core.Object, ) class TextObject(QtGui.QTextObject): def __repr__(self): return f"{type(self).__name__}()" def get_format(self) -> gui.TextFormat: return gui.TextFormat(self.format()) if __name__ == "__main__": doc = gui.TextDocument() obj = TextObject(doc)
def test_textframe(): doc = gui.TextDocument() frame = gui.TextFrame(doc) repr(frame) frame.get_first_cursor_position() frame.get_last_cursor_position()
def test_textobject(): doc = gui.TextDocument() obj = gui.TextObject(doc) repr(obj) obj.get_format()
def test_textblockgroup(): doc = gui.TextDocument() group = gui.TextBlockGroup(doc) repr(group) for textblock in group: pass