def deleteFile(self, path, name): file = QFile(path + name + ".tmp") print(file.fileName()) if file.exists(): print(file.remove()) file.setFileName(path + name + ".tmp.cfg") if file.exists(): print(file.remove())
def showNotification(self, icon, heading, text): ''' @param: icon QPixmap @param: heading QString @param: text QString ''' if not self._enabled: return if self._notifType == self.PopupWidget: if not self._desktopNotif: self._desktopNotif = DesktopNotification() def func(): self._desktopNotif = None self._desktopNotif.closedSignal.connect(func) self._desktopNotif.setPixmap(icon) self._desktopNotif.setHeading(heading) self._desktopNotif.setText(text) self._desktopNotif.setTimeout(self._timeout) self._desktopNotif.move(self._position) self._desktopNotif.show() elif self._notifType == self.DesktopNative: if const.OS_UNIX and not const.DISABLE_DBUS: tmp = QFile(DataPaths.path(DataPaths.Temp) + '/app_notif.png') tmp.open(QFile.WriteOnly) icon.save(tmp.fileName()) from PyQt5.Qt import QDBusInterface, QDBusConnection dbus = QDBusInterface('org.freedesktop.Notifications', '/org/freedesktop/Notifications', 'org.freedesktop.Notifications', QDBusConnection.sessionBus()) args = [] args.append('app') args.append(self._uint) args.append(tmp.fileName()) args.append(heading) args.append(text) args.append([]) args.append({}) args.append(self._timeout) dbus.callWithCallback('Notify', args, self._updateLastId, self._error)