Model Exercise SolutionΒΆ
The model should now contain the following top level function:
def line_colours():
colour_table = ["red", "blue", "black"]
return colour_table
The view should contain the following method:
def setColours(self,options):
self.colours.clear()
self.colours.addItems(options)
The presenter initialisation should now be:
def __init__(self, view, data_model, colour_list):
self.view = view
self.data_model = data_model
self.view.setColours(colour_list)
# connect statements
self.view.plotSignal.connect(self.updatePlot)
And the Main module should now pass the two models into the presenter:
def __init__(self, parent=None):
super().__init__(parent)
self.window = QtWidgets.QMainWindow()
my_view = view.View()
data_model = model.DataGenerator()
colour_list = model.line_colours()
self.presenter = presenter.Presenter(my_view, data_model, colour_list)
# set the view for the main window
self.setCentralWidget(my_view)
self.setWindowTitle("view tutorial")