def handle_capture(window, capture): email, ok = QInputDialog.getText( window, 'Email', 'Enter your employee ID or email:', flags=Qt.FramelessWindowHint | Qt.Popup) while ok and not get_email(email): email, ok = QInputDialog.getText( window, 'Email', 'Enter a valid employee ID or email:', flags=Qt.FramelessWindowHint | Qt.Popup) if ok: print('Send email to %s' % email) pb = None try: pb = QProgressDialog("Sending...", "", 0, 0, window, Qt.FramelessWindowHint | Qt.Popup) pb.setWindowModality(Qt.WindowModal) pb.setRange(0, 0) pb.setMinimumDuration(0) pb.setCancelButton(None) pb.show() nongui(send_image)(email, capture, cache_dir=IMAGE_CACHE_DIR) except Exception: import traceback traceback.print_exc() msg = QMessageBox(window) msg.setIcon(QMessageBox.Critical) msg.setText('Error sending email.') msg.setWindowFlags(Qt.FramelessWindowHint | Qt.Popup) msg.exec_() finally: if pb: pb.close()
def image_capture(self): self.freeze = self.image.copy() # prevent background update try: self.capture_handler(self, self.freeze) except Exception: msg = QMessageBox(self) msg.setIcon(QMessageBox.Critical) msg.setText('Error during capture.') msg.setWindowFlags(Qt.FramelessWindowHint | Qt.Popup) msg.exec_() self.freeze = None