Tix, spinboxes, and 1>=5

John McMonagle johnmc at velseis.com.au
Wed Feb 22 22:01:12 EST 2006


On Wed, 2006-02-22 at 18:37 -0800, cjbackhouse at gmail.com wrote:
> This odd bug has been annoying me for several days now. I finally got
> round to making this, frankly hilarious, testcase:
> 
> 
> from Tix import *
> 
> def sayfive(num):
>     if num<5: print num,"< 5"
>     else: print num,">= 5"
> 
> sayfive(4)
> sayfive(6)
> rootwnd=Tk()
> Control(rootwnd,command=sayfive).pack()
> rootwnd.mainloop()
> 
> 
> So, our program starts, the first two lines executed write "4<6" "6>=5"
> as expected. Now the user changes the value in the spinner, and we get
> output like "1>=5". What magic is Tix pulling, and more importantly how
> the hell do I stop it?

This should fix your problem:

from Tix import *

def sayfive(num):
    num = int(num)
    if num<5: print num,"< 5"
    else: print num,">= 5"

sayfive(4)
sayfive(6)
rootwnd=Tk()
Control(rootwnd,command=sayfive).pack()
rootwnd.mainloop()


The entry in the spinbox is a string.




-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.




More information about the Python-list mailing list