[Tutor] Variables of Variables

Tino Dai tinoloc at gmail.com
Mon Jan 22 17:43:04 CET 2007


On 1/18/07, Danny Yoo <dyoo at hkn.eecs.berkeley.edu> wrote:
>
> > Rather than storing your data as variables, you could store it in a
> > dictionary.  Then you can dynamically access data however you like..
>
> Suggesting a dictionary here is right.
>
> ** Stuff deleted about why using variables of variables is bad ***


Actually, I started off with a dictionary with a bunch of parameters. To
give you some background, I writing my
first GUI, and using the parameters in a dictionary to control what box the
GUI displays next. So, it looks
something that looks like this:

data={'position':'middle','next':'self.add_entry_db
(widget,None)','previous':'self.add_entry(widget,None)'}

The dictionary called data gets passed to a button maker function that will
show various buttons depending on
the position value in the data dictionary. The clicked signal is then hooked
up to a callback function (I think that's
what you call it), and the next/previous values get sent up to various
functions. An example one of these various functions
is:

    def add_next_button(self,widget,Data=None):
        self.dbTableName=self.addEntryBox.get_text()
        self.addWin.destroy()
        if type(Data) == type(None):
            print "Why are we here?"
            exit()
        print Data
        Data()

where the Data variable is 'self.add_entry_db(widget,None)'. How do I pass
the Data variable to the add_next_button so
that the contents itself the data variable can execute?

Thanks,
Tino
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tutor/attachments/20070122/6e2eaec7/attachment.htm 


More information about the Tutor mailing list