RadioButton Problem

Hi,

Hi, I am new to python and also new to wxpython. I have a simple radiobutton problem.The following is my sample code.

self.rb1 = wx.RadioButton(self.mainpa,40,“Title1”,wx.Point(20,60))
self.Bind(wx.EVT_RADIOBUTTON,self.OnSelect,id =40)

self.rb2 = wx.RadioButton(self.mainpa,50,“Title2”,wx.Point(20,80))
self.Bind(wx.EVT_RADIOBUTTON,self.OnSelect,id =50)

self.ok = wx.Button(self.mainpa, 80, ‘Ok’,wx.Point(20,280))

def OnSelect(self,event):
radio_select = event.GetEventObject()
if radio_select.GetLabel() == ‘Title1’:
print ‘Title1 selected’
else:
print ‘Title2 selected’

I want to change this code. So when radio button Title1 is clicked and then the ok button is clicked, then it should print ‘Title1 selected’ and sameway when Title2 is clicked and then ok button is clicked, then it should print ‘Title2 Selected’

Any help please !!
Thanks
Prasoona

Thursday, June 7, 2007, 11:01:20 AM, Thippana, Prasoonadevi wrote:

Hi,

Hi, I am new to python and also new to wxpython. I have a simple
radiobutton problem.The following is my sample code.

self.rb1 = wx.RadioButton(self.mainpa,40,"Title1",wx.Point(20,60))
self.Bind(wx.EVT_RADIOBUTTON,self.OnSelect,id =40)

self.rb2 = wx.RadioButton(self.mainpa,50,"Title2",wx.Point(20,80))
self.Bind(wx.EVT_RADIOBUTTON,self.OnSelect,id =50)

self.ok = wx.Button(self.mainpa, 80, 'Ok',wx.Point(20,280))

def OnSelect(self,event):
radio_select = event.GetEventObject()
if radio_select.GetLabel() == 'Title1':
print 'Title1 selected'
else:
print 'Title2 selected'

I want to change this code. So when radio button Title1 is clicked
and then the ok button is clicked, then it should print 'Title1
selected' and sameway when Title2 is clicked and then ok button is
clicked, then it should print 'Title2 Selected'

Use a wx.EVT_BUTTON on your self.ok object so that it calls a method
called, say, OnButton. On the OnButton method, check the value of the
self.rb1 object via its GetValue() method. If it's True, rb1 is
checked; if it's False, then rb2 is checked.

-- tacao

No bits were harmed during the making of this e-mail.

Hi Prasoonadevi,

Create a new method:
    def GetLastSelection(self):
        return(self.LastSelection)

Add code to OnSelect to to save the current selection into self.LastSelection.

When the OK button is pressed, call the GetLastSelection() method to return
the last selection.

Thursday, June 7, 2007, 10:01:20 AM, you wrote:

···

Hi,

Hi, I am new to python and also new to wxpython. I have a simple
radiobutton problem.The following is my sample code.

self.rb1 = wx.RadioButton(self.mainpa,40,"Title1",wx.Point(20,60))
self.Bind(wx.EVT_RADIOBUTTON,self.OnSelect,id =40)

self.rb2 = wx.RadioButton(self.mainpa,50,"Title2",wx.Point(20,80))
self.Bind(wx.EVT_RADIOBUTTON,self.OnSelect,id =50)

self.ok = wx.Button(self.mainpa, 80, 'Ok',wx.Point(20,280))

def OnSelect(self,event):
radio_select = event.GetEventObject()
if radio_select.GetLabel() == 'Title1':
print 'Title1 selected'
else:
print 'Title2 selected'

I want to change this code. So when radio button Title1 is clicked and
then the ok button is clicked, then it should print 'Title1 selected'
and sameway when Title2 is clicked and then ok button is clicked, then
it should print 'Title2 Selected'

Any help please !!
Thanks
Prasoona

Thippana, Prasoonadevi <pthippan <at> mc.com> writes:

Hmmm...someone with the user name prasoona asked the exact same
question on a forum 7 days ago where it was answered.

I suspect the poster wants someone to write the exact code for them.

Actually,I didn't check the forum on june 5th the day you have replied.
Thanks for the Reply.
I posted my questions in both the forums on same day. But Instead of
sending it to wxpython-users list, I send it to wxpython-subscribe
list. So thatswhy I posted again.
Sorry for the confusion

···

-----Original Message-----
From: news [mailto:news@sea.gmane.org] On Behalf Of 7stud
Sent: Friday, June 08, 2007 5:10 AM
To: wxpython-users@lists.wxwidgets.org
Subject: [wxPython-users] Re: RadioButton Problem

Thippana, Prasoonadevi <pthippan <at> mc.com> writes:

Hmmm...someone with the user name prasoona asked the exact same question
on a forum 7 days ago where it was answered.

I suspect the poster wants someone to write the exact code for them.

---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwidgets.org
For additional commands, e-mail: wxPython-users-help@lists.wxwidgets.org