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(config_obj: Configuration, strategy_name: str, caller: int, values): """ Set GUI values for a strategy based on values passed. :param config_obj: Configuration QDialog object (from configuration.py) :param strategy_name: 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 = config_obj.get_category_tab(caller) target_values = config_obj.strategyDict[tab, strategy_name, 'values'] parameters = config_obj.strategyDict[tab, strategy_name, 'parameters'] layout = config_obj.strategyDict[tab, strategy_name, 'layout'] while len(values) < len(target_values): delete_strategy_inputs(config_obj.strategyDict, parameters, strategy_name, tab) while len(values) > len(target_values): add_strategy_inputs(config_obj.strategyDict, parameters, strategy_name, layout, tab) for index, widget in enumerate(target_values): value = values[index] set_value(widget, value)