src/eric7/MicroPython/IgnoredDevicesDialog.py

branch
eric7
changeset 9209
b99e7fd55fd3
parent 8881
54e42bc2437a
child 9221
bf71ee032bb4
equal deleted inserted replaced
9208:3fc8dfeb6ebe 9209:b99e7fd55fd3
1 # -*- coding: utf-8 -*-
2
3 # Copyright (c) 2020 - 2022 Detlev Offenbach <detlev@die-offenbachs.de>
4 #
5
6 """
7 Module implementing a dialog to manage the list of ignored serial devices.
8 """
9
10 from PyQt6.QtWidgets import QDialog
11
12 from .Ui_IgnoredDevicesDialog import Ui_IgnoredDevicesDialog
13
14
15 class IgnoredDevicesDialog(QDialog, Ui_IgnoredDevicesDialog):
16 """
17 Class implementing a dialog to manage the list of ignored serial devices.
18 """
19 def __init__(self, deviceList, parent=None):
20 """
21 Constructor
22
23 @param deviceList list of ignored serial devices given by VID and PID
24 @type list of tuple of (int, int)
25 @param parent reference to the parent widget
26 @type QWidget
27 """
28 super().__init__(parent)
29 self.setupUi(self)
30
31 self.devicesEditWidget.setList([
32 "{0} ({1:04x}/{2:04x})".format(description, vid, pid)
33 for vid, pid, description in deviceList
34 ])
35
36 self.devicesEditWidget.setDefaultVisible(False)
37 self.devicesEditWidget.setAddVisible(False)
38
39 def getDevices(self):
40 """
41 Public method to get the list of ignored serial devices.
42
43 @return list of tuples containing the VID, PID and a description
44 of each ignored device
45 @rtype list of tuple of (int, int, str)
46 """
47 deviceList = []
48 textList = self.devicesEditWidget.getList()
49 for entry in textList:
50 description, vid_pid = entry.rsplit(None, 1)
51 vid, pid = vid_pid[1:-1].split("/", 1)
52 deviceList.append((int(vid, 16), int(pid, 16), description))
53
54 return deviceList

eric ide

mercurial