src/eric7/MicroPython/WifiDialogs/WifiApStationsDialog.py

branch
mpy_network
changeset 9787
163511257f24
child 9856
df2ff78bbc01
equal deleted inserted replaced
9783:5f84d5eeee9e 9787:163511257f24
1 # -*- coding: utf-8 -*-
2
3 # Copyright (c) 2023 Detlev Offenbach <detlev@die-offenbachs.de>
4 #
5
6 """
7 Module implementing a dialog showing the currently connected stations (clients).
8 """
9
10 import binascii
11
12 from PyQt6.QtCore import Qt
13 from PyQt6.QtWidgets import QDialog, QTreeWidgetItem
14
15 from .Ui_WifiApStationsDialog import Ui_WifiApStationsDialog
16
17
18 class WifiApStationsDialog(QDialog, Ui_WifiApStationsDialog):
19 """
20 Class documentation goes here.
21 """
22
23 def __init__(self, stations, parent=None):
24 """
25 Constructor
26
27 @param stations list of connected stations. Each entry is a tuple containing the
28 station's MAC-Address and the RSSI (if supported and available)
29 @param parent reference to the parent widget (defaults to None)
30 @type QWidget (optional)
31 """
32 super().__init__(parent)
33 self.setupUi(self)
34
35 rssiFound = False
36
37 for station in stations:
38 mac = binascii.hexlify(station[0], ":").decode("utf-8")
39 if len(station) > 1:
40 rssiFound = True
41 rssi = str(station[1])
42 else:
43 rssi = ""
44 QTreeWidgetItem(self.stationsList, [mac, rssi, ""])
45
46 self.stationsList.sortItems(0, Qt.SortOrder.AscendingOrder)
47 self.stationsList.resizeColumnToContents(0)
48 self.stationsList.resizeColumnToContents(1)
49 self.stationsList.setColumnHidden(1, not rssiFound)
50 self.stationsList.header().setStretchLastSection(True)

eric ide

mercurial