예제 #1
0
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")
예제 #2
0
 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)
예제 #3
0
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)
예제 #4
0
def test_textframe():
    doc = gui.TextDocument()
    frame = gui.TextFrame(doc)
    repr(frame)
    frame.get_first_cursor_position()
    frame.get_last_cursor_position()
예제 #5
0
def test_textobject():
    doc = gui.TextDocument()
    obj = gui.TextObject(doc)
    repr(obj)
    obj.get_format()
예제 #6
0
def test_textblockgroup():
    doc = gui.TextDocument()
    group = gui.TextBlockGroup(doc)
    repr(group)
    for textblock in group:
        pass