468,287 Members | 2,010 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,287 developers. It's quick & easy.

wxpython question

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
2 1332
bartonc
6,596 Expert 4TB
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
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.

Similar topics

3 posts views Thread by Equis Uno | last post: by
8 posts views Thread by Erik Johnson | last post: by
1 post views Thread by Steven W. Orr | last post: by
reply views Thread by gooli | last post: by
reply views Thread by NPC403 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.