7 Module implementing a dialog to show the WiFi status of the connected device. |
7 Module implementing a dialog to show the WiFi status of the connected device. |
8 """ |
8 """ |
9 |
9 |
10 import contextlib |
10 import contextlib |
11 |
11 |
12 from PyQt6.QtCore import Qt |
12 from PyQt6.QtCore import Qt, pyqtSlot |
13 from PyQt6.QtWidgets import QDialog, QDialogButtonBox, QTreeWidgetItem |
13 from PyQt6.QtWidgets import QDialog, QDialogButtonBox, QTreeWidgetItem |
|
14 |
|
15 from eric7.EricGui import EricPixmapCache |
14 |
16 |
15 from .Ui_WifiStatusDialog import Ui_WifiStatusDialog |
17 from .Ui_WifiStatusDialog import Ui_WifiStatusDialog |
16 |
18 |
17 |
19 |
18 class WifiStatusDialog(QDialog, Ui_WifiStatusDialog): |
20 class WifiStatusDialog(QDialog, Ui_WifiStatusDialog): |
19 """ |
21 """ |
20 Class implementing a dialog to show the WiFi status of the connected device. |
22 Class implementing a dialog to show the WiFi status of the connected device. |
21 """ |
23 """ |
22 |
24 |
23 def __init__(self, clientStatus, apStatus, overallStatus, parent=None): |
25 def __init__(self, microPython, parent=None): |
24 """ |
26 """ |
25 Constructor |
27 Constructor |
26 |
28 |
27 @param clientStatus dictionary containing the WiFi status data of the |
29 @param microPython reference to the MicroPython widget |
28 client interface |
30 @type MicroPythonWidget |
29 @type dict |
|
30 @param apStatus dictionary containing the WiFi status data of the |
|
31 access point interface |
|
32 @type dict |
|
33 @param overallStatus dictionary containing the overall WiFi status data |
|
34 @type dict |
|
35 @param parent reference to the parent widget (defaults to None) |
31 @param parent reference to the parent widget (defaults to None) |
36 @type QWidget (optional) |
32 @type QWidget (optional) |
37 """ |
33 """ |
38 super().__init__(parent) |
34 super().__init__(parent) |
39 self.setupUi(self) |
35 self.setupUi(self) |
|
36 self.setWindowFlags(Qt.WindowType.Window) |
40 |
37 |
41 self.statusTree.setColumnCount(2) |
38 self.statusTree.setColumnCount(2) |
42 |
39 |
43 # overall status |
40 self.refreshButton.setIcon(EricPixmapCache.getIcon("reload")) |
|
41 self.refreshButton.clicked.connect(self.__showStatus) |
|
42 |
|
43 self.__mpy = microPython |
|
44 |
|
45 self.__showStatus() |
|
46 |
|
47 @pyqtSlot() |
|
48 def __showStatus(self): |
|
49 """ |
|
50 Private slot to show the current WiFi status. |
|
51 """ |
|
52 # clear old data |
|
53 self.statusTree.clear() |
|
54 |
|
55 # get the status |
|
56 try: |
|
57 clientStatus, apStatus, overallStatus = self.__mpy.getDevice().getWifiData() |
|
58 except Exception as exc: |
|
59 self.__mpy.showError("getWifiData()", str(exc)) |
|
60 return |
|
61 |
|
62 # populate overall status |
44 QTreeWidgetItem( |
63 QTreeWidgetItem( |
45 self.statusTree, |
64 self.statusTree, |
46 [ |
65 [ |
47 self.tr("Active"), |
66 self.tr("Active"), |
48 self.tr("Yes") if overallStatus["active"] else self.tr("No"), |
67 self.tr("Yes") if overallStatus["active"] else self.tr("No"), |