Skip to content

Commit 951de0e

Browse files
committed
Gmoccapy, offsetpage: update to calculator use
- 'edit offsets' mode remains active after changing a value - preset calculator to current value - simplify calculator dialog text - general code cleanup
1 parent 4f57d45 commit 951de0e

1 file changed

Lines changed: 47 additions & 44 deletions

File tree

src/emc/usr_intf/gmoccapy/gmoccapy.py

Lines changed: 47 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/env python3
1+
#!/usr/bin/python3.12
22
# -*- coding:UTF-8 -*-
33
"""
44
A GUI for LinuxCNC based on gladevcp and Python
@@ -2251,58 +2251,61 @@ def _init_offsetpage(self):
22512251

22522252

22532253
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)
22572267
row = store_path
22582268
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)
22642274
if offset == "ERROR":
22652275
LOG.debug("conversion error")
22662276
self.dialogs.warning_dialog(self, _("Conversion error !"),
22672277
("Please enter only numerical values\nValues have not been applied"))
2268-
self.touch_button_dic["edit_offsets"].set_active(False)
2269-
return
22702278
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()
22782303
self.command.mode(linuxcnc.MODE_MDI)
22792304
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()
23062309

23072310
# Icon file selection stuff
23082311
def _init_IconFileSelection(self):

0 commit comments

Comments
 (0)