Skip to content

Commit 72055a7

Browse files
Fix QUrl ImportError and NameError in ServicesPage; Diagnose Env.
This commit includes: - `grazr/ui/site_config_panel.py`: I fixed `ImportError: cannot import name 'QUrl' from 'PySide6.QtGui'` by moving the import of `QUrl` to `PySide6.QtCore`. I also proactively added `import re`. - `grazr/ui/services_page.py`: I fixed `NameError: name 'main_window' is not defined` in the `add_header_actions` method by changing calls from `main_window.add_header_action(...)` to `header_widget.add_action_widget(...)`. I removed manual widget reparenting logic that is handled by Qt. - I conducted a review of imports and basic definitions (`logger`, `Slot`, config imports) in `services_page.py`, `site_config_panel.py`, `site_detail_widget.py`, and `generic_service_detail_widget.py`, and found no critical omissions in the latest versions of these files. Previously, I addressed issues including: - Extensive diagnostic logging for UI initialization, button states, page navigation, and header actions. - Handling of Node.js services on the ServicesPage. - Fixes for AttributeError related to ServiceDefinition and SitesPage. - Safeguards for RuntimeError (deleted C++ objects) in Header.clear_actions and ServicesPage/SitesPage set_controls_enabled methods. - Frontend guard for empty PHP version selection in `SiteConfigPanel`. - Various other ImportErrors, NameErrors, and linting errors. CRITICAL UNRESOLVED ISSUE: I've found that the execution environment is unable to reliably run Qt (PySide6) applications. Even an ultra-minimal Qt script consisting only of `QApplication` and `QWidget` instantiation and a `QTimer` to quit the event loop consistently times out. This prevents any testing or verification of the Grazr application's UI, including the fixes in this commit and all previously implemented UI-related changes and diagnostics. Application hangs or errors observed are highly likely symptoms of this environment-level incompatibility with Qt. Further work is critically needed to: 1. **Resolve the Qt execution issue within the testing environment.** This is the absolute highest priority. The environment must be capable of running basic PySide6 applications. 2. Once the environment is stable, I will thoroughly test all fixes in this commit (QUrl, NameError in ServicesPage). 3. I will capture and analyze all previously added diagnostic logs to understand and resolve issues with `ServicesPage` button visibility, page navigation, and any remaining `RuntimeError`s. 4. I will address any `qtpy` import issues if they resurface. 5. I will fully test the application in its intended GUI environment.
1 parent 33efc0e commit 72055a7

File tree

2 files changed

+21
-6
lines changed

2 files changed

+21
-6
lines changed

grazr/ui/services_page.py

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -206,10 +206,24 @@ def on_selection_changed_show_details(self):
206206

207207
# --- Header Action Methods ---
208208
def add_header_actions(self, header_widget):
209-
main_window.add_header_action(self.add_service_button, "services_page")
210-
main_window.add_header_action(self.stop_all_button, "services_page")
211-
if self.add_service_button.parent(): self.add_service_button.parent().layout().removeWidget(self.add_service_button)
212-
if self.stop_all_button.parent(): self.stop_all_button.parent().layout().removeWidget(self.stop_all_button)
209+
logger.debug(f"SERVICES_PAGE.add_header_actions: Called. add_service_button is valid: {self.add_service_button is not None}, stop_all_button is valid: {self.stop_all_button is not None}")
210+
211+
logger.debug(f"SERVICES_PAGE.add_header_actions: Attempting to add add_service_button ({self.add_service_button}) to header.")
212+
if self.add_service_button:
213+
header_widget.add_action_widget(self.add_service_button)
214+
else:
215+
logger.warning("SERVICES_PAGE.add_header_actions: self.add_service_button is None, cannot add to header.")
216+
217+
logger.debug(f"SERVICES_PAGE.add_header_actions: Attempting to add stop_all_button ({self.stop_all_button}) to header.")
218+
if self.stop_all_button:
219+
header_widget.add_action_widget(self.stop_all_button)
220+
else:
221+
logger.warning("SERVICES_PAGE.add_header_actions: self.stop_all_button is None, cannot add to header.")
222+
223+
# The original lines that removed widgets from their parents are commented out.
224+
# HeaderWidget.add_action_widget should handle reparenting.
225+
# if self.add_service_button.parent(): self.add_service_button.parent().layout().removeWidget(self.add_service_button)
226+
# if self.stop_all_button.parent(): self.stop_all_button.parent().layout().removeWidget(self.stop_all_button)
213227

214228
@Slot(str, str) # Receives unique_instance_id_or_process_id, action
215229
def on_service_action(self, service_item_id, action):

grazr/ui/site_config_panel.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
import logging
22
from pathlib import Path
3+
import re # Added for re.escape
34

45
from PySide6.QtWidgets import (QWidget, QVBoxLayout, QHBoxLayout, QLabel,
56
QPushButton, QComboBox, QCheckBox, QLineEdit,
67
QFormLayout, QSpacerItem, QSizePolicy, QMenu)
7-
from PySide6.QtCore import Signal, Slot, Qt, QRegularExpression, QSize
8-
from PySide6.QtGui import QFont, QRegularExpressionValidator, QIcon, QDesktopServices, QUrl
8+
from PySide6.QtCore import Signal, Slot, Qt, QRegularExpression, QSize, QUrl # QUrl added
9+
from PySide6.QtGui import QFont, QRegularExpressionValidator, QIcon, QDesktopServices # QUrl removed
910

1011
logger = logging.getLogger(__name__)
1112

0 commit comments

Comments
 (0)