Skip to content

NetworkInterface

Qt Base Class: QNetworkInterface

Signature: QNetworkInterface(self) -> None QNetworkInterface(self, other: PySide6.QtNetwork.QNetworkInterface) -> None

Base classes

Name Children Inherits
QNetworkInterface
PySide6.QtNetwork
QNetworkInterface(self) -> None

⋔ Inheritance diagram

graph TD
  1473574010496["network.NetworkInterface"]
  1473573765520["QtNetwork.QNetworkInterface"]
  1473291690208["Shiboken.Object"]
  140713234304496["builtins.object"]
  1473573765520 --> 1473574010496
  1473291690208 --> 1473573765520
  140713234304496 --> 1473291690208

🛈 DocStrings

Bases: QNetworkInterface

Listing of the host's IP addresses and network interfaces.

Source code in prettyqt\network\networkinterface.py
class NetworkInterface(network.QNetworkInterface):
    """Listing of the host's IP addresses and network interfaces."""

    # def __bool__(self):
    #     return self.isValid()

    def get_type(self) -> InterfaceTypeStr:
        """Get the interface type.

        Returns:
            interface type
        """
        return INTERFACE_TYPE.inverse[self.type()]

    def get_address_entries(self) -> list[network.NetworkAddressEntry]:
        return [network.NetworkAddressEntry(i) for i in self.addressEntries()]

    @staticmethod
    def get_all_addresses() -> list[network.HostAddress]:
        return [network.HostAddress(i) for i in NetworkInterface.allAddresses()]

    @staticmethod
    def get_all_interfaces() -> list[network.HostAddress]:
        return [network.NetworkInterface(i) for i in NetworkInterface.allInterfaces()]

    @staticmethod
    def get_interface_from_name(name: str) -> NetworkInterface:
        interface = NetworkInterface.interfaceFromName(name)
        # if not interface:
        #     return None
        return NetworkInterface(interface)

get_type() -> InterfaceTypeStr

Get the interface type.

Source code in prettyqt\network\networkinterface.py
def get_type(self) -> InterfaceTypeStr:
    """Get the interface type.

    Returns:
        interface type
    """
    return INTERFACE_TYPE.inverse[self.type()]