I have the following code where I have several small problems.
I have included some comments as I can't seem to get my 'pop up menu' button to work in order to retrieve the number of columns requested by the user.
I then need to be able to get the values entered into each entry box within these columns but by EACH ROW (a list of values per row) and I have not got a clue how to get these values when I don't always know how many columns I will have (see lambda function where there is currently 4 'set' values but need to have 'n').
If anyone could help as I'm really reaching a dead here, I would be eternally grateful! I'm fairly new to python and especially Tkinter and therefore it may be a problem within my class structure as this is my first program written using class and self.
def ValueBox(self):
self.number_boxes = self.value.get()
self.win2.destroy
return self.number_boxes
def ChoiceBox(self, choice):
if choice == "List":
self.win2 = Tk()
self.win2.title("List")
self.list_text = Label(self.win2, text="Please enter number of values to be used:")
self.list_text.grid(row=0, column=0, sticky="nsew", padx=1, pady=1)
self.value = StringVar()
self.list_values = Entry(self.win2, textvariable=self.value, justify="center")
self.list_values.grid(row=1, column=1, sticky="nsew", padx=1, pady=1)
#self.value_number = self.value.get()
#self.list_button = ttk.Button(self.win2, text="Enter", command=self.ValueBox)
self.list_values.bind('<Return>', self.ValueBox) # Link entry button to box.
#self.list_button.grid(row=2, column=1, sticky="nsew", padx=1, pady=1)
self.win2.mainloop()
#self.number_boxes = 4
column = 7
self.numbers = [StringVar() for i in xrange(self.number_boxes) ] #Name available in global scope.
for i in xrange(self.number_boxes):
choice_title = Label(self.frame_table, text='Value %g'% float(i+1), bg='white', borderwidth=0, width=10)
choice_title.grid(row=1, column=column+i, sticky="nsew", padx=1, pady=1)
boxes=[]
for i in xrange(self.number_boxes):
for j in range(2, rows):
box=Entry(self.frame_table,bg='white',borderwidth=0,textvariable=self.numbers[i], width=10, justify="center")
box.grid(row=j,column=column+i, sticky='nsew', padx=1, pady=1)
boxes.append(box)
print boxes
# = map(float, co_ord.strip('()').split(','))
#box1,box2,box3,box4=boxes
for i in self.numbers:
i.trace('w',lambda a,b,c,n=i: self.numberwritten(n) )
def numberwritten(self, numbers):
fg = self.numbers.get()
print fg