Source code for tagit.controller.sidebox.pgm
"""
Part of the tagit module.
A copy of the license is provided with the project.
Author: Matthias Baumgartner, 2016
"""
# IMPORTS
# INNER-MODULE IMPORTS
from ..controller import DataController
# EXPORTS
__all__ = ('CSidebox_Program_Control', )
## CODE ##
[docs]class CSidebox_Program_Control(DataController):
"""A set of functions to manage the model.
"""
def __init__(self, widget, model, settings, parent=None, main_widget=None):
super(CSidebox_Program_Control, self).__init__(widget, model, settings, parent)
self.main_wx = main_widget
self.pgm = None
def unload(self):
if self.pgm is not None:
if self.pgm.is_running():
self.pgm.stop()
self.pgm.unload()
def load(self, program, path=None):
self.unload()
if program == 'BFS':
from tagit.program import Pgm_BFS
self.pgm = Pgm_BFS()
self.pgm.init(self.main_wx, self.on_start, self.on_stop)
if path is not None:
self.pgm.load(path)
self.parent.dispatch('status', '[color=#FF0000][b]BFS: [/b][/color] Program loaded')
def save(self, path):
self.pgm.save(path)
self.parent.dispatch('status', '[color=#FF0000][b]BFS: [/b][/color] Saved')
def on_stop(self):
self.widget.show_play(self.widget.start)
self.widget.show_load()
self.parent.dispatch('status', '[color=#FF0000][b]BFS: [/b][/color] Program stopped')
def on_start(self):
self.widget.show_pause(self.widget.pause)
self.parent.dispatch('status', '[color=#FF0000][b]BFS: [/b][/color] Started')
def start(self):
if self.pgm is None: return
self.pgm.start()
def stop(self):
if self.pgm is None or not self.pgm.is_running(): return
self.pgm.stop()
# continues with on_stop
def pause(self):
self.widget.show_play(self.widget.resume)
self.pgm.pause()
def resume(self):
self.widget.show_pause(self.widget.pause)
self.pgm.resume()
## EOF ##