Refactor UI configuration logic to use `set_data_dict` and add config persistence with `write_config`
This commit is contained in:
parent
74c70bca76
commit
c2b103f598
|
|
@ -102,43 +102,44 @@ class RichInterface(UIInterface):
|
||||||
if pressure_unit == '':
|
if pressure_unit == '':
|
||||||
pressure_unit = 'K'
|
pressure_unit = 'K'
|
||||||
|
|
||||||
self.__parent.config.config_data["checkwx_api_key"] = api_key
|
self.__parent.config.set_data_dict({ "checkwx_api_key": api_key})
|
||||||
|
|
||||||
if always_show_detailed == 'Y':
|
if always_show_detailed == 'Y':
|
||||||
self.__parent.config.config_data["always_show_detailed"] = True
|
self.__parent.config.set_data_dict({"always_show_detailed":True})
|
||||||
else:
|
else:
|
||||||
self.__parent.config.config_data["always_show_detailed"] = False
|
self.__parent.config.set_data_dict({"always_show_detailed": False})
|
||||||
|
|
||||||
if wind_speed_unit == 'K':
|
if wind_speed_unit == 'K':
|
||||||
self.__parent.config.config_data["wind_speed_unit"] = "Keep"
|
self.__parent.config.set_data_dict({"wind_speed_unit":"Keep"})
|
||||||
elif wind_speed_unit == 'M':
|
elif wind_speed_unit == 'M':
|
||||||
self.__parent.config.config_data["wind_speed_unit"] = "Miles"
|
self.__parent.config.set_data_dict({"wind_speed_unit":"Miles"})
|
||||||
elif wind_speed_unit == 'N':
|
elif wind_speed_unit == 'N':
|
||||||
self.__parent.config.config_data["wind_speed_unit"] = "Knots"
|
self.__parent.config.set_data_dict({"wind_speed_unit": "Knots"})
|
||||||
elif wind_speed_unit == 'H':
|
elif wind_speed_unit == 'H':
|
||||||
self.__parent.config.config_data["wind_speed_unit"] = "KM/H"
|
self.__parent.config.set_data_dict({"wind_speed_unit": "KM/H"})
|
||||||
|
|
||||||
if temp_unit == 'K':
|
if temp_unit == 'K':
|
||||||
self.__parent.config.config_data["temp_unit"] = "Keep"
|
self.__parent.config.set_data_dict({"temp_unit":"Keep"})
|
||||||
elif temp_unit == 'C':
|
elif temp_unit == 'C':
|
||||||
self.__parent.config.config_data["temp_unit"] = "Celsius"
|
self.__parent.config.set_data_dict({ "temp_unit": "Celsius"})
|
||||||
elif temp_unit == 'F':
|
elif temp_unit == 'F':
|
||||||
self.__parent.config.config_data["temp_unit"] = "Fahrenheit"
|
self.__parent.config.set_data_dict({ "temp_unit": "Fahrenheit"})
|
||||||
|
|
||||||
if visibility_unit == 'K':
|
if visibility_unit == 'K':
|
||||||
self.__parent.config.config_data["visibility_unit"] = "Keep"
|
self.__parent.config.set_data_dict({ "visibility_unit": "Keep"})
|
||||||
elif visibility_unit == 'S':
|
elif visibility_unit == 'S':
|
||||||
self.__parent.config.config_data["visibility_unit"] = "SM"
|
self.__parent.config.set_data_dict({"visibility_unit": "SM"})
|
||||||
elif visibility_unit == 'M':
|
elif visibility_unit == 'M':
|
||||||
self.__parent.config.config_data["visibility_unit"] = "Meters"
|
self.__parent.config.set_data_dict({"visibility_unit": "Miles"})
|
||||||
|
|
||||||
if pressure_unit == 'K':
|
if pressure_unit == 'K':
|
||||||
self.__parent.config.config_data["pressure_unit"] = "Keep"
|
self.__parent.config.set_data_dict({"pressure_unit": "Keep"})
|
||||||
elif pressure_unit == 'H':
|
elif pressure_unit == 'H':
|
||||||
self.__parent.config.config_data["pressure_unit"] = "HPa"
|
self.__parent.config.set_data_dict({ "pressure_unit": "HPa"})
|
||||||
elif pressure_unit == 'I':
|
elif pressure_unit == 'I':
|
||||||
self.__parent.config.config_data["pressure_unit"] = "InHg"
|
self.__parent.config.set_data_dict({ "pressure_unit": "InHg"})
|
||||||
|
|
||||||
|
self.__parent.config.write_config()
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
if not self.__parent.is_configured and self.mode != "configure":
|
if not self.__parent.is_configured and self.mode != "configure":
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue