def load_strategy_from_config(self, caller: int, strategyName: str, config: dict): """ This function will load the strategy from the config dictionary provided. :param caller: Caller to manipulate. :param strategyName: Name of strategy to load. :param config: Configuration dictionary to load. :return: None """ key = f'{strategyName.lower()}Length' if key not in config: return valueCount = config[key] tab = self.get_category_tab(caller) valueWidgets = self.strategyDict[tab, strategyName, 'values'] parameters = self.strategyDict[tab, strategyName, 'parameters'] groupBoxLayout = self.strategyDict[tab, strategyName, 'layout'] self.strategyDict[tab, strategyName, 'groupBox'].setChecked(config[f'{strategyName.lower()}']) while valueCount > len(valueWidgets): add_strategy_inputs(self.strategyDict, parameters, strategyName, groupBoxLayout, tab) while valueCount < len(valueWidgets): delete_strategy_inputs(self.strategyDict, parameters, strategyName, tab) for index, widget in enumerate(valueWidgets, start=1): value = config[f'{strategyName.lower()}{index}'] set_value(widget, value)
def set_strategy_values(self, strategyName: str, caller: int, values): """ Set GUI values for a strategy based on values passed. :param strategyName: Name of the strategy that'll have its values set. :param caller: Caller that'll determine which tab object gets returned. :param values: List of values to populate GUI with. :return: None """ tab = self.get_category_tab(caller) targetValues = self.strategyDict[tab, strategyName, 'values'] parameters = self.strategyDict[tab, strategyName, 'parameters'] layout = self.strategyDict[tab, strategyName, 'layout'] while len(values) < len(targetValues): delete_strategy_inputs(self.strategyDict, parameters, strategyName, tab) while len(values) > len(targetValues): add_strategy_inputs(self.strategyDict, parameters, strategyName, layout, tab) for index, widget in enumerate(targetValues): value = values[index] set_value(widget, value)