src/eric7/MicroPython/BluetoothDialogs/BluetoothStatusDialog.py

branch
eric7
changeset 11166
fd914f897dcf
parent 11090
f5f5f5803935
equal deleted inserted replaced
11165:24e1beb8779a 11166:fd914f897dcf
5 5
6 """ 6 """
7 Module implementing a dialog to show Bluetooth related status information. 7 Module implementing a dialog to show Bluetooth related status information.
8 """ 8 """
9 9
10 from PyQt6.QtCore import Qt 10 from PyQt6.QtCore import Qt, pyqtSlot
11 from PyQt6.QtWidgets import QDialog, QDialogButtonBox, QTreeWidgetItem 11 from PyQt6.QtWidgets import QDialog, QDialogButtonBox, QTreeWidgetItem
12
13 from eric7.EricGui import EricPixmapCache
12 14
13 from .Ui_BluetoothStatusDialog import Ui_BluetoothStatusDialog 15 from .Ui_BluetoothStatusDialog import Ui_BluetoothStatusDialog
14 16
15 17
16 class BluetoothStatusDialog(QDialog, Ui_BluetoothStatusDialog): 18 class BluetoothStatusDialog(QDialog, Ui_BluetoothStatusDialog):
17 """ 19 """
18 Class implementing a dialog to show Bluetooth related status information. 20 Class implementing a dialog to show Bluetooth related status information.
19 """ 21 """
20 22
21 def __init__(self, status, parent=None): 23 def __init__(self, microPython, parent=None):
22 """ 24 """
23 Constructor 25 Constructor
24 26
25 @param status status data to be show 27 @param microPython reference to the MicroPython widget
26 @type list of tuples of (str, str) 28 @type MicroPythonWidget
27 @param parent reference to the parent widget (defaults to None) 29 @param parent reference to the parent widget (defaults to None)
28 @type QWidget (optional) 30 @type QWidget (optional)
29 """ 31 """
30 super().__init__(parent) 32 super().__init__(parent)
31 self.setupUi(self) 33 self.setupUi(self)
34 self.setWindowFlags(Qt.WindowType.Window)
32 35
33 self.statusTree.setColumnCount(2) 36 self.statusTree.setColumnCount(2)
37
38 self.refreshButton.setIcon(EricPixmapCache.getIcon("reload"))
39 self.refreshButton.clicked.connect(self.__showStatus)
40
41 self.__mpy = microPython
42
43 self.__showStatus()
44
45 @pyqtSlot()
46 def __showStatus(self):
47 """
48 Private slot to show the current WiFi status.
49 """
50 self.statusTree.clear()
51
52 try:
53 status = self.__mpy.getDevice().getBluetoothStatus()
54 # status is a list of user labels and associated values
55 except Exception as exc:
56 self.__mpy.showError("getBluetoothStatus()", str(exc))
57 return
34 58
35 for topic, value in status: 59 for topic, value in status:
36 QTreeWidgetItem(self.statusTree, [topic, str(value)]) 60 QTreeWidgetItem(self.statusTree, [topic, str(value)])
37 61
38 for col in range(self.statusTree.columnCount()): 62 for col in range(self.statusTree.columnCount()):

eric ide

mercurial