Fix GUI when cfg.render.line_width missing

pull/357/head
nyanpasu64 2018-12-11 06:12:16 -08:00
rodzic 7797929338
commit 85caa921ec
1 zmienionych plików z 15 dodań i 0 usunięć

Wyświetl plik

@ -171,6 +171,19 @@ def nrow_ncol_property(altered: str, unaltered: str) -> property:
return property(get, set)
def default_property(path: str, default):
def getter(self: 'ConfigModel'):
val = rgetattr(self.cfg, path)
if val is None:
return default
else:
return val
def setter(self: 'ConfigModel', val: int):
rsetattr(self.cfg, path, val)
return property(getter, setter)
class ConfigModel(PresentationModel):
cfg: Config
combo_symbols = {}
@ -214,6 +227,8 @@ class ConfigModel(PresentationModel):
combo_symbols['layout__orientation'] = ['h', 'v']
combo_text['layout__orientation'] = ['Horizontal', 'Vertical']
render__line_width = default_property('render__line_width', 1.5)
# TODO mutate _cfg and convert all colors to #rrggbb on access