python - pyqt graceful logout my app when user signs off -
when app running, if user logs off pop window displaying info , confirming logout
class myapp(qtwidgets.qapplication): def __init__(self, *args, **kwargs): super(myapp, self).__init__(*args, **kwargs) self.commitdatarequest.connect(lambda manager: self.commitdata(manager)) @qtcore.pyqtslot(qtgui.qsessionmanager) def commitdata(self, manager): print 'shutdown' if __name__ == '__main__': qapplication = myapp(sys.argv) qtwidgets.qapplication.setquitonlastwindowclosed(false) #interaction through tray icon application.exec_()
the issue it's not going slot method.
my app not have main window, interfaces through tray icon.
you need on ride qtwidget:
def closeevent(self, event): quit_msg = "are sure want exit program?" reply = qtgui.qmessagebox.question(self, 'message', quit_msg, qtgui.qmessagebox.yes, qtgui.qmessagebox.no) if reply == qtgui.qmessagebox.yes: event.accept() else: event.ignore()
Comments
Post a Comment