Can you give us the whole class?
Just a note, 'l00' is a heck of a variable name, looks a lot like the number '100', I would avoid it!
Thanks; here it is, hope you can figure out my beginner's scribblings;)
class Application(LabelFrame): # 3
def __init__(self, rowpos, colpos, framenr, crWidg, master=None):
LabelFrame.__init__(self, master)#, name='lf'+chr(framenr+ord('0'))) # 4
if crWidg == 1:
self.grid(row=rowpos, column=colpos) # 5
self.createWidgets(framenr, rowpos, colpos)
elif crWidg == 0:
self.grid(row=rowpos, column=colpos, columnspan=3, sticky=W) # 5
lident = 'l'+chr(rowpos+ord('0'))+chr(colpos+ord('0'))
self.l00 = Label(self, borderwidth=1, relief=RIDGE, anchor=W, \
name=lident, text=" "+lident+" ")
self.l00.grid(row=0, column=0, columnspan=3)
else:
self.grid(row=rowpos, column=0, columnspan=3, sticky=E) # 5
self.e01 = Entry(self, borderwidth=0, relief=RIDGE, width=colpos)
self.e01.grid(row=rowpos, sticky=E)
self.e01.bind_all('<Key>', self.key)
self.e01.focus_set()
#
# this function generates a widget (cell) name relating to its position within the LabelFrame
#
def get_cell_ident(self, framenr, cells_per_frame_inX, cells_per_frame_inY, rownum, colnum):
rowst, colst = divmod(framenr,cells_per_frame_inX) # get result and remainder
rowst = rowst*cells_per_frame_inY # start-nr of the row-cell
colst = colst*cells_per_frame_inX # start-nr of the column-cell
text = chr(rowst+rownum+ord('0'))+ \
chr(colst+colnum+ord('0')) # this is the ident described in the top table
return text
#
# this function instantiates m * n Label-widgets and 'grid's them into the previously instantiated LabelFrame
#
def createWidgets(self, framenum, rowposn, colposn):
for rownr in range(0,cellsperframeinY): # WITHIN each frame, process .....
for colnr in range(0,cellsperframeinX): # .... each cell.
ident = self.get_cell_ident(framenum, cellsperframeinX, \
cellsperframeinY, rownr, colnr)
self.wlab = Label(self, borderwidth=2, relief=RIDGE, \
text=ident, name='w'+ident)
self.wlab.grid(row=rownr, column=colnr, ipadx=5, ipady=5)
#
# this is the function which has been bound to the Entry-box 'e01' (instantiated above in Application)
#
def key(self, event):
if event.char == event.keysym:
msg = 'Normal Key %r' % event.char
elif len(event.char) == 1:
msg = 'Punctuation Key %r (%r)' % (event.keysym, event.char)
else:
msg = 'Special Key %r' % event.keysym
l00.config(text=msg)