Tix, spinboxes, and 1>=5

C

cjbackhouse

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?
 
J

John McMonagle

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.
 
C

cjbackhouse

The entry in the spinbox is a string.

Thanks. The only question now is why oh why would anyone design
something so stupid.
(severely tempted to go back to a strongly typed language before even
finishing one program)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,776
Messages
2,569,603
Members
45,189
Latest member
CryptoTaxSoftware

Latest Threads

Top