48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
|
return True
# Load values from conf. store into gtk widgets
def load_config(self, config, prefix="config_", widgets={}):
for key,val in config.items():
w = self.main.get_widget(prefix + key) or widgets.get(prefix + key)
if w:
# number
if isinstance(w, gtk.SpinButton):
w.set_value(int(val))
# input field
elif isinstance(w, gtk.Entry):
w.set_text(str(val))
# checkmark
elif isinstance(w, gtk.CheckButton):
w.set_active(bool(val))
# dropdown
elif isinstance(w, ComboBoxText):
w.set_default(val)
# list
elif isinstance(w, gtk.ListStore):
w.clear()
if isinstance(val, dict):
for k,v in val.items():
w.append([k, v, uikit.app_bin_check(v)])
w.append(["", "", gtk.STOCK_NEW])
elif isinstance(val, list):
for row in val:
log.DATA(row)
w.append([str(e) for e in row])
if len(val):
w.append(["" for e in val[0]])
#log.CONF("config load", prefix+key, val, type(w))
# Store gtk widget valus back into conf. dict
def save_config(self, config, prefix="config_", save=0, widgets={}):
for key,val in config.items():
w = self.main.get_widget(prefix + key) or widgets.get(prefix + key)
if w:
# int
|
>
|
<
|
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
|
return True
# Load values from conf. store into gtk widgets
def load_config(self, config, prefix="config_", widgets={}):
for key,val in config.items():
w = self.main.get_widget(prefix + key) or widgets.get(prefix + key)
#log.CONF("load_config()", prefix+key, "=", val, "→", type(w))
if w:
# number
if isinstance(w, gtk.SpinButton):
w.set_value(int(val))
# input field
elif isinstance(w, gtk.Entry):
w.set_text(str(val))
# checkmark
elif isinstance(w, gtk.CheckButton):
w.set_active(bool(val))
# dropdown
elif isinstance(w, ComboBoxText):
w.set_default(str(val))
# list
elif isinstance(w, gtk.ListStore):
w.clear()
if isinstance(val, dict):
for k,v in val.items():
w.append([k, v, uikit.app_bin_check(v)])
w.append(["", "", gtk.STOCK_NEW])
elif isinstance(val, list):
for row in val:
log.DATA(row)
w.append([str(e) for e in row])
if len(val):
w.append(["" for e in val[0]])
# Store gtk widget valus back into conf. dict
def save_config(self, config, prefix="config_", save=0, widgets={}):
for key,val in config.items():
w = self.main.get_widget(prefix + key) or widgets.get(prefix + key)
if w:
# int
|