--- a/src/eric7/MicroPython/WifiDialogs/WifiStatusDialog.py Thu Mar 06 17:44:49 2025 +0100 +++ b/src/eric7/MicroPython/WifiDialogs/WifiStatusDialog.py Sun Mar 09 14:16:35 2025 +0100 @@ -9,9 +9,11 @@ import contextlib -from PyQt6.QtCore import Qt +from PyQt6.QtCore import Qt, pyqtSlot from PyQt6.QtWidgets import QDialog, QDialogButtonBox, QTreeWidgetItem +from eric7.EricGui import EricPixmapCache + from .Ui_WifiStatusDialog import Ui_WifiStatusDialog @@ -20,27 +22,44 @@ Class implementing a dialog to show the WiFi status of the connected device. """ - def __init__(self, clientStatus, apStatus, overallStatus, parent=None): + def __init__(self, microPython, parent=None): """ Constructor - @param clientStatus dictionary containing the WiFi status data of the - client interface - @type dict - @param apStatus dictionary containing the WiFi status data of the - access point interface - @type dict - @param overallStatus dictionary containing the overall WiFi status data - @type dict + @param microPython reference to the MicroPython widget + @type MicroPythonWidget @param parent reference to the parent widget (defaults to None) @type QWidget (optional) """ super().__init__(parent) self.setupUi(self) + self.setWindowFlags(Qt.WindowType.Window) self.statusTree.setColumnCount(2) - # overall status + self.refreshButton.setIcon(EricPixmapCache.getIcon("reload")) + self.refreshButton.clicked.connect(self.__showStatus) + + self.__mpy = microPython + + self.__showStatus() + + @pyqtSlot() + def __showStatus(self): + """ + Private slot to show the current WiFi status. + """ + # clear old data + self.statusTree.clear() + + # get the status + try: + clientStatus, apStatus, overallStatus = self.__mpy.getDevice().getWifiData() + except Exception as exc: + self.__mpy.showError("getWifiData()", str(exc)) + return + + # populate overall status QTreeWidgetItem( self.statusTree, [ @@ -57,7 +76,7 @@ self.statusTree, [self.tr("Country"), overallStatus["country"]] ) - # client interface + # populate status of client interface if clientStatus: header = self.__createHeader(self.tr("Client")) QTreeWidgetItem( @@ -131,7 +150,7 @@ apHeader, [self.tr("Country"), clientStatus["ap_country"]] ) - # access point interface + # populate status of access point interface if apStatus: header = self.__createHeader(self.tr("Access Point")) QTreeWidgetItem(