|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now! |
|
#1
|
||||
|
||||
|
Problem with variables and Tkinter...
OK, so I'v got 11 radio buttons hooked up to one variable: self.weaponbonus. However, no matter what radio button I have checked, self.weaponbonus is treated as 0. This is my code:
Code:
self.weaponbonus = IntVar
self.radio1 = Radiobutton(master, text="+1", variable=self.weaponbonus, value=1)
self.radio1.grid(row=1, column=0)
self.radio2 = Radiobutton(master, text="+2", variable=self.weaponbonus, value=2)
self.radio2.grid(row=1, column=1)
self.radio3 = Radiobutton(master, text="+3", variable=self.weaponbonus, value=3)
self.radio3.grid(row=1, column=2)
self.radio4 = Radiobutton(master, text="+4", variable=self.weaponbonus, value=4)
self.radio4.grid(row=1, column=3)
self.radio5 = Radiobutton(master, text="+5", variable=self.weaponbonus, value=5)
self.radio5.grid(row=1, column=4)
self.radio6 = Radiobutton(master, text="+6", variable=self.weaponbonus, value=6)
self.radio6.grid(row=2, column=0)
self.radio7 = Radiobutton(master, text="+7", variable=self.weaponbonus, value=7)
self.radio7.grid(row=2, column=1)
self.radio8 = Radiobutton(master, text="+8", variable=self.weaponbonus, value=8)
self.radio8.grid(row=2, column=2)
self.radio9 = Radiobutton(master, text="+9", variable=self.weaponbonus, value=9)
self.radio9.grid(row=2, column=3)
self.radio10 = Radiobutton(master, text="+10", variable=self.weaponbonus, value=10)
self.radio10.grid(row=2, column=4)
self.radioran = Radiobutton(master, text="Random", variable=self.weaponbonus, value=99)
self.radioran.grid(row=3, column=0, columnspan=5)
totalweaponbonus = self.weaponbonus
if totalweaponbonus == 99:
totalweaponbonus = random.randint(1, 10)
Does anyone know what's wrong? Thanks.
__________________
Before you criticize someone, walk a mile in their shoes, that way when you do criticize them, you're a mile away and you have their shoes! |
|
#2
|
||||
|
||||
|
Anyone? I really need help!
|
|
#3
|
||||
|
||||
|
Hey Baltor,
I'm not a GUI guy persay but i did mess around with it for an hour of so last night, no luck. By "self.weaponbonus is treated as 0" do you mean you got the value PYV0 or something similar (which is what i was getting), it appears to me that the RadioButton widget just isn't updating the value correctly? But i wouldn't know howe to fix this.. I was looking at the online docs on Radiobutton but there examples were very similar to yours (and didn't work either) ![]() Sorry, Mark. |
|
#4
|
||||
|
||||
|
Yeah, I get PYVO.
Also, if I have: Code:
self.weaponbonus = int() Instead of: Code:
self.weaponbonus = IntVar I get self.weaponbonus = 0. I'm really confused; I don't see any reason why this wouldn't work. |
|
#5
|
||||
|
||||
|
i've tried int() aswell, it should work as far as i can see! Maybe were just missing somthing but.. and like i said i'm not really into the whole GUI thing! I've always opted for the web based taskes instead of GUI's, but give it a few years and i dout you'll be able to see much of a border between the too, at least program wise.
Sorry Baltor, maybe this i question that should be asked to the powers that be on comp.lang.python: http://www.dbforums.com/f97/ Mark. |
|
#6
|
||||
|
||||
|
OK, thanks for your help.
I've posted it there. |
![]() |
| Viewing: Dev Shed Forums > Programming Languages > Python Programming > Problem with variables and Tkinter... |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|