Commit 0ee5bfd6 authored by Guillaume Seguin's avatar Guillaume Seguin

Conceal setting callback/validator/... better

parent 6e8d98f4
...@@ -291,13 +291,13 @@ class BuildDimensionsSetting(wxSetting): ...@@ -291,13 +291,13 @@ class BuildDimensionsSetting(wxSetting):
self.value = "%.02fx%.02fx%.02f%+.02f%+.02f%+.02f%+.02f%+.02f%+.02f" % tuple(values) self.value = "%.02fx%.02fx%.02f%+.02f%+.02f%+.02f%+.02f%+.02f%+.02f" % tuple(values)
class Settings(object): class Settings(object):
def _baudrate_list(self): return ["2400", "9600", "19200", "38400", "57600", "115200", "250000"] def __baudrate_list(self): return ["2400", "9600", "19200", "38400", "57600", "115200", "250000"]
def __init__(self, root): def __init__(self, root):
# defaults here. # defaults here.
# the initial value determines the type # the initial value determines the type
self._add(StringSetting("port", "", _("Serial port"), _("Port used to communicate with printer"))) self._add(StringSetting("port", "", _("Serial port"), _("Port used to communicate with printer")))
self._add(ComboSetting("baudrate", 115200, self._baudrate_list(), _("Baud rate"), _("Communications Speed"))) self._add(ComboSetting("baudrate", 115200, self.__baudrate_list(), _("Baud rate"), _("Communications Speed")))
self._add(BooleanSetting("tcp_streaming_mode", False, _("TCP streaming mode"), _("When using a TCP connection to the printer, the streaming mode will not wait for acks from the printer to send new commands. This will break things such as ETA prediction, but can result in smoother prints.")), root.update_tcp_streaming_mode) self._add(BooleanSetting("tcp_streaming_mode", False, _("TCP streaming mode"), _("When using a TCP connection to the printer, the streaming mode will not wait for acks from the printer to send new commands. This will break things such as ETA prediction, but can result in smoother prints.")), root.update_tcp_streaming_mode)
self._add(SpinSetting("bedtemp_abs", 110, 0, 400, _("Bed temperature for ABS"), _("Heated Build Platform temp for ABS (deg C)"), "Printer")) self._add(SpinSetting("bedtemp_abs", 110, 0, 400, _("Bed temperature for ABS"), _("Heated Build Platform temp for ABS (deg C)"), "Printer"))
self._add(SpinSetting("bedtemp_pla", 60, 0, 400, _("Bed temperature for PLA"), _("Heated Build Platform temp for PLA (deg C)"), "Printer")) self._add(SpinSetting("bedtemp_pla", 60, 0, 400, _("Bed temperature for PLA"), _("Heated Build Platform temp for PLA (deg C)"), "Printer"))
...@@ -353,23 +353,23 @@ class Settings(object): ...@@ -353,23 +353,23 @@ class Settings(object):
alias = None, autocomplete_list = None): alias = None, autocomplete_list = None):
setattr(self, setting.name, setting) setattr(self, setting.name, setting)
if callback: if callback:
setattr(self, "_" + setting.name + "_cb", callback) setattr(self, "__" + setting.name + "_cb", callback)
if validate: if validate:
setattr(self, "_" + setting.name + "_validate", validate) setattr(self, "__" + setting.name + "_validate", validate)
if alias: if alias:
setattr(self, "_" + setting.name + "_alias", alias) setattr(self, "__" + setting.name + "_alias", alias)
if autocomplete_list: if autocomplete_list:
setattr(self, "_" + setting.name + "_list", autocomplete_list) setattr(self, "__" + setting.name + "_list", autocomplete_list)
def _set(self, key, value): def _set(self, key, value):
try: try:
value = getattr(self, "_%s_alias" % key)()[value] value = getattr(self, "__%s_alias" % key)()[value]
except KeyError: except KeyError:
pass pass
except AttributeError: except AttributeError:
pass pass
try: try:
getattr(self, "_%s_validate" % key)(value) getattr(self, "__%s_validate" % key)(value)
except AttributeError: except AttributeError:
pass pass
t = type(getattr(self, key)) t = type(getattr(self, key))
...@@ -378,7 +378,7 @@ class Settings(object): ...@@ -378,7 +378,7 @@ class Settings(object):
try: try:
cb = None cb = None
try: try:
cb = getattr(self, "_%s_cb" % key) cb = getattr(self, "__%s_cb" % key)
except AttributeError: except AttributeError:
pass pass
if cb is not None: cb(key, value) if cb is not None: cb(key, value)
...@@ -389,11 +389,11 @@ class Settings(object): ...@@ -389,11 +389,11 @@ class Settings(object):
def _tabcomplete(self, key): def _tabcomplete(self, key):
try: try:
return getattr(self, "_%s_list" % key)() return getattr(self, "__%s_list" % key)()
except AttributeError: except AttributeError:
pass pass
try: try:
return getattr(self, "_%s_alias" % key)().keys() return getattr(self, "__%s_alias" % key)().keys()
except AttributeError: except AttributeError:
pass pass
return [] return []
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment