|
1 | | -#!/usr/bin/env python3 |
| 1 | +#!/usr/bin/python3.12 |
2 | 2 | # -*- coding:UTF-8 -*- |
3 | 3 | """ |
4 | 4 | A GUI for LinuxCNC based on gladevcp and Python |
@@ -2251,58 +2251,61 @@ def _init_offsetpage(self): |
2251 | 2251 |
|
2252 | 2252 |
|
2253 | 2253 | def col_edit_started(self, widget, filtered_path, new_text, col): |
2254 | | - model, treeiter = self.widgets.offsetpage1.view2.get_selection().get_selected() |
2255 | | - path = self.widgets.offsetpage1.modelfilter.get_path(treeiter) |
2256 | | - (store_path,) = self.widgets.offsetpage1.modelfilter.convert_path_to_child_path(path) |
| 2254 | + def cancel_editing(): |
| 2255 | + # this is needed to get offsetview out of editing mode |
| 2256 | + GLib.timeout_add(50, |
| 2257 | + offsetview.set_cursor, |
| 2258 | + path, |
| 2259 | + offsetview.get_columns()[0], |
| 2260 | + True) |
| 2261 | + |
| 2262 | + offsetpage = self.widgets.offsetpage1 |
| 2263 | + offsetview = offsetpage.view2 |
| 2264 | + model, treeiter = offsetview.get_selection().get_selected() |
| 2265 | + path = offsetpage.modelfilter.get_path(treeiter) |
| 2266 | + (store_path,) = offsetpage.modelfilter.convert_path_to_child_path(path) |
2257 | 2267 | row = store_path |
2258 | 2268 | if self.touch_button_dic["edit_offsets"].get_active(): |
2259 | | - offset = self.dialogs.entry_dialog( |
2260 | | - self, |
2261 | | - header=_("Enter value for offset"), |
2262 | | - label=_("Set %s %s-offset to:" % (self.widgets.offsetpage1.store[row][0], AXISLIST[col])), |
2263 | | - integer=False) |
| 2269 | + offset = self.dialogs.entry_dialog(self, |
| 2270 | + data=offsetpage.store[row][col], |
| 2271 | + header=_("Enter value for offset"), |
| 2272 | + label=_("%s %s-offset:" % (offsetpage.store[row][0], AXISLIST[col])), |
| 2273 | + integer=False) |
2264 | 2274 | if offset == "ERROR": |
2265 | 2275 | LOG.debug("conversion error") |
2266 | 2276 | self.dialogs.warning_dialog(self, _("Conversion error !"), |
2267 | 2277 | ("Please enter only numerical values\nValues have not been applied")) |
2268 | | - self.touch_button_dic["edit_offsets"].set_active(False) |
2269 | | - return |
2270 | 2278 | elif offset == "CANCEL": |
2271 | | - self.touch_button_dic["edit_offsets"].set_active(False) |
2272 | | - return |
2273 | | - print(AXISLIST[col]) |
2274 | | - self.widgets.offsetpage1.store[row][col] = str(offset) |
2275 | | - axisnum = col - 1 |
2276 | | - try: |
2277 | | - if self.stat.task_mode != linuxcnc.MODE_MDI: |
| 2279 | + pass |
| 2280 | + else: |
| 2281 | + axisnum = col - 1 |
| 2282 | + try: |
| 2283 | + if self.stat.task_mode != linuxcnc.MODE_MDI: |
| 2284 | + self.command.mode(linuxcnc.MODE_MDI) |
| 2285 | + self.command.wait_complete() |
| 2286 | + if row == 0: |
| 2287 | + self.command.mdi("G43.1 %s %10.4f" % (AXISLIST[col], offset)) |
| 2288 | + elif row == 1: |
| 2289 | + self.command.mdi("#%s = %10.4f" % (str(5161 + axisnum), offset)) |
| 2290 | + elif row == 2: |
| 2291 | + self.command.mdi("#%s = %10.4f" % (str(5181 + axisnum), offset)) |
| 2292 | + elif row == 3: |
| 2293 | + self.command.mdi("G92 %s %10.4f" % (AXISLIST[col], offset)) |
| 2294 | + else: |
| 2295 | + pnum = row-3 |
| 2296 | + if not pnum == None: |
| 2297 | + if col == 10: |
| 2298 | + self.command.mdi("G10 L2 P%d R %10.4f" % (pnum, offset)) |
| 2299 | + else: |
| 2300 | + self.command.mdi("G10 L2 P%d %s %10.4f" % (pnum, AXISLIST[col], offset)) |
| 2301 | + self.command.mode(linuxcnc.MODE_MANUAL) |
| 2302 | + self.command.wait_complete() |
2278 | 2303 | self.command.mode(linuxcnc.MODE_MDI) |
2279 | 2304 | self.command.wait_complete() |
2280 | | - if row == 0: |
2281 | | - self.command.mdi("G43.1 %s %10.4f" % (AXISLIST[col], offset)) |
2282 | | - elif row == 1: |
2283 | | - self.command.mdi("#%s = %10.4f" % (str(5161 + axisnum), offset)) |
2284 | | - elif row == 2: |
2285 | | - self.command.mdi("#%s = %10.4f" % (str(5181 + axisnum), offset)) |
2286 | | - elif row == 3: |
2287 | | - self.command.mdi("G92 %s %10.4f" % (AXISLIST[col], offset)) |
2288 | | - else: |
2289 | | - print("TRY5") |
2290 | | - pnum = row-3 |
2291 | | - if not pnum == None: |
2292 | | - if col == 10: |
2293 | | - self.command.mdi("G10 L2 P%d R %10.4f" % (pnum, offset)) |
2294 | | - else: |
2295 | | - self.command.mdi("G10 L2 P%d %s %10.4f" % (pnum, AXISLIST[col], offset)) |
2296 | | - print(("G10 L2 P%d %s %10.4f" % (pnum, AXISLIST[col], offset))) |
2297 | | - self.command.mode(linuxcnc.MODE_MANUAL) |
2298 | | - self.command.wait_complete() |
2299 | | - self.command.mode(linuxcnc.MODE_MDI) |
2300 | | - self.command.wait_complete() |
2301 | | - except Exception as error: |
2302 | | - print(_("offsetpage widget error: MDI call error")) |
2303 | | - print(error) |
2304 | | - self.widgets.offsetpage1.reload_offsets() |
2305 | | - self.touch_button_dic["edit_offsets"].set_active(False) |
| 2305 | + except: |
| 2306 | + print(_("offsetpage widget error: MDI call error")) |
| 2307 | + offsetpage.reload_offsets() |
| 2308 | + cancel_editing() |
2306 | 2309 |
|
2307 | 2310 | # Icon file selection stuff |
2308 | 2311 | def _init_IconFileSelection(self): |
|
0 commit comments