Mercurial > libervia-backend
comparison frontends/src/jp/base.py @ 2550:1d754bc14381
jp (base): new confirmOrQuit helper method to ask confirmation to user, and quit if he cancel
author | Goffi <goffi@goffi.org> |
---|---|
date | Sat, 31 Mar 2018 18:21:56 +0200 |
parents | 2d69a0afe039 |
children | 38e1e29c48e9 |
comparison
equal
deleted
inserted
replaced
2549:f685ad80ee98 | 2550:1d754bc14381 |
---|---|
544 try: | 544 try: |
545 self.loop.quit() | 545 self.loop.quit() |
546 except AttributeError: | 546 except AttributeError: |
547 pass | 547 pass |
548 | 548 |
549 def confirmOrQuit(self, message, cancel_message=_(u"action cancelled by user")): | |
550 """Request user to confirm action, and quit if he doesn't""" | |
551 | |
552 res = raw_input("{} (y/N)? ".format(message)) | |
553 if res not in ("y", "Y"): | |
554 self.disp(cancel_message) | |
555 self.quit(C.EXIT_USER_CANCELLED) | |
556 | |
549 def quitFromSignal(self, errcode=0): | 557 def quitFromSignal(self, errcode=0): |
550 """Same as self.quit, but from a signal handler | 558 """Same as self.quit, but from a signal handler |
551 | 559 |
552 /!\: return must be used after calling this method ! | 560 /!\: return must be used after calling this method ! |
553 """ | 561 """ |