Various changes to reflect current CVS.

Added a separate wxRadioButton demo.
Various tweaks.


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_4_BRANCH@17545 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robin Dunn
2002-10-16 22:51:31 +00:00
parent a5b317c973
commit d73361fed5
18 changed files with 338 additions and 49 deletions

View File

@@ -25,19 +25,8 @@ import images
_treeList = [
# new stuff
('New since last release', [
'RowColSizer',
'Unicode',
'wxFileHistory',
'wxGenericDirCtrl',
'wxImageFromStream',
'wxArtProvider',
'ScrolledPanel',
'wxMenu',
'wxIEHtmlWin',
'wxKeyEvents',
'wxWizard',
'wxXmlResourceHandler',
'wxTimeCtrl',
'wxRadioButton',
]),
# managed windows == things with a caption you can close
@@ -89,6 +78,7 @@ _treeList = [
'wxNotebook',
'wxPopupWindow',
'wxRadioBox',
'wxRadioButton',
'wxSashWindow',
'wxSlider',
'wxScrolledWindow',

View File

@@ -3,10 +3,13 @@ from wxPython.wx import *
#---------------------------------------------------------------------------
RBOX1 = wxNewId()
RBOX2 = wxNewId()
RBUT1 = wxNewId()
RBUT2 = wxNewId()
RBUT3 = wxNewId()
RBUT4 = wxNewId()
RBOX1 = wxNewId()
RBOX2 = wxNewId()
class TestRadioButtons(wxPanel):
def __init__(self, parent, log):
@@ -33,15 +36,6 @@ class TestRadioButtons(wxPanel):
rb.SetToolTip(wxToolTip("This box has no label"))
sizer.Add(rb, 0, wxLEFT|wxRIGHT|wxBOTTOM, 20)
sizer.Add(wxStaticText(self, -1, "These are plain wxRadioButtons"),
0, wxLEFT|wxRIGHT, 20)
sizer.Add(wxRadioButton(self, RBUT1, "wxRadioButton 1"),
0, wxLEFT|wxRIGHT, 20)
sizer.Add(wxRadioButton(self, RBUT2, "wxRadioButton 2"),
0, wxLEFT|wxRIGHT, 20)
EVT_RADIOBUTTON(self, RBUT1, self.EvtRadioButton)
EVT_RADIOBUTTON(self, RBUT2, self.EvtRadioButton)
self.SetSizer(sizer)
@@ -49,7 +43,7 @@ class TestRadioButtons(wxPanel):
self.log.WriteText('EvtRadioBox: %d\n' % event.GetInt())
def EvtRadioButton(self, event):
self.log.write('EvtRadioButton:%d\n' % event.GetInt())
self.log.write('EvtRadioButton:%d\n' % event.GetId())
#---------------------------------------------------------------------------
@@ -57,21 +51,19 @@ def runTest(frame, nb, log):
win = TestRadioButtons(nb, log)
return win
#---------------------------------------------------------------------------
overview = """\
A radio box item is used to select one of number of mutually exclusive choices. It is displayed as a vertical column or horizontal row of labelled buttons.
A radio box item is used to select one of number of mutually exclusive
choices. It is displayed as a vertical column or horizontal row of
labelled buttons.
"""
if __name__ == '__main__':
import sys,os
import run
run.main(['', os.path.basename(sys.argv[0])])

View File

@@ -0,0 +1,118 @@
from wxPython.wx import *
#----------------------------------------------------------------------
class TestPanel( wxPanel ):
def __init__( self, parent, log ):
wxPanel.__init__( self, parent, -1 )
self.log = log
panel = wxPanel( self, -1 )
# 1st group of controls:
self.group1_ctrls = []
radio1 = wxRadioButton( panel, -1, "Radio1", style = wxRB_GROUP )
text1 = wxTextCtrl( panel, -1, "" )
radio2 = wxRadioButton( panel, -1, "Radio2" )
text2 = wxTextCtrl( panel, -1, "" )
radio3 = wxRadioButton( panel, -1, "Radio3" )
text3 = wxTextCtrl( panel, -1, "" )
self.group1_ctrls.append((radio1, text1))
self.group1_ctrls.append((radio2, text2))
self.group1_ctrls.append((radio3, text3))
# 2nd group of controls:
self.group2_ctrls = []
radio4 = wxRadioButton( panel, -1, "Radio1", style = wxRB_GROUP )
text4 = wxTextCtrl( panel, -1, "" )
radio5 = wxRadioButton( panel, -1, "Radio2" )
text5 = wxTextCtrl( panel, -1, "" )
radio6 = wxRadioButton( panel, -1, "Radio3" )
text6 = wxTextCtrl( panel, -1, "" )
self.group2_ctrls.append((radio4, text4))
self.group2_ctrls.append((radio5, text5))
self.group2_ctrls.append((radio6, text6))
# Layout controls on panel:
vs = wxBoxSizer( wxVERTICAL )
box1_title = wxStaticBox( panel, -1, "Group 1" )
box1 = wxStaticBoxSizer( box1_title, wxVERTICAL )
grid1 = wxFlexGridSizer( 0, 2, 0, 0 )
for radio, text in self.group1_ctrls:
grid1.AddWindow( radio, 0, wxALIGN_CENTRE|wxLEFT|wxRIGHT|wxTOP, 5 )
grid1.AddWindow( text, 0, wxALIGN_CENTRE|wxLEFT|wxRIGHT|wxTOP, 5 )
box1.AddSizer( grid1, 0, wxALIGN_CENTRE|wxALL, 5 )
vs.AddSizer( box1, 0, wxALIGN_CENTRE|wxALL, 5 )
box2_title = wxStaticBox( panel, -1, "Group 2" )
box2 = wxStaticBoxSizer( box2_title, wxVERTICAL )
grid2 = wxFlexGridSizer( 0, 2, 0, 0 )
for radio, text in self.group2_ctrls:
grid2.AddWindow( radio, 0, wxALIGN_CENTRE|wxLEFT|wxRIGHT|wxTOP, 5 )
grid2.AddWindow( text, 0, wxALIGN_CENTRE|wxLEFT|wxRIGHT|wxTOP, 5 )
box2.AddSizer( grid2, 0, wxALIGN_CENTRE|wxALL, 5 )
vs.AddSizer( box2, 0, wxALIGN_CENTRE|wxALL, 5 )
panel.SetSizer( vs )
vs.Fit( panel )
panel.Move( (50,50) )
self.panel = panel
# Setup event handling and initial state for controls:
for radio, text in self.group1_ctrls:
EVT_RADIOBUTTON( self, radio.GetId(), self.OnGroup1Select )
for radio, text in self.group2_ctrls:
EVT_RADIOBUTTON( self, radio.GetId(), self.OnGroup2Select )
for radio, text in self.group1_ctrls + self.group2_ctrls:
radio.SetValue(0)
text.Enable(FALSE)
def OnGroup1Select( self, event ):
radio_selected = event.GetEventObject()
self.log.write('Group1 %s selected\n' % radio_selected.GetLabel() )
for radio, text in self.group1_ctrls:
if radio is radio_selected:
text.Enable(TRUE)
else:
text.Enable(FALSE)
def OnGroup2Select( self, event ):
radio_selected = event.GetEventObject()
self.log.write('Group2 %s selected\n' % radio_selected.GetLabel() )
for radio, text in self.group2_ctrls:
if radio is radio_selected:
text.Enable(TRUE)
else:
text.Enable(FALSE)
#----------------------------------------------------------------------
def runTest( frame, nb, log ):
win = TestPanel( nb, log )
return win
#----------------------------------------------------------------------
overview = """
<html>
<P>
This demo shows how individual radio buttons can be used to build
more complicated selection mechanisms...
<P>
It uses 2 groups of wxRadioButtons, where the groups are defined by
instantiation. When a wxRadioButton is created with the <I>wxRB_GROUP</I>
style, all subsequent wxRadioButtons created without it are implicitly
added to that group by the framework.
"""
if __name__ == '__main__':
import sys,os
import run
run.main(['', os.path.basename(sys.argv[0])])