[Tutor] Tkinter Data Passing Problem

mdcooper mdcooper at uvic.ca
Mon Oct 24 23:36:25 CEST 2005


Hi,

I am having some trouble with tkinter.

I am creating a filled set of entry boxes so that a user can adjust certain 
data if desired. I would prefer that the box containing these data be separate 
from the main GUI.

The problem is that when I specify that the frame be part of root the data 
appears in the entry boxes (using textvariable = StringVar()) but if a second 
Tk() root is specified, the entry boxes appear, but there is no data. I cannot 
figure out why.

Can someone help?

Thanks,

Matt

def adjustGuassianData2(self, master):

	self.frames.append(Frame(master))
	self.frames[4].grid()
	self.entries=[]
	self.text=[]

	Label(self.frames[4], text="Frequencies").grid(row=0, column=0)
	Label(self.frames[4], text="Intensities").grid(row=0, column=1)
	Label(self.frames[4], text="New Intensities").grid(row=0, column=2)
	for r in range(len(self.frequencies)):
		self.text.append([[],[],[]])
		self.text[r][0]=StringVar()
		self.text[r][1]=StringVar()
		self.text[r][2]=StringVar()
		self.text[r][0].set("%3.2f" % (self.frequencies[r]))
		self.text[r][1].set("%3.2f" % (self.IR_intensities[r]))
		self.text[r][2].set("%3.2f" % (self.IR_intensities[r]))
		           
self.entries.append([Entry(self.frames[4],textvariable=self.text[r][0]),
			Entry(self.frames[4],textvariable=self.text[r][1]),
                        Label(self.frames[4], textvariable=self.text[r][2])])
		self.entries[r][0].grid(row=r+1, column=0)
		self.entries[r][1].grid(row=r+1, column=1)
		self.entries[r][2].grid(row=r+1, column=2)

	b = Button(self.frames[4], text="UPDATE!", command=self.updateEntries)
	b.grid(row=r+2,column=0,columnspan=3)




More information about the Tutor mailing list