Sorry, here is the code that makes the label widgets:

systemdata = [[0]*len(headers)]*len(machines)

for i in range(len(machines)):
    for j in range(len(headers)):
        systemdata[i][j] = tk.Label(root, text=' ')
        systemdata[i][j].grid(row=i+1, column=j+1)


If I do the following:

systemdata[1][2].config(text='Test')

It puts "Test" into position [2][2] rather than [1][2]. It appears to only "see" the last row ([2]).

Iain


Michael O'Donnell wrote:
Iain,

  You code is incomplete, the place where you create the Label widgets
is not included. We need that to see the problem.

Check the grid operation on each Label, in particular the row parameter.

Also, do a print as each Label is gridded, to see if they all are
actually created.

Mick

On Mon, Mar 16, 2009 at 10:50 PM, Iain Day
<i...@day-online.org.uk.invalid> wrote:
Hi,

I've written a short program which is supposed to populate a table
constructed from tk.Label widgets. It does this by looping over the rows.
Unfortunately, it only seems to populate the final row. What am I doing
wrong?

The code is:

def updatedata():
   updatetime.delete(0, tk.END)
   for i in range(len(machines)):
       print machines[i]
       status = sshshowstat(machines[i])

       for j in range(len(status)):
           param, value = status[j].split(': ')

           for k in range(len(variables)):
               if re.match(variables[k], param) is None:
                   continue
               else:
#                    print i, value
                   if value in ('Acquiring', 'Regulated'):
                       systemdata[i][k].config(text=value,
foreground='green')
                   elif value in ('Not Reg.'):
                       systemdata[i][k].config(text=value, foreground='red')
                   else:
                       systemdata[i][k].config(text=value)


tk.Button(root, text="Update Table Data",
command=updatedata).grid(row=len(machines)+1, column=len(variables),
sticky=tk.S)



Thanks,

Iain

_______________________________________________
Tkinter-discuss mailing list
Tkinter-discuss@python.org
http://mail.python.org/mailman/listinfo/tkinter-discuss


_______________________________________________
Tkinter-discuss mailing list
Tkinter-discuss@python.org
http://mail.python.org/mailman/listinfo/tkinter-discuss

Reply via email to