src/eric7/MicroPython/WifiDialogs/WifiCountryDialog.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) 2023 - 2025 Detlev Offenbach <detlev@die-offenbachs.de>
#


"""
Module implementing a dialog to enter the country code for the WiFi interface.
"""

from PyQt6.QtCore import pyqtSlot
from PyQt6.QtWidgets import QDialog, QDialogButtonBox

from eric7 import Preferences

from .Ui_WifiCountryDialog import Ui_WifiCountryDialog


class WifiCountryDialog(QDialog, Ui_WifiCountryDialog):
    """
    Class implementing a dialog to enter the country code for the WiFi interface.
    """

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

        @param parent reference to the parent widget (defaults to None)
        @type QWidget (optional)
        """
        super().__init__(parent)
        self.setupUi(self)

        self.buttonBox.button(QDialogButtonBox.StandardButton.Ok).setEnabled(False)

        self.countryEdit.setText(Preferences.getMicroPython("WifiCountry").upper())

        msh = self.minimumSizeHint()
        self.resize(max(self.width(), msh.width()), msh.height())

    @pyqtSlot(str)
    def on_countryEdit_textChanged(self, country):
        """
        Private slot handling a change of the country.

        @param country entered country code
        @type str
        """
        self.buttonBox.button(QDialogButtonBox.StandardButton.Ok).setEnabled(
            bool(country)
        )

    def getCountry(self):
        """
        Public method to get the entered country code.

        @return tuple containing the country code and a flag indicating to save it to
            the settings
        @rtype tuple of (str, bool)
        """
        return self.countryEdit.text().upper(), self.rememberCheckBox.isChecked()

eric ide

mercurial