Source code for src.utils.waiting_while_processing.waiting_while_processing_controller
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Waiting while processing controller
"""
from utils.waiting_while_processing.waiting_while_processing_view import waitingWhileProcessingView
from utils.waiting_while_processing.waiting_while_processing_listener import waitingWhileProcessingListener
__author__ = "Lemahieu Antoine"
__copyright__ = "Copyright 2022"
__credits__ = ["Lemahieu Antoine"]
__license__ = "GNU General Public License v3.0"
__maintainer__ = "Lemahieu Antoine"
__email__ = "Antoine.Lemahieu@ulb.be"
__status__ = "Dev"
[docs]class waitingWhileProcessingController(waitingWhileProcessingListener):
def __init__(self, processing_title, finish_method=None):
"""
Controller for the waiting window.
Create a new window for the waiting time while the computation is done.
:param processing_title: The title displayed on the window.
:type processing_title: str
:param finish_method: The method to call when the computation is finished.
:type finish_method: function
"""
self.main_listener = None
self.finish_method = finish_method
self.error = False
self.waiting_while_processing_view = waitingWhileProcessingView(processing_title)
self.waiting_while_processing_view.set_listener(self)
self.waiting_while_processing_view.show()
[docs] def stop_progress_bar(self, processing_title_finished, error=False):
"""
Stop the progress bar of the waiting window.
:param processing_title_finished: The title displayed on the window.
:type processing_title_finished: str
:param error: Set to True if an error occurred, avoid to call the finish method.
:type error: bool
"""
self.error = error
self.waiting_while_processing_view.stop_progress_bar(processing_title_finished)
"""
Setters
"""
[docs] def set_listener(self, listener):
"""
Set the main listener so that the controller is able to communicate with the main controller.
:param listener: main listener
:type listener: mainController
"""
self.main_listener = listener