Fix graph error and make colors configurable

This commit is contained in:
Jordan
2021-12-05 20:35:37 -05:00
committed by jordanruthe
parent dd56d192cc
commit c3103d3b11
6 changed files with 76 additions and 35 deletions

View File

@@ -448,6 +448,42 @@ class KlipperScreen(Gtk.Window):
css_data = css_base_data + css.read()
css.close()
f = open(klipperscreendir + "/styles/base.conf")
style_options = json.load(f)
f.close()
self.gtk.color_list = style_options['graph_colors']
if os.path.exists(klipperscreendir + "/styles/%s/style.conf" % (self.theme)):
try:
f = open(klipperscreendir + "/styles/%s/style.conf" % (self.theme))
style_options.update(json.load(f))
f.close()
except Exception:
logging.error("Unable to parse custom template conf file.")
for i in range(len(style_options['graph_colors']['extruder']['colors'])):
num = "" if i == 0 else i+1
css_data += "\n.graph_label_extruder%s {border-left-color: #%s}" % (
num,
style_options['graph_colors']['extruder']['colors'][i]
)
for i in range(len(style_options['graph_colors']['bed']['colors'])):
css_data += "\n.graph_label_heater_bed%s {border-left-color: #%s}" % (
"" if i+1 == 1 else i+1,
style_options['graph_colors']['bed']['colors'][i]
)
for i in range(len(style_options['graph_colors']['fan']['colors'])):
css_data += "\n.graph_label_fan_%s {border-left-color: #%s}" % (
i+1,
style_options['graph_colors']['fan']['colors'][i]
)
for i in range(len(style_options['graph_colors']['sensor']['colors'])):
css_data += "\n.graph_label_sensor_%s {border-left-color: #%s}" % (
i+1,
style_options['graph_colors']['sensor']['colors'][i]
)
css_data = css_data.replace("KS_FONT_SIZE", str(self.gtk.get_font_size()))
style_provider = Gtk.CssProvider()