I am currently testing the Mcode that Andy posted earlier in this thread and get the following error.
Code:
14:17:58 | pycall(m11):
Traceback (most recent call last):
File "python/remap.py", line 395, in m11
dialog = Tk()
File "/usr/lib/python2.7/lib-tk/Tkinter.py", line 1762, in __init__
baseName = os.path.basename(sys.argv[0])
IndexError: list index out
For reference, the TK routine is posted below.
Code:
class Tk(Misc, Wm):
"""Toplevel widget of Tk which represents mostly the main window
of an application. It has an associated Tcl interpreter."""
_w = '.'
def __init__(self, screenName=None, baseName=None, className='Tk',
useTk=1, sync=0, use=None):
"""Return a new Toplevel widget on screen SCREENNAME. A new Tcl interpreter will
be created. BASENAME will be used for the identification of the profile file (see
readprofile).
It is constructed from sys.argv[0] without extensions if None is given. CLASSNAME
is the name of the widget class."""
self.master = None
self.children = {}
self._tkloaded = 0
# to avoid recursions in the getattr code in case of failure, we
# ensure that self.tk is always _something_.
self.tk = None
if baseName is None:
import os
baseName = os.path.basename(sys.argv[0])
baseName, ext = os.path.splitext(baseName)
if ext not in ('.py', '.pyc', '.pyo'):
baseName = baseName + ext
interactive = 0
self.tk = _tkinter.create(screenName, baseName, className, interactive, wantobjects, useTk, sync, use)
if useTk:
self._loadtk()
if not sys.flags.ignore_environment:
# Issue #16248: Honor the -E flag to avoid code injection.
self.readprofile(baseName, className)
The exact Gcode I used is below
Code:
M12
M10 (RADIUS)
M10 (LENGTH)
M10 (MASS/KG;MASS);
M11 (ENTER PARAMETERS)
(DEBUG, _radius = #<radius>)
(DEBUG, _length = #<length>)
(DEBUG, _mass = #<mass>)
M2
The "List index out" would suggest that the list is not being set, and returning nil during the TK routine? I am not sure why this is happening or what I am doing wrong.
The code below is taken directly from Andy's earlier post.
Code:
#!/usr/bin/python
import sys
from interpreter import *
from Tkinter import *
list = []
# Add an entry
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
Any suggestions?