[Tkinter-discuss] Filling a series of tk.Label

jimscafe pdhartley at gmail.com
Thu Mar 19 09:24:39 CET 2009


I hope the problem has been solved for you.

I found your message because I was searching the internet for my own
solution. I am doing the exact same as you, creating a grid of labels.

How do you plan to scroll horizontally if the number of columns in the data
exceeds the number displayed?

I decided to use the Scale widget, it works but a scrollbar would be better.
I just couldn't figure out how to use the scrollbar - it seems that it needs
to be attached to a frame or similar, then how do you set the values? This
is easy in a Scale, but it doesn't look as good.

I also named the labels that displayed the data so that I could easily
identify when a user clicks on a label, which cell they had chosen. I want
to let them drill down on the data in a cell (the application is for monthly
financial data).



Iain Day 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 at python.org
> http://mail.python.org/mailman/listinfo/tkinter-discuss
> 
> 

-- 
View this message in context: http://www.nabble.com/Filling-a-series-of-tk.Label-tp22548194p22595082.html
Sent from the Python - tkinter-discuss mailing list archive at Nabble.com.



More information about the Tkinter-discuss mailing list