Need call by Name or any other solution...!?!

Emile van Sebille emile at fenx.com
Tue Nov 13 22:55:50 EST 2001


"Th. Heidenreich" <python at heidenreichs.de> wrote in message
news:263c4e12.0111131731.3a7b49f2 at posting.google.com...
> Hi,
>
> I´ve got the following problem: I want to assign a number of variables
> (which are not constant) a value by an entry box. Better look at the
> code:
>
>
> def confirm(self):
> print self.right
>
> def __init__(self, nof_entries, categories):
> self.right = []
> for i in range(nof_entries):
> list_label = Label(text = categories[i], relief="flat")
> list_label.grid( row = i+2  , column = 0)
> self.right.append(chr(65+i))  # just to have something in there

More than just something, this is putting the 'A' in self.right that you're
seeing below.


> right_label.append(Entry( relief = "sunken", bd = 2, textvariable =
> self.right[i]))  # **** THATS THE THING THAT DOSN´T WORK   ****
> right_label[i].grid(row = i+2  , column = 1)
>
> b_confirm = Button(text = "Confirm", command = self.confirm)
> b_confirm.grid(row = laenge+3, column = 0, columnspan = 2)
>
> ...
>
>
> self.right[0] for example refers to a variable named "A" - but it
> should refer to a variable CONTAINING "A", so how can I assign a


Where is this 'A' you want it to be instead of the 'A' you put in it above?


> textvariable to an entry of an array?? Or has anyone another idea how
> to do this???
>

You'll probably want to use getattr(container_of_A, self.right[i]) or
container_of_A[self.right[i])

HTH,


--

Emile van Sebille
emile at fenx.com

---------




More information about the Python-list mailing list