Example #1
0
class SplashContainer(object):
    """
    I act as a Container for all the splash stuff
    """
    def __init__(self):
        self.ctrl = SplashController(Model())
        self.view = SplashView(self.ctrl)
        self.loop = None
        self.view.show()

    def pulse(self):
        try:
            self.view['splash_progress_bar'].pulse()
        except TypeError:
            pass

    def start_pulse(self):
        if not self.loop:
            self.loop = LoopingCall(self.pulse)
            self.loop.start(.2, now=True)
        else:
            raise Exception("Can't start loop twice")

    def stop_pulse(self):
        if self.loop:
            self.loop.stop()
            self.loop = None
        else:
            raise Exception("Can't stop a loop that hasn't started")

    def set_fraction(self, fraction):
        """Sets the given fraction in the progress bar"""
        try:
            self.view['splash_progress_bar'].set_fraction(fraction)
        except:
            pass

    def set_text(self, text):
        """Sets the given text in the progress bar"""
        try:
            self.view['splash_progress_bar'].set_text(text)
        except:
            pass

    def close(self):
        try:
            self.ctrl.model.unregister_observer(self.ctrl)
            self.view.get_top_widget().destroy()
        except AttributeError:
            pass

        self.ctrl = None
        self.view = None
class SplashContainer(object):
    """
    I act as a Container for all the splash stuff
    """
    def __init__(self):
        self.ctrl = SplashController(Model())
        self.view = SplashView(self.ctrl)
        self.loop = None
        self.view.show()

    def pulse(self):
        try:
            self.view['splash_progress_bar'].pulse()
        except TypeError:
            pass

    def start_pulse(self):
        if not self.loop:
            self.loop = LoopingCall(self.pulse)
            self.loop.start(.2, now=True)
        else:
            raise Exception("Can't start loop twice")

    def stop_pulse(self):
        if self.loop:
            self.loop.stop()
            self.loop = None
        else:
            raise Exception("Can't stop a loop that hasn't started")

    def set_fraction(self, fraction):
        """Sets the given fraction in the progress bar"""
        try:
            self.view['splash_progress_bar'].set_fraction(fraction)
        except:
            pass

    def set_text(self, text):
        """Sets the given text in the progress bar"""
        try:
            self.view['splash_progress_bar'].set_text(text)
        except:
            pass

    def close(self):
        try:
            self.ctrl.model.unregister_observer(self.ctrl)
            self.view.get_top_widget().destroy()
        except AttributeError:
            pass

        self.ctrl = None
        self.view = None
Example #3
0
 def __init__(self):
     self.ctrl = SplashController(Model())
     self.view = SplashView(self.ctrl)
     self.loop = None
     self.view.show()
 def __init__(self):
     self.ctrl = SplashController(Model())
     self.view = SplashView(self.ctrl)
     self.loop = None
     self.view.show()