shorten _screen.printer to _printer

This commit is contained in:
alfrix committed 2022-12-11 09:17:18 -03:00
1 parent f31ae7a829
commit 70d7564a78
11 files changed
+52 -52

No files matched your search

+10 -10
View File
@@ -113,11 +113,11 @@ class BasePanel(ScreenPanel):
try:
for child in self.control['temp_box'].get_children():
self.control['temp_box'].remove(child)
if not show or self._screen.printer.get_temp_store_devices() is None:
if not show or self._printer.get_temp_store_devices() is None:
return
img_size = self._gtk.img_scale * self.bts
for device in self._screen.printer.get_temp_store_devices():
for device in self._printer.get_temp_store_devices():
self.labels[device] = Gtk.Label(label="100º")
self.labels[device].set_ellipsize(Pango.EllipsizeMode.START)
@@ -131,18 +131,18 @@ class BasePanel(ScreenPanel):
nlimit = int(round(log(self._screen.width, 10) * 5 - 10.5))
n = 0
if self._screen.printer.get_tools():
self.current_extruder = self._screen.printer.get_stat("toolhead", "extruder")
if self._printer.get_tools():
self.current_extruder = self._printer.get_stat("toolhead", "extruder")
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"])
n += 1
if self._screen.printer.has_heated_bed():
if self._printer.has_heated_bed():
self.control['temp_box'].add(self.labels['heater_bed_box'])
n += 1
# Options in the config have priority
for device in self._screen.printer.get_temp_store_devices():
for device in self._printer.get_temp_store_devices():
# Users can fill the bar if they want
if n >= nlimit + 1:
break
@@ -154,7 +154,7 @@ class BasePanel(ScreenPanel):
break
# If there is enough space fill with heater_generic
for device in self._screen.printer.get_temp_store_devices():
for device in self._printer.get_temp_store_devices():
if n >= nlimit:
break
if device.startswith("heater_generic"):
@@ -166,7 +166,7 @@ class BasePanel(ScreenPanel):
def get_icon(self, device, img_size):
if device.startswith("extruder"):
if self._screen.printer.extrudercount > 1:
if self._printer.extrudercount > 1:
if device == "extruder":
device = "extruder0"
return self._gtk.Image(f"extruder-{device[8:]}", img_size, img_size)
@@ -227,10 +227,10 @@ class BasePanel(ScreenPanel):
if action != "notify_status_update" or self._screen.printer is None:
return
devices = self._screen.printer.get_temp_store_devices()
devices = self._printer.get_temp_store_devices()
if devices is not None:
for device in devices:
temp = self._screen.printer.get_dev_stat(device, "temperature")
temp = self._printer.get_dev_stat(device, "temperature")
if temp is not None and device in self.labels:
name = ""
if not (device.startswith("extruder") or device.startswith("heater_bed")):
+6 -6
View File
@@ -33,7 +33,7 @@ class BedLevelPanel(ScreenPanel):
grid = self._gtk.HomogeneousGrid()
grid.attach(self.buttons['dm'], 0, 0, 1, 1)
if "screws_tilt_adjust" in self._screen.printer.get_config_section_list():
if "screws_tilt_adjust" in self._printer.get_config_section_list():
self.buttons['screws'] = self._gtk.Button("refresh", _("Screws Adjust"), "color4")
self.buttons['screws'].connect("clicked", self.screws_tilt_calculate)
grid.attach(self.buttons['screws'], 0, 1, 1, 1)
@@ -41,7 +41,7 @@ class BedLevelPanel(ScreenPanel):
self.screws = self._get_screws("screws_tilt_adjust")
logging.info(f"screws_tilt_adjust: {self.screws}")
probe = self._screen.printer.get_probe()
probe = self._printer.get_probe()
if probe:
if "x_offset" in probe:
self.x_offset = round(float(probe['x_offset']), 1)
@@ -57,7 +57,7 @@ class BedLevelPanel(ScreenPanel):
self.screws = new_screws
logging.info(f"screws with offset: {self.screws}")
elif "bed_screws" in self._screen.printer.get_config_section_list():
elif "bed_screws" in self._printer.get_config_section_list():
self.screws = self._get_screws("bed_screws")
logging.info(f"bed_screws: {self.screws}")
@@ -262,7 +262,7 @@ class BedLevelPanel(ScreenPanel):
self.buttons[key].set_label(f"{value}")
def go_to_position(self, widget, position):
if self._screen.printer.get_stat("toolhead", "homed_axes") != "xyz":
if self._printer.get_stat("toolhead", "homed_axes") != "xyz":
self._screen._ws.klippy.gcode_script(KlippyGcodes.HOME)
logging.debug(f"Going to position: {position}")
script = [
@@ -335,7 +335,7 @@ class BedLevelPanel(ScreenPanel):
def _get_screws(self, config_section_name):
screws = []
config_section = self._screen.printer.get_config_section(config_section_name)
config_section = self._printer.get_config_section(config_section_name)
for item in config_section:
logging.debug(f"{config_section_name}: {config_section[item]}")
result = re.match(r"([\-0-9\.]+)\s*,\s*([\-0-9\.]+)", config_section[item])
@@ -347,7 +347,7 @@ class BedLevelPanel(ScreenPanel):
return sorted(screws, key=lambda s: (float(s[1]), float(s[0])))
def screws_tilt_calculate(self, widget):
if self._screen.printer.get_stat("toolhead", "homed_axes") != "xyz":
if self._printer.get_stat("toolhead", "homed_axes") != "xyz":
self._screen._ws.klippy.gcode_script(KlippyGcodes.HOME)
self.response_count = 0
self.buttons['screws'].set_sensitive(False)
+3 -3
View File
@@ -68,7 +68,7 @@ class BedMeshPanel(ScreenPanel):
def activate(self):
self.load_meshes()
with contextlib.suppress(KeyError):
self.activate_mesh(self._screen.printer.get_stat("bed_mesh", "profile_name"))
self.activate_mesh(self._printer.get_stat("bed_mesh", "profile_name"))
def activate_mesh(self, profile):
if self.active_mesh is not None:
@@ -268,13 +268,13 @@ class BedMeshPanel(ScreenPanel):
def calibrate_mesh(self, widget):
self._screen.show_popup_message(_("Calibrating"), level=1)
if self._screen.printer.get_stat("toolhead", "homed_axes") != "xyz":
if self._printer.get_stat("toolhead", "homed_axes") != "xyz":
self._screen._ws.klippy.gcode_script(KlippyGcodes.HOME)
self._screen._ws.klippy.gcode_script("BED_MESH_CALIBRATE")
# Load zcalibrate to do a manual mesh
if not self._screen.printer.get_probe():
if not self._printer.get_probe():
self.menu_item_clicked(widget, "refresh", {"name": _("Mesh calibrate"), "panel": "zcalibrate"})
def send_clear_mesh(self, widget):
+1 -1
View File
@@ -19,7 +19,7 @@ class ExtrudePanel(ScreenPanel):
def __init__(self, screen, title):
super().__init__(screen, title)
self.current_extruder = self._printer.get_stat("toolhead", "extruder")
macros = self._screen.printer.get_gcode_macros()
macros = self._printer.get_gcode_macros()
self.load_filament = any("LOAD_FILAMENT" in macro.upper() for macro in macros)
self.unload_filament = any("UNLOAD_FILAMENT" in macro.upper() for macro in macros)
+1 -1
View File
@@ -113,7 +113,7 @@ class InputShaperPanel(ScreenPanel):
def start_calibration(self, widget, method):
self.labels['popover'].popdown()
if self._screen.printer.get_stat("toolhead", "homed_axes") != "xyz":
if self._printer.get_stat("toolhead", "homed_axes") != "xyz":
self._screen._ws.klippy.gcode_script(KlippyGcodes.HOME)
self.calibrating_axis = method
if method == "x":
+11 -11
View File
@@ -122,7 +122,7 @@ class JobStatusPanel(ScreenPanel):
self.labels['thumbnail'] = self._gtk.Image("file", self._screen.width / 4, self._screen.height / 4)
self.labels['info_grid'] = Gtk.Grid()
self.labels['info_grid'].attach(self.labels['thumbnail'], 0, 0, 1, 1)
if self._screen.printer.get_tools():
if self._printer.get_tools():
self.current_extruder = self._printer.get_stat("toolhead", "extruder")
diameter = float(self._printer.get_config_section(self.current_extruder)['filament_diameter'])
self.fila_section = pi * ((diameter / 2) ** 2)
@@ -159,7 +159,7 @@ class JobStatusPanel(ScreenPanel):
nlimit = 2 if self._screen.width <= 480 else 3
n = 0
self.buttons['extruder'] = {}
if self._screen.printer.get_tools():
if self._printer.get_tools():
for i, extruder in enumerate(self._printer.get_tools()):
self.labels[extruder] = Gtk.Label("-")
self.buttons['extruder'][extruder] = self._gtk.Button(f"extruder-{i}", "", None, self.bts,
@@ -183,7 +183,7 @@ class JobStatusPanel(ScreenPanel):
self.buttons['heater']['heater_bed'].set_halign(Gtk.Align.START)
self.labels['temp_grid'].attach(self.buttons['heater']['heater_bed'], n, 0, 1, 1)
n += 1
for dev in self._screen.printer.get_heaters():
for dev in self._printer.get_heaters():
if n >= nlimit:
break
if dev.startswith("heater_generic"):
@@ -201,7 +201,7 @@ class JobStatusPanel(ScreenPanel):
if titlebar_items is not None:
titlebar_items = [str(i.strip()) for i in titlebar_items.split(',')]
logging.info(f"Titlebar items: {titlebar_items}")
for device in self._screen.printer.get_heaters():
for device in self._printer.get_heaters():
if device.startswith("temperature_sensor"):
name = " ".join(device.split(" ")[1:])
for item in titlebar_items:
@@ -227,9 +227,9 @@ class JobStatusPanel(ScreenPanel):
szfe.set_column_homogeneous(True)
szfe.attach(self.buttons['speed'], 0, 0, 3, 1)
szfe.attach(self.buttons['z'], 2, 0, 2, 1)
if self._screen.printer.get_tools():
if self._printer.get_tools():
szfe.attach(self.buttons['extrusion'], 0, 1, 3, 1)
if self._screen.printer.get_fans():
if self._printer.get_fans():
szfe.attach(self.buttons['fan'], 2, 1, 2, 1)
info = Gtk.Grid()
@@ -583,7 +583,7 @@ class JobStatusPanel(ScreenPanel):
fan_label = ""
for fan in self.fans:
with contextlib.suppress(KeyError):
self.fans[fan]['speed'] = f"{self._screen.printer.get_fan_speed(fan) * 100:3.0f}%"
self.fans[fan]['speed'] = f"{self._printer.get_fan_speed(fan) * 100:3.0f}%"
fan_label += f" {self.fans[fan]['name']}{self.fans[fan]['speed']}"
if fan_label:
self.buttons['fan'].set_label(fan_label[:12])
@@ -742,16 +742,16 @@ class JobStatusPanel(ScreenPanel):
self.enable_button("resume", "cancel")
self.can_close = False
else:
offset = self._screen.printer.get_stat("gcode_move", "homing_origin")
offset = self._printer.get_stat("gcode_move", "homing_origin")
self.zoffset = float(offset[2]) if offset else 0
if self.zoffset != 0:
endstop = (self._screen.printer.config_section_exists("stepper_z") and
not self._screen.printer.get_config_section("stepper_z")['endstop_pin'].startswith("probe"))
endstop = (self._printer.config_section_exists("stepper_z") and
not self._printer.get_config_section("stepper_z")['endstop_pin'].startswith("probe"))
if endstop:
self.buttons['button_grid'].attach(self.buttons["save_offset_endstop"], 0, 0, 1, 1)
else:
self.buttons['button_grid'].attach(Gtk.Label(""), 0, 0, 1, 1)
if self._screen.printer.get_probe():
if self._printer.get_probe():
self.buttons['button_grid'].attach(self.buttons["save_offset_probe"], 1, 0, 1, 1)
else:
self.buttons['button_grid'].attach(Gtk.Label(""), 1, 0, 1, 1)
+2 -2
View File
@@ -82,7 +82,7 @@ class MovePanel(ScreenPanel):
grid.attach(self.buttons['z_tilt'], 2, 0, 1, 1)
elif self._printer.config_section_exists("quad_gantry_level"):
grid.attach(self.buttons['quad_gantry_level'], 2, 0, 1, 1)
elif "delta" in self._screen.printer.get_config_section("printer")['kinematics']:
elif "delta" in self._printer.get_config_section("printer")['kinematics']:
grid.attach(self.buttons['motors_off'], 2, 0, 1, 1)
else:
grid.attach(self.buttons['home_xy'], 2, 0, 1, 1)
@@ -164,7 +164,7 @@ class MovePanel(ScreenPanel):
return
if action != "notify_status_update":
return
homed_axes = self._screen.printer.get_stat("toolhead", "homed_axes")
homed_axes = self._printer.get_stat("toolhead", "homed_axes")
if homed_axes == "xyz":
if "gcode_move" in data and "gcode_position" in data["gcode_move"]:
self.labels['pos_x'].set_text(f"X: {data['gcode_move']['gcode_position'][0]:.2f}")
+4 -4
View File
@@ -30,10 +30,10 @@ class PowerPanel(ScreenPanel):
self.content.add(scroll)
def activate(self):
devices = self._screen.printer.get_power_devices()
devices = self._printer.get_power_devices()
for x in devices:
self.devices[x]['switch'].disconnect_by_func(self.on_switch)
self.devices[x]['switch'].set_active(self._screen.printer.get_power_device_status(x) == "on")
self.devices[x]['switch'].set_active(self._printer.get_power_device_status(x) == "on")
self.devices[x]['switch'].connect("notify::active", self.on_switch, x)
@@ -49,7 +49,7 @@ class PowerPanel(ScreenPanel):
switch = Gtk.Switch()
switch.set_hexpand(False)
switch.set_active(self._screen.printer.get_power_device_status(device) == "on")
switch.set_active(self._printer.get_power_device_status(device) == "on")
switch.connect("notify::active", self.on_switch, device)
switch.set_property("width-request", round(self._gtk.font_size * 7))
switch.set_property("height-request", round(self._gtk.font_size * 3.5))
@@ -77,7 +77,7 @@ class PowerPanel(ScreenPanel):
self.labels['devices'].show_all()
def load_power_devices(self):
devices = self._screen.printer.get_power_devices()
devices = self._printer.get_power_devices()
for x in devices:
self.add_device(x)
+3 -3
View File
@@ -103,13 +103,13 @@ class SplashScreenPanel(ScreenPanel):
def check_power_status(self):
if 'power' in self.labels:
devices = self._screen.printer.get_power_devices()
devices = self._printer.get_power_devices()
if devices is not None:
for device in devices:
if self._screen.printer.get_power_device_status(device) == "off":
if self._printer.get_power_device_status(device) == "off":
self.labels['power'].set_sensitive(True)
break
elif self._screen.printer.get_power_device_status(device) == "on":
elif self._printer.get_power_device_status(device) == "on":
self.labels['power'].set_sensitive(False)
def firmware_restart(self, widget):
+1 -1
View File
@@ -43,7 +43,7 @@ class TemperaturePanel(ScreenPanel):
self.show_preheat = True
selection.extend(self._printer.get_heaters())
else:
current_extruder = self._screen.printer.get_stat("toolhead", "extruder")
current_extruder = self._printer.get_stat("toolhead", "extruder")
if current_extruder:
selection.append(current_extruder)
+10 -10
View File
@@ -21,7 +21,7 @@ class ZCalibratePanel(ScreenPanel):
def __init__(self, screen, title):
super().__init__(screen, title)
self.z_offset = None
self.probe = self._screen.printer.get_probe()
self.probe = self._printer.get_probe()
if self.probe:
self.z_offset = float(self.probe['z_offset'])
logging.info(f"Z offset: {self.z_offset}")
@@ -51,7 +51,7 @@ class ZCalibratePanel(ScreenPanel):
functions = []
pobox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
if self._printer.config_section_exists("stepper_z") \
and not self._screen.printer.get_config_section("stepper_z")['endstop_pin'].startswith("probe"):
and not self._printer.get_config_section("stepper_z")['endstop_pin'].startswith("probe"):
self._add_button("Endstop", "endstop", pobox)
functions.append("endstop")
if self.probe:
@@ -61,7 +61,7 @@ class ZCalibratePanel(ScreenPanel):
# This is used to do a manual bed mesh if there is no probe
self._add_button("Bed mesh", "mesh", pobox)
functions.append("mesh")
if "delta" in self._screen.printer.get_config_section("printer")['kinematics']:
if "delta" in self._printer.get_config_section("printer")['kinematics']:
if "probe" in functions:
self._add_button("Delta Automatic", "delta", pobox)
functions.append("delta")
@@ -132,7 +132,7 @@ class ZCalibratePanel(ScreenPanel):
def start_calibration(self, widget, method):
self.labels['popover'].popdown()
if self._screen.printer.get_stat("toolhead", "homed_axes") != "xyz":
if self._printer.get_stat("toolhead", "homed_axes") != "xyz":
self._screen._ws.klippy.gcode_script(KlippyGcodes.HOME)
if method == "probe":
@@ -166,8 +166,8 @@ class ZCalibratePanel(ScreenPanel):
speed = self.probe['speed']
# Use safe_z_home position
if "safe_z_home" in self._screen.printer.get_config_section_list():
safe_z = self._screen.printer.get_config_section("safe_z_home")
if "safe_z_home" in self._printer.get_config_section_list():
safe_z = self._printer.get_config_section("safe_z_home")
safe_z_xy = safe_z['home_xy_position']
safe_z_xy = [str(i.strip()) for i in safe_z_xy.split(',')]
if x_position is None:
@@ -188,7 +188,7 @@ class ZCalibratePanel(ScreenPanel):
if x_position is not None and y_position is not None:
logging.debug(f"Configured probing position X: {x_position} Y: {y_position}")
self._screen._ws.klippy.gcode_script(f'G0 X{x_position} Y{y_position} F3000')
elif "delta" in self._screen.printer.get_config_section("printer")['kinematics']:
elif "delta" in self._printer.get_config_section("printer")['kinematics']:
logging.info("Detected delta kinematics calibrating at 0,0")
self._screen._ws.klippy.gcode_script('G0 X0 Y0 F3000')
else:
@@ -197,8 +197,8 @@ class ZCalibratePanel(ScreenPanel):
def _calculate_position(self):
logging.debug("Position not configured, probing the middle of the bed")
try:
xmax = float(self._screen.printer.get_config_section("stepper_x")['position_max'])
ymax = float(self._screen.printer.get_config_section("stepper_y")['position_max'])
xmax = float(self._printer.get_config_section("stepper_x")['position_max'])
ymax = float(self._printer.get_config_section("stepper_y")['position_max'])
except KeyError:
logging.error("Couldn't get max position from stepper_x and stepper_y")
return
@@ -231,7 +231,7 @@ class ZCalibratePanel(ScreenPanel):
self.process_busy(data)
return
if action == "notify_status_update":
if self._screen.printer.get_stat("toolhead", "homed_axes") != "xyz":
if self._printer.get_stat("toolhead", "homed_axes") != "xyz":
self.widgets['zposition'].set_text("Z: ?")
elif "gcode_move" in data and "gcode_position" in data['gcode_move']:
self.update_position(data['gcode_move']['gcode_position'])