Esempio n. 1
0
    def calculate_data(self):
        # Create a GrowthCalculator object
        growth = GrowthCalculator()

        # Update the GrowthCalculator parameters from the GUI options
        growth.a = self.options_menu.a_sb.value()
        growth.b = self.options_menu.b_sb.value()
        growth.c = self.options_menu.c_sb.value()
        growth.d = self.options_menu.d_sb.value()
        growth.predators = self.options_menu.predator_sb.value()
        growth.prey = self.options_menu.prey_sb.value()
        growth.iterations = self.options_menu.iterations_sb.value()
        growth.dt = self.options_menu.timedelta_sb.value()

        # Calculate the population growths
        results = growth.calculate()
        self.predator_history.extend(results['predator'])
        self.prey_history.extend(results['prey'])

        # Put the latest population sizes into the options toolbar
        self.options_menu.predator_sb.setValue(self.predator_history[-1])
        self.options_menu.prey_sb.setValue(self.prey_history[-1])

        # Redraw the graph
        self.redraw_graph()
 def setup(self):
     self.growth_calculator = GrowthCalculator()