Skip to content

NetworkInterface

Base classes

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

⋔ Inheritance diagram

graph TD
  2019279607["network.NetworkInterface"]
  3335325926["QtNetwork.QNetworkInterface"]
  37984305["Shiboken.Object"]
  2751680898["builtins.object"]
  3335325926 --> 2019279607
  37984305 --> 3335325926
  2751680898 --> 37984305

🛈 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.NetworkInterface]:
        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()]

:fa-brands-github: Show source on GitHub