Tkinter: runtime widget naming?

Isaac To Kar Keung kkto at csis.hku.hk
Thu May 24 20:48:55 EDT 2001


>>>>> "sternber" ==   <sternber at socrates.Berkeley.EDU> writes:

    sternber> I'm translating a Tk system that does alot of this: set b
    sternber> ".mybutton" ...  button $b ...

    sternber> What is a good way to do this in Python?

I think the correct question is, why on the hell you want to do this in
Python?  In Tcl/Tk, you don't have array support, you don't have dictionary
support, so everything is a string, and you'd like to encode things within
your variable names.  But come on... you are now in Python.  You have all
the normally available things there.  Why not writing something like this?

  buttons = {}
  buttons['ok'] = Button(...)
  buttons['cancel'] = Button(...)

Regards,
Isaac.



More information about the Python-list mailing list