From 409213585a066eeb45ddc70e132aa9ae7dcc372a Mon Sep 17 00:00:00 2001 From: EKNr1 Date: Mon, 9 Dec 2024 16:53:33 +0100 Subject: [PATCH] I think I fixed the formatting issue when writing new data. --- binary_text_edit.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/binary_text_edit.py b/binary_text_edit.py index 39d40b3..337b0bb 100644 --- a/binary_text_edit.py +++ b/binary_text_edit.py @@ -16,12 +16,10 @@ class BinaryTextEdit(QPlainTextEdit): # rewrite QPlainTextEdit.keyPressEvent be if not (pos + 1) % 9 == 0 or event.text() in {"", None}: # dont overwrite the separator character super().keyPressEvent(event) - # skip over the separator character when the cursor is before it. + # skip over the separator character when the cursor is right before it. if (pos + 2) % 9 == 0 and not event.text() in {"", None}: - if pos == text_length: # append to the input if the cursor is at the end - self.insertPlainText(" ") - cursor = self.textCursor() - cursor.setPosition(pos + 2) + if pos == text_length - 1: # append to the input if the cursor is at the end + self.insertPlainText(" 00000000") cursor.setPosition(pos + 2) self.setTextCursor(cursor)