src/eric7/MicroPython/IgnoredDevicesDialog.py

Sun, 16 Mar 2025 12:53:12 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sun, 16 Mar 2025 12:53:12 +0100
branch
eric7
changeset 11170
6d6199d668fb
parent 11090
f5f5f5803935
permissions
-rw-r--r--

Added the Adafruit Feather nRF52840 to the list of known NRF52 boards and changed the list of known CircuitPython boards to be more explicit with respect to Adafruit boards (i.e. VID 0x239A).

# -*- coding: utf-8 -*-

# Copyright (c) 2020 - 2025 Detlev Offenbach <detlev@die-offenbachs.de>
#

"""
Module implementing a dialog to manage the list of ignored serial devices.
"""

from PyQt6.QtWidgets import QDialog

from .Ui_IgnoredDevicesDialog import Ui_IgnoredDevicesDialog


class IgnoredDevicesDialog(QDialog, Ui_IgnoredDevicesDialog):
    """
    Class implementing a dialog to manage the list of ignored serial devices.
    """

    def __init__(self, deviceList, parent=None):
        """
        Constructor

        @param deviceList list of ignored serial devices given by VID and PID
        @type list of tuple of (int, int)
        @param parent reference to the parent widget
        @type QWidget
        """
        super().__init__(parent)
        self.setupUi(self)

        self.devicesEditWidget.setList(
            [
                "{0} ({1:04x}/{2:04x})".format(description, vid, pid)
                for vid, pid, description in deviceList
            ]
        )

        self.devicesEditWidget.setResetVisible(False)
        self.devicesEditWidget.setDefaultVisible(False)
        self.devicesEditWidget.setAddVisible(False)

    def getDevices(self):
        """
        Public method to get the list of ignored serial devices.

        @return list of tuples containing the VID, PID and a description
            of each ignored device
        @rtype list of tuple of (int, int, str)
        """
        deviceList = []
        textList = self.devicesEditWidget.getList()
        for entry in textList:
            description, vid_pid = entry.rsplit(None, 1)
            vid, pid = vid_pid[1:-1].split("/", 1)
            deviceList.append((int(vid, 16), int(pid, 16), description))

        return deviceList

eric ide

mercurial