[help]Is this a bug or my code's fault

dolephi9080 member27604 at dbforums.com
Tue Apr 8 05:29:53 EDT 2003


import Tkinter
import sys
import os
import os.path



if __name__ == "__main__":
    rt = Tkinter.Tk()
    btn = Tkinter.Button(rt,text='one')
    btn.setvar('v','one')  #<=here I set a var to the btn object
    with v='one'
    btn.pack()
    btn1=Tkinter.Button(rt,text="aa")
    btn1.setvar('v','aa')   #<=here I set a vat to the btn1 object
    v='aa'
    btn1.pack()
    print btn1.getvar('v') #<= print the btn1 v
    print btn.getvar('v') #<= print the btn v

    rt.mainloop()




please look at the comment, I set the value to two buttons, but when I
print it at last, two buttons got the same data. I don't know why when I
set the btn1's value, it will rewrite the btn's value, is this a bug? by
the way I'm using activestate python 2.2.2

--
Posted via http://dbforums.com




More information about the Python-list mailing list