By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
439,957 Members | 2,017 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 439,957 IT Pros & Developers. It's quick & easy.

wxpython question

P: 5
Hi,
I am new to python and also new to wxpython. I have a problem with radio button. I created 2 radiobutton and then a ok button. How can I write a code so that when I click a first radiobutton and then click a ok button, the message related to first radiobutton should open. Same way when I click the 2nd radiobutton and click ok button, a message related to 2nd radiobutton should open. Right now the message is just a print statement.

Please help!!

Thanks
May 23 '07 #1
Share this Question
Share on Google+
2 Replies


bartonc
Expert 5K+
P: 6,596
Hi,
I am new to python and also new to wxpython. I have a problem with radio button. I created 2 radiobutton and then a ok button. How can I write a code so that when I click a first radiobutton and then click a ok button, the message related to first radiobutton should open. Same way when I click the 2nd radiobutton and click ok button, a message related to 2nd radiobutton should open. Right now the message is just a print statement.

Please help!!

Thanks
We can help, but you'll need to post some code to show what you are working on.

On the right hand side of the page (while you are replying with a copy of your script in the clipboard), you'll find POSTING GUIDELINES which tell you how to use [code] tags so that we'll be able to see the structure of your code.

Thanks for joining.
May 24 '07 #2

P: 5
We can help, but you'll need to post some code to show what you are working on.

On the right hand side of the page (while you are replying with a copy of your script in the clipboard), you'll find POSTING GUIDELINES which tell you how to use [code] tags so that we'll be able to see the structure of your code.

Thanks for joining.
Thanks.The following is the code I am trying to implement.
Expand|Select|Wrap|Line Numbers
  1. import wx
  2. import os, sys
  3. import string
  4.  
  5. class MyFrame(wx.Frame):
  6.         def __init__(self, parent, id, title):
  7.             wx.Frame.__init__(self, parent,-1,title,wx.DefaultPosition,wx.Size(402,450))
  8.  
  9.             self.mainpa = wx.Panel(self,-1,wx.DefaultPosition, wx.DefaultSize)
  10.             self.stext1 = wx.StaticText(self.mainpa,-1,"Select Type",(20,10))
  11.  
  12.             self.rb1 = wx.RadioButton(self.mainpa,40,"Title1",wx.Point(20,60))
  13.             self.Bind(wx.EVT_RADIOBUTTON,self.OnSelect,id =40)
  14.  
  15.             self.rb2 = wx.RadioButton(self.mainpa,50,"Title2",wx.Point(20,80))
  16.             self.Bind(wx.EVT_RADIOBUTTON,self.OnSelect,id=50)
  17.  
  18.  
  19.             self.b1 =wx.Button(self.mainpa,30,'Ok',(300,340))
  20.             self.Bind(wx.EVT_BUTTON,self.OnSelect,id = 30)
  21.  
  22.        def OnSelect(self,event):
  23.             if (self.board.GetId()):
  24.                     print 'Title1 selected'
  25.             if(self.chassis.GetId()):
  26.                     print 'Title2 Selected'
I think my OnSelect function is not correct, thats where I need help. I want to select Title1 and click Ok button and the print statement must be 'Title1 Selected'. Samething for the 'Title2'

Thanks
Sumitha
May 24 '07 #3

Post your reply

Sign in to post your reply or Sign up for a free account.