For Reference, the code below is pulled directly from the INI file. Note that I am currently testing in virtual box, not on the machine.
Code:
# REMAPPING
# for tool change commands
REMAP=M6 modalgroup=6 prolog=zbotatc_M6_prolog ngc=m400
REMAP=M7 modalgroup=8 argspec=p py=smart_cool_M7
REMAP=M8 modalgroup=8 argspec=p py=smart_cool_M8
REMAP=M9 modalgroup=8 py=smart_cool_M9
#for get user input stuff
REMAP=M10 modalgroup=4 python=m10
REMAP=M11 modalgroup=4 python=m11
REMAP=M12 modalgroup=4 python=m12
# for various GUI functions
REMAP=M600 modalgroup=10 argspec=PQ ngc=m600
REMAP=g30 modalgroup=1 argspec=xyza py=g300
REMAP=m998 modalgroup=5 argspec=xyza py=m998
REMAP=g50 modalgroup=1 py=g500
REMAP=g47 modalgroup=1 argspec=xyZpqRd py=g470
REMAP=g84 modalgroup=1 argspec=rpxyza prolog=cycle_prolog epilog=cycle_epilog py=g840
[PYTHON]
TOPLEVEL= python/toplevel.py
PATH_PREPEND= python
LOG_LEVEL=8
Code:
import hal, time
import serial
import sys
import commands
import redis
import emccanon
from interpreter import *
from constants import * #goody bag of values from Tormach
import tormach_file_util
import datetime
import remap
Code:
#!/usr/bin/python
import sys
from interpreter import *
from Tkinter import *
list = []
def m10(self, **words):
global list
if not self.task: return INTERP_OK
list.append(self.blocks[self.remap_level].comment)
return INTERP_OK
def done(self, dialog, entries):
for entry in entries:
val = entry[1].get()
if val.isdigit:
self.params[entry[0]] = float(val)
dialog.update()
dialog.destroy()
# Show the entries
def m11(self, **words):
if not self.task: return INTERP_OK
dir(self)
global list
entries = []
row = 1
if not hasattr(sys, 'argv'):
sys.argv = ['']
dialog = Tk()
dialog.title(self.blocks[self.remap_level].comment)
for item in list:
ret = item.split(";")
prompt = ret[0]
if len(ret) == 1:
param = "_" + prompt.replace(" ", "")
else:
param = "_" + ret[1].replace(" ", "")
Label(dialog, text=prompt).grid(row=row)
entry = Entry(dialog)
entry.grid(column=1, row=row)
try:
entry.insert(0, self.params[param])
except:
pass
entries.append((param, entry))
row += 1
Button(dialog, text='OK', command=lambda: done(self, dialog, entries)).grid(row=row, column=0, sticky=W, pady=4)
mainloop()
return INTERP_OK
def m12(self, **words):
global list
list = []
return INTERP_OK