From 2d42e0fcea056ec2982c6a9169b2d70b34c5d85e Mon Sep 17 00:00:00 2001 From: alfrix Date: Thu, 9 May 2024 11:59:30 -0300 Subject: [PATCH] move and zcalibrate: changes in z invert now invert z will swap the button position in both panels --- panels/move.py | 20 ++++++++++++++++---- panels/zcalibrate.py | 16 ++++++++++++---- 2 files changed, 28 insertions(+), 8 deletions(-) diff --git a/panels/move.py b/panels/move.py index 6a09cfd5..9c6d0312 100644 --- a/panels/move.py +++ b/panels/move.py @@ -80,8 +80,12 @@ class Panel(ScreenPanel): grid.attach(self.buttons["x-"], 2, 1, 1, 1) grid.attach(self.buttons["y+"], 1, 0, 1, 1) grid.attach(self.buttons["y-"], 1, 1, 1, 1) - grid.attach(self.buttons["z+"], 3, 0, 1, 1) - grid.attach(self.buttons["z-"], 3, 1, 1, 1) + if self._config.get_config()["main"].getboolean("invert_z", False): + grid.attach(self.buttons["z+"], 3, 1, 1, 1) + grid.attach(self.buttons["z-"], 3, 0, 1, 1) + else: + grid.attach(self.buttons["z+"], 3, 0, 1, 1) + grid.attach(self.buttons["z-"], 3, 1, 1, 1) grid.attach(self.buttons["home"], 0, 0, 1, 1) grid.attach(self.buttons["motors_off"], 2, 0, 1, 1) @@ -155,6 +159,7 @@ class Panel(ScreenPanel): "name": _("Invert Z"), "type": "binary", "value": "False", + "callback": self.reinit_move, } }, { @@ -196,6 +201,11 @@ class Panel(ScreenPanel): self._screen.panels_reinit.append("bed_level") self._screen.panels_reinit.append("bed_mesh") + def reinit_move(self, widget): + self._screen.panels_reinit.append("move") + self._screen.panels_reinit.append("zcalibrate") + self._screen._menu_go_back(home=True) + def process_update(self, action, data): if action != "notify_status_update": return @@ -228,8 +238,10 @@ class Panel(ScreenPanel): self.distance = distance def move(self, widget, axis, direction): - if self._config.get_config()["main"].getboolean( - f"invert_{axis.lower()}", False + axis = axis.lower() + if ( + self._config.get_config()["main"].getboolean(f"invert_{axis}", False) + and axis != "z" ): direction = "-" if direction == "+" else "+" diff --git a/panels/zcalibrate.py b/panels/zcalibrate.py index 224ec550..2729b36e 100644 --- a/panels/zcalibrate.py +++ b/panels/zcalibrate.py @@ -85,16 +85,24 @@ class Panel(ScreenPanel): grid = Gtk.Grid(column_homogeneous=True) if self._screen.vertical_mode: - grid.attach(self.buttons['zpos'], 0, 1, 1, 1) - grid.attach(self.buttons['zneg'], 0, 2, 1, 1) + if self._config.get_config()["main"].getboolean("invert_z", False): + grid.attach(self.buttons['zpos'], 0, 2, 1, 1) + grid.attach(self.buttons['zneg'], 0, 1, 1, 1) + else: + grid.attach(self.buttons['zpos'], 0, 1, 1, 1) + grid.attach(self.buttons['zneg'], 0, 2, 1, 1) grid.attach(self.buttons['start'], 0, 0, 1, 1) grid.attach(pos, 1, 0, 1, 1) grid.attach(self.buttons['complete'], 1, 1, 1, 1) grid.attach(self.buttons['cancel'], 1, 2, 1, 1) grid.attach(distances, 0, 3, 2, 1) else: - grid.attach(self.buttons['zpos'], 0, 0, 1, 1) - grid.attach(self.buttons['zneg'], 0, 1, 1, 1) + if self._config.get_config()["main"].getboolean("invert_z", False): + grid.attach(self.buttons['zpos'], 0, 1, 1, 1) + grid.attach(self.buttons['zneg'], 0, 0, 1, 1) + else: + grid.attach(self.buttons['zpos'], 0, 0, 1, 1) + grid.attach(self.buttons['zneg'], 0, 1, 1, 1) grid.attach(self.buttons['start'], 1, 0, 1, 1) grid.attach(pos, 1, 1, 1, 1) grid.attach(self.buttons['complete'], 2, 0, 1, 1)