src/eric7/MicroPython/IgnoredDevicesDialog.py

branch
eric7
changeset 9221
bf71ee032bb4
parent 9209
b99e7fd55fd3
child 9562
94f349d5cd1e
equal deleted inserted replaced
9220:e9e7eca7efee 9221:bf71ee032bb4
14 14
15 class IgnoredDevicesDialog(QDialog, Ui_IgnoredDevicesDialog): 15 class IgnoredDevicesDialog(QDialog, Ui_IgnoredDevicesDialog):
16 """ 16 """
17 Class implementing a dialog to manage the list of ignored serial devices. 17 Class implementing a dialog to manage the list of ignored serial devices.
18 """ 18 """
19
19 def __init__(self, deviceList, parent=None): 20 def __init__(self, deviceList, parent=None):
20 """ 21 """
21 Constructor 22 Constructor
22 23
23 @param deviceList list of ignored serial devices given by VID and PID 24 @param deviceList list of ignored serial devices given by VID and PID
24 @type list of tuple of (int, int) 25 @type list of tuple of (int, int)
25 @param parent reference to the parent widget 26 @param parent reference to the parent widget
26 @type QWidget 27 @type QWidget
27 """ 28 """
28 super().__init__(parent) 29 super().__init__(parent)
29 self.setupUi(self) 30 self.setupUi(self)
30 31
31 self.devicesEditWidget.setList([ 32 self.devicesEditWidget.setList(
32 "{0} ({1:04x}/{2:04x})".format(description, vid, pid) 33 [
33 for vid, pid, description in deviceList 34 "{0} ({1:04x}/{2:04x})".format(description, vid, pid)
34 ]) 35 for vid, pid, description in deviceList
35 36 ]
37 )
38
36 self.devicesEditWidget.setDefaultVisible(False) 39 self.devicesEditWidget.setDefaultVisible(False)
37 self.devicesEditWidget.setAddVisible(False) 40 self.devicesEditWidget.setAddVisible(False)
38 41
39 def getDevices(self): 42 def getDevices(self):
40 """ 43 """
41 Public method to get the list of ignored serial devices. 44 Public method to get the list of ignored serial devices.
42 45
43 @return list of tuples containing the VID, PID and a description 46 @return list of tuples containing the VID, PID and a description
44 of each ignored device 47 of each ignored device
45 @rtype list of tuple of (int, int, str) 48 @rtype list of tuple of (int, int, str)
46 """ 49 """
47 deviceList = [] 50 deviceList = []
48 textList = self.devicesEditWidget.getList() 51 textList = self.devicesEditWidget.getList()
49 for entry in textList: 52 for entry in textList:
50 description, vid_pid = entry.rsplit(None, 1) 53 description, vid_pid = entry.rsplit(None, 1)
51 vid, pid = vid_pid[1:-1].split("/", 1) 54 vid, pid = vid_pid[1:-1].split("/", 1)
52 deviceList.append((int(vid, 16), int(pid, 16), description)) 55 deviceList.append((int(vid, 16), int(pid, 16), description))
53 56
54 return deviceList 57 return deviceList

eric ide

mercurial