Skip to content

TextStream

Qt Base Class: QTextStream

Signature: QTextStream(self) -> None QTextStream(self, array: Union[PySide6.QtCore.QByteArray, bytes], openMode: PySide6.QtCore.QIODeviceBase.OpenModeFlag = Instance(PySide6.QtCore.QIODeviceBase.OpenModeFlag.ReadWrite)) -> None QTextStream(self, device: PySide6.QtCore.QIODevice) -> None

Base classes

Name Children Inherits
QTextStream
PySide6.QtCore
QTextStream(self) -> None

⋔ Inheritance diagram

graph TD
  1473299822832["core.TextStream"]
  1473243637824["QtCore.QTextStream"]
  1473243629040["QtCore.QIODeviceBase"]
  1473291690208["Shiboken.Object"]
  140713234304496["builtins.object"]
  1473243637824 --> 1473299822832
  1473243629040 --> 1473243637824
  1473291690208 --> 1473243629040
  140713234304496 --> 1473291690208

🛈 DocStrings

Bases: QTextStream

Convenient interface for reading and writing text.

Source code in prettyqt\core\textstream.py
class TextStream(QtCore.QTextStream):
    """Convenient interface for reading and writing text."""

    def set_field_alignment(
        self, alignment: FieldAlignmentStr | QtCore.QTextStream.FieldAlignment
    ):
        """Set the field alignment.

        Args:
            alignment: field alignment
        """
        self.setFieldAlignment(FIELD_ALIGNMENT.get_enum_value(alignment))

    def get_field_alignment(self) -> FieldAlignmentStr:
        """Get current field alignment.

        Returns:
            current field alignment
        """
        return FIELD_ALIGNMENT.inverse[self.fieldAlignment()]

    def set_status(self, status: StatusStr | QtCore.QTextStream.Status):
        """Set the status.

        Args:
            status: status
        """
        self.setStatus(STATUS.get_enum_value(status))

    def get_status(self) -> StatusStr:
        """Get current status.

        Returns:
            current status
        """
        return STATUS.inverse[self.status()]

    def set_real_number_notation(
        self, notation: RealNumberNotationStr | QtCore.QTextStream.RealNumberNotation
    ):
        """Set the real number notation.

        Args:
            notation: real number notation
        """
        self.setRealNumberNotation(REAL_NUMBER_NOTATION.get_enum_value(notation))

    def get_real_number_notation(self) -> RealNumberNotationStr:
        """Get current real number notation.

        Returns:
            current real number notation
        """
        return REAL_NUMBER_NOTATION.inverse[self.realNumberNotation()]

    def read_lines(self) -> Iterator[str]:
        while True:
            if msg := self.readLine():
                yield msg
            else:
                return

    def get_number_flags(self) -> list[NumberFlagStr]:
        return NUMBER_FLAGS.get_list(self.numberFlags())

    def set_number_flags(self, *flags: NumberFlagStr):
        flag = NUMBER_FLAGS.merge_flags(flags)
        self.setNumberFlags(flag)

get_field_alignment() -> FieldAlignmentStr

Get current field alignment.

Source code in prettyqt\core\textstream.py
def get_field_alignment(self) -> FieldAlignmentStr:
    """Get current field alignment.

    Returns:
        current field alignment
    """
    return FIELD_ALIGNMENT.inverse[self.fieldAlignment()]

get_real_number_notation() -> RealNumberNotationStr

Get current real number notation.

Source code in prettyqt\core\textstream.py
def get_real_number_notation(self) -> RealNumberNotationStr:
    """Get current real number notation.

    Returns:
        current real number notation
    """
    return REAL_NUMBER_NOTATION.inverse[self.realNumberNotation()]

get_status() -> StatusStr

Get current status.

Source code in prettyqt\core\textstream.py
def get_status(self) -> StatusStr:
    """Get current status.

    Returns:
        current status
    """
    return STATUS.inverse[self.status()]

set_field_alignment(alignment: FieldAlignmentStr | QtCore.QTextStream.FieldAlignment)

Set the field alignment.

Parameters:

Name Type Description Default
alignment FieldAlignmentStr | FieldAlignment

field alignment

required
Source code in prettyqt\core\textstream.py
def set_field_alignment(
    self, alignment: FieldAlignmentStr | QtCore.QTextStream.FieldAlignment
):
    """Set the field alignment.

    Args:
        alignment: field alignment
    """
    self.setFieldAlignment(FIELD_ALIGNMENT.get_enum_value(alignment))

set_real_number_notation(notation: RealNumberNotationStr | QtCore.QTextStream.RealNumberNotation)

Set the real number notation.

Parameters:

Name Type Description Default
notation RealNumberNotationStr | RealNumberNotation

real number notation

required
Source code in prettyqt\core\textstream.py
def set_real_number_notation(
    self, notation: RealNumberNotationStr | QtCore.QTextStream.RealNumberNotation
):
    """Set the real number notation.

    Args:
        notation: real number notation
    """
    self.setRealNumberNotation(REAL_NUMBER_NOTATION.get_enum_value(notation))

set_status(status: StatusStr | QtCore.QTextStream.Status)

Set the status.

Parameters:

Name Type Description Default
status StatusStr | Status

status

required
Source code in prettyqt\core\textstream.py
def set_status(self, status: StatusStr | QtCore.QTextStream.Status):
    """Set the status.

    Args:
        status: status
    """
    self.setStatus(STATUS.get_enum_value(status))