Basic PyQt5 + Python 3.6 support

This commit is contained in:
Silvan Calarco 2019-03-31 19:43:46 +02:00
parent 2038c0f763
commit c3e25efaef

View File

@ -1,6 +1,6 @@
#!/usr/bin/python #!/usr/bin/python3.6
# mambatray 2 # mambatray 2
# Copyright (C) 2011-2018 by Silvan Calarco # Copyright (C) 2011-2019 by Silvan Calarco
# Copyright (C) 2011 by michiamophil # Copyright (C) 2011 by michiamophil
# Distributed under the terms of the GPL version 3 FLOSS License # Distributed under the terms of the GPL version 3 FLOSS License
# #
@ -26,7 +26,10 @@ class SystemTrayIcon(QtWidgets.QSystemTrayIcon):
QtWidgets.QSystemTrayIcon.__init__(self, icon, parent) QtWidgets.QSystemTrayIcon.__init__(self, icon, parent)
menu = QtWidgets.QMenu(parent) menu = QtWidgets.QMenu(parent)
try:
desktop_session = os.path.basename(os.getenv('DESKTOP_SESSION')) desktop_session = os.path.basename(os.getenv('DESKTOP_SESSION'))
except:
desktop_session = 'default'
if desktop_session == 'default': if desktop_session == 'default':
desktop_session = 'plasma' desktop_session = 'plasma'
@ -128,7 +131,7 @@ class SystemTrayIcon(QtWidgets.QSystemTrayIcon):
version = _("Error: Unable to find /etc/openmamba-release") version = _("Error: Unable to find /etc/openmamba-release")
QtWidgets.QMessageBox.about(menu, _("About"), QtWidgets.QMessageBox.about(menu, _("About"),
"<center><b>"+_("openmamba control center")+"</b>" "<center><b>"+_("openmamba control center")+"</b>"
"<br><br>Copyright(c) 2011-2018 by Silvan Calarco" "<br><br>Copyright(c) 2011-2019 by Silvan Calarco"
"<br>Copyright(c) 2011 by michiamophil" "<br>Copyright(c) 2011 by michiamophil"
"<br><br><b>"+_("System info:")+"</b></center>" "<br><br><b>"+_("System info:")+"</b></center>"
""+_(version)+"<center><a href=\"http://openmamba.org\">http://openmamba.org</a></center>") ""+_(version)+"<center><a href=\"http://openmamba.org\">http://openmamba.org</a></center>")
@ -254,15 +257,13 @@ class SystemTrayIcon(QtWidgets.QSystemTrayIcon):
testo = testo + a + ', ' testo = testo + a + ', '
return testo[0:len(testo)-2] return testo[0:len(testo)-2]
def main(): def main():
app = QtWidgets.QApplication(sys.argv) app = QtWidgets.QApplication(sys.argv)
if (app.isSessionRestored()): if (app.isSessionRestored()):
app.exit(1) app.exit(1)
else: else:
app.setQuitOnLastWindowClosed(0) app.setQuitOnLastWindowClosed(0)
gettext.install('mambatray', '/usr/share/locale', unicode=1) gettext.install('mambatray', '/usr/share/locale')
w = QtWidgets.QWidget() w = QtWidgets.QWidget()
w.setWindowIcon(QtGui.QIcon.fromTheme("mambatray",QtGui.QIcon("/usr/share/icons/hicolor/64x64/apps/mambatray.png"))) w.setWindowIcon(QtGui.QIcon.fromTheme("mambatray",QtGui.QIcon("/usr/share/icons/hicolor/64x64/apps/mambatray.png")))
trayIcon = SystemTrayIcon(QtGui.QIcon.fromTheme("mambatray", QtGui.QIcon("/usr/share/icons/hicolor/32x32/apps/mambatray.png")), w) trayIcon = SystemTrayIcon(QtGui.QIcon.fromTheme("mambatray", QtGui.QIcon("/usr/share/icons/hicolor/32x32/apps/mambatray.png")), w)