fix #775
This commit is contained in:
parent
2fc01c07b6
commit
7ee162092c
@ -117,68 +117,71 @@ class BasePanel(ScreenPanel):
|
|||||||
return
|
return
|
||||||
|
|
||||||
def show_heaters(self, show=True):
|
def show_heaters(self, show=True):
|
||||||
for child in self.control['temp_box'].get_children():
|
try:
|
||||||
self.control['temp_box'].remove(child)
|
for child in self.control['temp_box'].get_children():
|
||||||
if not show or self._screen.printer.get_temp_store_devices() is None:
|
self.control['temp_box'].remove(child)
|
||||||
return
|
if not show or self._screen.printer.get_temp_store_devices() is None:
|
||||||
|
return
|
||||||
|
|
||||||
printer_cfg = self._config.get_printer_config(self._screen.connected_printer)
|
printer_cfg = self._config.get_printer_config(self._screen.connected_printer)
|
||||||
if printer_cfg is not None:
|
if printer_cfg is not None:
|
||||||
self.titlebar_name_type = printer_cfg.get("titlebar_name_type", None)
|
self.titlebar_name_type = printer_cfg.get("titlebar_name_type", None)
|
||||||
else:
|
else:
|
||||||
self.titlebar_name_type = None
|
self.titlebar_name_type = None
|
||||||
logging.info(f"Titlebar name type: {self.titlebar_name_type}")
|
logging.info(f"Titlebar name type: {self.titlebar_name_type}")
|
||||||
|
|
||||||
img_size = self._gtk.img_scale * .5
|
img_size = self._gtk.img_scale * .5
|
||||||
for device in self._screen.printer.get_temp_store_devices():
|
for device in self._screen.printer.get_temp_store_devices():
|
||||||
self.labels[device] = Gtk.Label(label="100º")
|
self.labels[device] = Gtk.Label(label="100º")
|
||||||
self.labels[device].set_ellipsize(Pango.EllipsizeMode.START)
|
self.labels[device].set_ellipsize(Pango.EllipsizeMode.START)
|
||||||
|
|
||||||
self.labels[f'{device}_box'] = Gtk.Box()
|
self.labels[f'{device}_box'] = Gtk.Box()
|
||||||
icon = self.get_icon(device, img_size)
|
icon = self.get_icon(device, img_size)
|
||||||
if icon is not None:
|
if icon is not None:
|
||||||
self.labels[f'{device}_box'].pack_start(icon, False, False, 3)
|
self.labels[f'{device}_box'].pack_start(icon, False, False, 3)
|
||||||
self.labels[f'{device}_box'].pack_start(self.labels[device], False, False, 0)
|
self.labels[f'{device}_box'].pack_start(self.labels[device], False, False, 0)
|
||||||
|
|
||||||
# Limit the number of items according to resolution
|
# Limit the number of items according to resolution
|
||||||
nlimit = int(round(log(self._screen.width, 10) * 5 - 10.5))
|
nlimit = int(round(log(self._screen.width, 10) * 5 - 10.5))
|
||||||
|
|
||||||
n = 0
|
n = 0
|
||||||
if self._screen.printer.get_tools():
|
if self._screen.printer.get_tools():
|
||||||
self.current_extruder = self._screen.printer.get_stat("toolhead", "extruder")
|
self.current_extruder = self._screen.printer.get_stat("toolhead", "extruder")
|
||||||
if self.current_extruder and f"{self.current_extruder}_box" in self.labels:
|
if self.current_extruder and f"{self.current_extruder}_box" in self.labels:
|
||||||
self.control['temp_box'].add(self.labels[f"{self.current_extruder}_box"])
|
self.control['temp_box'].add(self.labels[f"{self.current_extruder}_box"])
|
||||||
|
n += 1
|
||||||
|
|
||||||
|
if self._screen.printer.has_heated_bed():
|
||||||
|
self.control['temp_box'].add(self.labels['heater_bed_box'])
|
||||||
n += 1
|
n += 1
|
||||||
|
|
||||||
if self._screen.printer.has_heated_bed():
|
# Options in the config have priority
|
||||||
self.control['temp_box'].add(self.labels['heater_bed_box'])
|
if printer_cfg is not None:
|
||||||
n += 1
|
titlebar_items = printer_cfg.get("titlebar_items", None)
|
||||||
|
if titlebar_items is not None:
|
||||||
# Options in the config have priority
|
titlebar_items = [str(i.strip()) for i in titlebar_items.split(',')]
|
||||||
if printer_cfg is not None:
|
logging.info(f"Titlebar items: {titlebar_items}")
|
||||||
titlebar_items = printer_cfg.get("titlebar_items", None)
|
for device in self._screen.printer.get_temp_store_devices():
|
||||||
if titlebar_items is not None:
|
# Users can fill the bar if they want
|
||||||
titlebar_items = [str(i.strip()) for i in titlebar_items.split(',')]
|
if n >= nlimit + 1:
|
||||||
logging.info(f"Titlebar items: {titlebar_items}")
|
|
||||||
for device in self._screen.printer.get_temp_store_devices():
|
|
||||||
# Users can fill the bar if they want
|
|
||||||
if n >= nlimit + 1:
|
|
||||||
break
|
|
||||||
name = device.split()[1] if len(device.split()) > 1 else device
|
|
||||||
for item in titlebar_items:
|
|
||||||
if name == item:
|
|
||||||
self.control['temp_box'].add(self.labels[f"{device}_box"])
|
|
||||||
n += 1
|
|
||||||
break
|
break
|
||||||
|
name = device.split()[1] if len(device.split()) > 1 else device
|
||||||
|
for item in titlebar_items:
|
||||||
|
if name == item:
|
||||||
|
self.control['temp_box'].add(self.labels[f"{device}_box"])
|
||||||
|
n += 1
|
||||||
|
break
|
||||||
|
|
||||||
# If there is enough space fill with heater_generic
|
# If there is enough space fill with heater_generic
|
||||||
for device in self._screen.printer.get_temp_store_devices():
|
for device in self._screen.printer.get_temp_store_devices():
|
||||||
if n >= nlimit:
|
if n >= nlimit:
|
||||||
break
|
break
|
||||||
if device.startswith("heater_generic"):
|
if device.startswith("heater_generic"):
|
||||||
self.control['temp_box'].add(self.labels[f"{device}_box"])
|
self.control['temp_box'].add(self.labels[f"{device}_box"])
|
||||||
n += 1
|
n += 1
|
||||||
self.control['temp_box'].show_all()
|
self.control['temp_box'].show_all()
|
||||||
|
except Exception as e:
|
||||||
|
logging.debug(f"Couldn't create heaters box: {e}")
|
||||||
|
|
||||||
def get_icon(self, device, img_size):
|
def get_icon(self, device, img_size):
|
||||||
if device.startswith("extruder"):
|
if device.startswith("extruder"):
|
||||||
|
@ -440,7 +440,7 @@ class JobStatusPanel(ScreenPanel):
|
|||||||
if self.filename != "none":
|
if self.filename != "none":
|
||||||
self._screen._ws.klippy.print_start(self.filename)
|
self._screen._ws.klippy.print_start(self.filename)
|
||||||
self.new_print()
|
self.new_print()
|
||||||
GLib.timeout_add_seconds(5, self.enable_button("restart"))
|
GLib.timeout_add_seconds(5, self.enable_button, "restart")
|
||||||
|
|
||||||
def resume(self, widget):
|
def resume(self, widget):
|
||||||
self._screen._ws.klippy.print_resume(self._response_callback, "enable_button", "pause", "cancel")
|
self._screen._ws.klippy.print_resume(self._response_callback, "enable_button", "pause", "cancel")
|
||||||
@ -497,7 +497,7 @@ class JobStatusPanel(ScreenPanel):
|
|||||||
if self.state not in ["printing", "paused", "cancelling"]:
|
if self.state not in ["printing", "paused", "cancelling"]:
|
||||||
self._screen.printer_ready()
|
self._screen.printer_ready()
|
||||||
self._printer.change_state("ready")
|
self._printer.change_state("ready")
|
||||||
GLib.timeout_add_seconds(5, self.enable_button("menu"))
|
GLib.timeout_add_seconds(5, self.enable_button, "menu")
|
||||||
|
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user