From 43baeed7d303d02fd259e6af3047e1664b16dcfd Mon Sep 17 00:00:00 2001 From: Vxrtrauter Date: Tue, 14 Oct 2025 10:42:41 +0200 Subject: [PATCH] Added "No Results" Text to GUI --- core/interface/gui.py | 15 +++++++++++++++ core/interface/utils/searchhelper.py | 13 +++++++------ 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/core/interface/gui.py b/core/interface/gui.py index 0735108..1c8caf7 100644 --- a/core/interface/gui.py +++ b/core/interface/gui.py @@ -51,6 +51,12 @@ class MainWindow(QtWidgets.QMainWindow, QWidget): self.softwareList = QListWidget() self.post_author_list = QListWidget() self.libraryList = QListWidget() + + self.emptyResults = QLabel("No Results") + self.emptyResults.setAlignment(Qt.AlignCenter) + self.emptyResults.hide() + + self.download_model = None self.downloadList = QTableView() self.emptyLibrary = QLabel("No items in library.") @@ -117,6 +123,7 @@ class MainWindow(QtWidgets.QMainWindow, QWidget): self.horizontal_layout = QHBoxLayout() self.horizontal_layout.addWidget(self.softwareList, stretch=3) + self.horizontal_layout.addWidget(self.emptyResults, stretch=3) self.horizontal_layout.addWidget(self.post_author_list) self.tab1 = create_tab("Search", self.searchbar, self.softwareList, self.tabs, self.dlbutton, self.horizontal_layout) @@ -173,3 +180,11 @@ class MainWindow(QtWidgets.QMainWindow, QWidget): def update_progress(self): progress = dlprogress() self.progressbar.setValue(progress) + + def show_empty_results(self, show: bool): + if show: + self.softwareList.hide() + self.emptyResults.show() + else: + self.emptyResults.hide() + self.softwareList.show() diff --git a/core/interface/utils/searchhelper.py b/core/interface/utils/searchhelper.py index 539dfc9..73e2754 100644 --- a/core/interface/utils/searchhelper.py +++ b/core/interface/utils/searchhelper.py @@ -25,13 +25,14 @@ def return_pressed(self): self.post_author_list.addItems(state.post_author) if state.tracker == "rutracker": _, state.posts, _, _, cached = split_data(response) - if state.posts == []: - if state.debug: - print(f"No Results found for \"{search_text}\"") - self.softwareList.clear() - self.softwareList.addItem("No Results") # replace with no results text in center - + if state.posts == []: + if state.debug: + print(f"No Results found for \"{search_text}\"") + self.softwareList.clear() + self.show_empty_results(True) + else: state.post_titles, _, state.post_author = format_data(state.posts) + self.show_empty_results(False) self.post_author_list.clear() self.post_author_list.addItems(state.post_author) self.softwareList.clear()