12
12
13
13
# D-Bus
14
14
import dbus
15
- from dbus .mainloop .qt import DBusQtMainLoop
15
+ from dbus .mainloop .pyqt5 import DBusQtMainLoop
16
16
17
17
# Qt Libraries
18
- from PyQt5 import QtGui
18
+ from PyQt5 import QtWidgets
19
19
from PyQt5 .QtCore import *
20
20
21
21
# UI
@@ -52,10 +52,10 @@ def get_icon(conn_type, state = False):
52
52
return CONN_TYPES .get (conn_type ,
53
53
QIconLoader .loadOverlayed ("network-wired" , state , 32 , position = QIconLoader .TopLeft ))
54
54
55
- class ConnectionItem (QtGui .QWidget , Ui_ConnectionItem ):
55
+ class ConnectionItem (QtWidgets .QWidget , Ui_ConnectionItem ):
56
56
57
57
def __init__ (self , parent , connection ):
58
- QtGui .QWidget .__init__ (self , parent )
58
+ QtWidgets .QWidget .__init__ (self , parent )
59
59
self .setupUi (self )
60
60
61
61
self .available = True
@@ -73,7 +73,7 @@ def __init__(self, parent, connection):
73
73
self .mainLayout .insertWidget (0 , self .busy )
74
74
self .busy .hide ()
75
75
76
- self . connect (parent , SIGNAL ( "stateChanged()" ), self .updateState )
76
+ parent . stateChanged . connect (self .updateState )
77
77
self .button .clicked .connect (lambda : self .parent .setState (self ))
78
78
79
79
self .updateState ()
@@ -122,10 +122,10 @@ def leaveEvent(self, event):
122
122
def toggleButtons (self , toggle = False ):
123
123
self .button .setVisible (toggle )
124
124
125
- class QNetworkManager (QtGui .QListWidget ):
125
+ class QNetworkManager (QtWidgets .QListWidget ):
126
126
127
127
def __init__ (self , parent = None ):
128
- QtGui .QListWidget .__init__ (self , parent )
128
+ QtWidgets .QListWidget .__init__ (self , parent )
129
129
self .setAlternatingRowColors (True )
130
130
131
131
self .nm = NetworkManager ()
@@ -138,7 +138,7 @@ def __init__(self, parent = None):
138
138
nm_interface .connect_to_signal ("DeviceAdded" , self .fillConnections )
139
139
nm_interface .connect_to_signal ("DeviceRemoved" , lambda * args : self .showMessage ("A device removed." , True ))
140
140
nm_interface .connect_to_signal ("DeviceRemoved" , self .fillConnections )
141
- nm_interface .connect_to_signal ("PropertiesChanged" , lambda * args : self .emit (SIGNAL ( "stateChanged()" ) ))
141
+ nm_interface .connect_to_signal ("PropertiesChanged" , lambda * args : self .stateChanged . emit ())
142
142
143
143
nm_settings_bus = self .bus .get_object (NM_BUS_NAME , NM_SETTINGS_OBJECT_PATH )
144
144
nm_settings = dbus .Interface (nm_settings_bus , NM_SETTINGS )
@@ -170,7 +170,7 @@ def fillConnections(self, *args):
170
170
self .clearList ()
171
171
actives = self .nm .active_connections
172
172
for connection in self .nm .connections :
173
- item = QtGui .QListWidgetItem ()
173
+ item = QtWidgets .QListWidgetItem ()
174
174
item .setSizeHint (QSize (200 , 38 ))
175
175
self .addItem (item )
176
176
self .setItemWidget (item , ConnectionItem (self , connection ))
@@ -218,7 +218,7 @@ def connect(self, connection):
218
218
# Basic test app
219
219
if __name__ == "__main__" :
220
220
import sys
221
- app = QtGui .QApplication (sys .argv )
221
+ app = QtWidgets .QApplication (sys .argv )
222
222
DBusQtMainLoop (set_as_default = True )
223
223
nm = QNetworkManager ()
224
224
nm .show ()
0 commit comments