eric7/EricNetwork/EricNetworkIcon.py

branch
eric7
changeset 8586
6a315398a554
parent 8585
c9996d52a1b9
child 8663
a925267d1545
equal deleted inserted replaced
8585:c9996d52a1b9 8586:6a315398a554
5 5
6 """ 6 """
7 Module implementing a statusbar icon tracking the network status. 7 Module implementing a statusbar icon tracking the network status.
8 """ 8 """
9 9
10 from PyQt6.QtCore import pyqtSlot, pyqtSignal 10 from PyQt6.QtCore import pyqtSignal
11 from PyQt6.QtNetwork import QNetworkInformation 11 from PyQt6.QtNetwork import QNetworkInformation
12 from PyQt6.QtWidgets import QLabel 12 from PyQt6.QtWidgets import QLabel
13 13
14 import UI.PixmapCache 14 import UI.PixmapCache
15 import Preferences 15 import Preferences
45 QNetworkInformation.Reachability.Online 45 QNetworkInformation.Reachability.Online
46 ) 46 )
47 self.__reachabilityChanged( 47 self.__reachabilityChanged(
48 QNetworkInformation.instance().reachability()) 48 QNetworkInformation.instance().reachability())
49 49
50 QNetworkInformation.instance().reachabilityChanged.connect( 50 # TODO: remove this 'contextlib' with official relelase
51 self.__reachabilityChanged) 51 import contextlib
52 with contextlib.suppress(Exception):
53 QNetworkInformation.instance().reachabilityChanged.connect(
54 self.__reachabilityChanged)
52 else: 55 else:
53 # assume to be 'always online' if no backend could be loaded or 56 # assume to be 'always online' if no backend could be loaded or
54 # dynamic online check is switched of 57 # dynamic online check is switched of
55 self.__online = True 58 self.__online = True
56 self.__reachabilityChanged(QNetworkInformation.Reachability.Online) 59 self.__reachabilityChanged(QNetworkInformation.Reachability.Online)

eric ide

mercurial