From 869a108360a8c0b6c0b739252a2fbfdd45af2afa Mon Sep 17 00:00:00 2001 From: Auric Vente Date: Sat, 20 Jul 2024 02:56:05 -0600 Subject: [PATCH] Mods --- cromulant/game.py | 15 +++++++-------- cromulant/window.py | 16 +++++++++++----- 2 files changed, 18 insertions(+), 13 deletions(-) diff --git a/cromulant/game.py b/cromulant/game.py index aec7ee3..502865e 100644 --- a/cromulant/game.py +++ b/cromulant/game.py @@ -8,8 +8,8 @@ from PySide6.QtWidgets import QHBoxLayout # type: ignore from PySide6.QtWidgets import QVBoxLayout from PySide6.QtWidgets import QLabel from PySide6.QtWidgets import QWidget -from PySide6.QtGui import QKeyEvent -from PySide6.QtGui import QPixmap # type: ignore +from PySide6.QtGui import QKeyEvent # type: ignore +from PySide6.QtGui import QPixmap from PySide6.QtCore import QTimer from wonderwords import RandomSentence # type: ignore @@ -79,6 +79,7 @@ class Game: def add_view_container(container: QHBoxLayout) -> None: root = QWidget() root.setContentsMargins(0, 0, 0, 0) + container.setContentsMargins(0, 0, 0, 0) root.setLayout(container) Window.view.insertWidget(0, root) @@ -286,8 +287,8 @@ class Game: layout2 = widget.layout() - for i in range(layout2.count()): - wid = layout2.itemAt(i).widget() + for j in range(layout2.count()): + wid = layout2.itemAt(j).widget() if not wid: continue @@ -297,9 +298,7 @@ class Game: if not name: continue - if name == "view_title": - text.append(wid.text().lower()) - elif name == "view_message": + if (name == "view_title") or (name == "view_message"): text.append(wid.text().lower()) - return text \ No newline at end of file + return text diff --git a/cromulant/window.py b/cromulant/window.py index 7a4cfdd..f937e65 100644 --- a/cromulant/window.py +++ b/cromulant/window.py @@ -20,6 +20,7 @@ from PySide6.QtWidgets import QLineEdit from PySide6.QtGui import QFontDatabase # type: ignore from PySide6.QtGui import QMouseEvent from PySide6.QtGui import QIcon +from PySide6.QtGui import QKeyEvent from PySide6.QtCore import Qt # type: ignore from PySide6.QtCore import Signal from PySide6.QtCore import QUrl @@ -40,6 +41,14 @@ class SpecialButton(QPushButton): # type: ignore super().mousePressEvent(e) +class FilterLineEdit(QLineEdit): # type: ignore + def keyPressEvent(self, e: QKeyEvent) -> None: + if e.key() == Qt.Key_Escape: + self.clear() + else: + super().keyPressEvent(e) + + class Window: app: QApplication window: QMainWindow @@ -207,8 +216,7 @@ class Window: Window.speed.setCurrentIndex(1) Window.speed.currentIndexChanged.connect(Game.update_speed) - - Window.filter = QLineEdit() + Window.filter = FilterLineEdit() Window.filter.setToolTip("Filter the updates\nClick to scroll to the top") Window.filter.setFixedWidth(120) Window.filter.setPlaceholderText("Filter") @@ -312,9 +320,7 @@ class Window: container = QHBoxLayout() Window.info = SpecialButton("---") - Window.info.setToolTip( - "Click to scroll to the bottom or top" - ) + Window.info.setToolTip("Click to scroll to the bottom or top") Window.info.clicked.connect(Window.toggle_scroll) Window.info.setMinimumSize(35, 35)