Python Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesPython Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old October 4th, 2003, 12:16 PM
Baltor's Avatar
Baltor Baltor is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Posts: 67 Baltor User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 41 m
Reputation Power: 10
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!

Reply With Quote
  #2  
Old October 5th, 2003, 01:15 PM
Baltor's Avatar
Baltor Baltor is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Posts: 67 Baltor User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 41 m
Reputation Power: 10
Anyone? I really need help!

Reply With Quote
  #3  
Old October 5th, 2003, 03:45 PM
netytan's Avatar
netytan netytan is offline
Hello World :)
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Mar 2003
Location: Hull, UK
Posts: 2,537 netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 1 Week 2 Days 18 h 17 m 47 sec
Reputation Power: 68
Send a message via ICQ to netytan Send a message via AIM to netytan Send a message via MSN to netytan Send a message via Yahoo to netytan
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.
__________________
programming language development: www.netytan.com Hula


Reply With Quote
  #4  
Old October 5th, 2003, 05:11 PM
Baltor's Avatar
Baltor Baltor is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Posts: 67 Baltor User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 41 m
Reputation Power: 10
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.

Reply With Quote
  #5  
Old October 5th, 2003, 07:10 PM
netytan's Avatar
netytan netytan is offline
Hello World :)
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Mar 2003
Location: Hull, UK
Posts: 2,537 netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 1 Week 2 Days 18 h 17 m 47 sec
Reputation Power: 68
Send a message via ICQ to netytan Send a message via AIM to netytan Send a message via MSN to netytan Send a message via Yahoo to netytan
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.

Reply With Quote
  #6  
Old October 5th, 2003, 07:57 PM
Baltor's Avatar
Baltor Baltor is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Posts: 67 Baltor User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 41 m
Reputation Power: 10
OK, thanks for your help.
I've posted it there.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPython Programming > Problem with variables and Tkinter...

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap