|
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 |
@@ -123,7 +123,7 @@ def excepthook(exc_type, exc_obj, exc_tb): |
123 | 123 | ALERT_ICON = "dialog_warning" |
124 | 124 | INFO_ICON = "dialog_information" |
125 | 125 |
|
126 | | - |
| 126 | +AXISLIST = ['offset', 'X', 'Y', 'Z', 'A', 'B', 'C', 'U', 'V', 'W', 'name'] |
127 | 127 |
|
128 | 128 | class gmoccapy(object): |
129 | 129 | def __init__(self, argv): |
@@ -2245,6 +2245,65 @@ def _init_offsetpage(self): |
2245 | 2245 | name = self.prefs.getpref(system_name, name, str) |
2246 | 2246 | names.append([system, name]) |
2247 | 2247 | self.widgets.offsetpage1.set_names(names) |
| 2248 | + for col, name in enumerate(AXISLIST): |
| 2249 | + if col > 9:break |
| 2250 | + temp = self.widgets.offsetpage1.wTree.get_object("cell_%s" % name) |
| 2251 | + temp.connect('editing-started', self.on_offset_col_edit_started, col) |
| 2252 | + |
| 2253 | + |
| 2254 | + def on_offset_col_edit_started(self, widget, filtered_path, new_text, col): |
| 2255 | + offsetpage = self.widgets.offsetpage1 |
| 2256 | + offsetview = offsetpage.view2 |
| 2257 | + model, treeiter = offsetview.get_selection().get_selected() |
| 2258 | + path = offsetpage.modelfilter.get_path(treeiter) |
| 2259 | + (store_path,) = offsetpage.modelfilter.convert_path_to_child_path(path) |
| 2260 | + row = store_path |
| 2261 | + if self.touch_button_dic["edit_offsets"].get_active(): |
| 2262 | + offset = self.dialogs.entry_dialog(self, |
| 2263 | + data=offsetpage.store[row][col], |
| 2264 | + header=_("Enter value for offset"), |
| 2265 | + label=_("%s %s-offset:" % (offsetpage.store[row][0], AXISLIST[col])), |
| 2266 | + integer=False) |
| 2267 | + if offset == "ERROR": |
| 2268 | + LOG.debug("conversion error") |
| 2269 | + self.dialogs.warning_dialog(self, _("Conversion error !"), |
| 2270 | + ("Please enter only numerical values\nValues have not been applied")) |
| 2271 | + elif offset == "CANCEL": |
| 2272 | + pass |
| 2273 | + else: |
| 2274 | + axisnum = col - 1 |
| 2275 | + try: |
| 2276 | + if self.stat.task_mode != linuxcnc.MODE_MDI: |
| 2277 | + self.command.mode(linuxcnc.MODE_MDI) |
| 2278 | + self.command.wait_complete() |
| 2279 | + if row == 0: |
| 2280 | + self.command.mdi("G43.1 %s %10.4f" % (AXISLIST[col], offset)) |
| 2281 | + elif row == 1: |
| 2282 | + self.command.mdi("#%s = %10.4f" % (str(5161 + axisnum), offset)) |
| 2283 | + elif row == 2: |
| 2284 | + self.command.mdi("#%s = %10.4f" % (str(5181 + axisnum), offset)) |
| 2285 | + elif row == 3: |
| 2286 | + self.command.mdi("G92 %s %10.4f" % (AXISLIST[col], offset)) |
| 2287 | + else: |
| 2288 | + pnum = row-3 |
| 2289 | + if not pnum == None: |
| 2290 | + if col == 10: |
| 2291 | + self.command.mdi("G10 L2 P%d R %10.4f" % (pnum, offset)) |
| 2292 | + else: |
| 2293 | + self.command.mdi("G10 L2 P%d %s %10.4f" % (pnum, AXISLIST[col], offset)) |
| 2294 | + self.command.mode(linuxcnc.MODE_MANUAL) |
| 2295 | + self.command.wait_complete() |
| 2296 | + self.command.mode(linuxcnc.MODE_MDI) |
| 2297 | + self.command.wait_complete() |
| 2298 | + except: |
| 2299 | + print(_("offsetpage widget error: MDI call error")) |
| 2300 | + offsetpage.reload_offsets() |
| 2301 | + # this is needed to get offsetview out of editing mode |
| 2302 | + GLib.timeout_add(50, |
| 2303 | + offsetview.set_cursor, |
| 2304 | + path, |
| 2305 | + offsetview.get_columns()[0], |
| 2306 | + True) |
2248 | 2307 |
|
2249 | 2308 | # Icon file selection stuff |
2250 | 2309 | def _init_IconFileSelection(self): |
|
0 commit comments