Demo updates for new wx namespace, from Jeff Grimmett
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@24723 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -1,57 +1,67 @@
|
||||
from wxPython.wx import *
|
||||
# 11/21/2003 - Jeff Grimmett (grimmtooth@softhome.net)
|
||||
#
|
||||
# o Updated for wx namespace
|
||||
#
|
||||
|
||||
import wx
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
class TestPanel( wxPanel ):
|
||||
class TestPanel( wx.Panel ):
|
||||
def __init__( self, parent, log ):
|
||||
|
||||
wxPanel.__init__( self, parent, -1 )
|
||||
wx.Panel.__init__( self, parent, -1 )
|
||||
self.log = log
|
||||
panel = wxPanel( self, -1 )
|
||||
panel = wx.Panel( 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, "" )
|
||||
radio1 = wx.RadioButton( panel, -1, " Radio1 ", style = wx.RB_GROUP )
|
||||
text1 = wx.TextCtrl( panel, -1, "" )
|
||||
radio2 = wx.RadioButton( panel, -1, " Radio2 " )
|
||||
text2 = wx.TextCtrl( panel, -1, "" )
|
||||
radio3 = wx.RadioButton( panel, -1, " Radio3 " )
|
||||
text3 = wx.TextCtrl( 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, "" )
|
||||
radio4 = wx.RadioButton( panel, -1, " Radio1 ", style = wx.RB_GROUP )
|
||||
text4 = wx.TextCtrl( panel, -1, "" )
|
||||
radio5 = wx.RadioButton( panel, -1, " Radio2 " )
|
||||
text5 = wx.TextCtrl( panel, -1, "" )
|
||||
radio6 = wx.RadioButton( panel, -1, " Radio3 " )
|
||||
text6 = wx.TextCtrl( 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 )
|
||||
vs = wx.BoxSizer( wx.VERTICAL )
|
||||
|
||||
box1_title = wx.StaticBox( panel, -1, "Group 1" )
|
||||
box1 = wx.StaticBoxSizer( box1_title, wx.VERTICAL )
|
||||
grid1 = wx.FlexGridSizer( 0, 2, 0, 0 )
|
||||
|
||||
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 )
|
||||
grid1.AddWindow( radio, 0, wx.ALIGN_CENTRE|wx.LEFT|wx.RIGHT|wx.TOP, 5 )
|
||||
grid1.AddWindow( text, 0, wx.ALIGN_CENTRE|wx.LEFT|wx.RIGHT|wx.TOP, 5 )
|
||||
|
||||
box1.AddSizer( grid1, 0, wx.ALIGN_CENTRE|wx.ALL, 5 )
|
||||
vs.AddSizer( box1, 0, wx.ALIGN_CENTRE|wx.ALL, 5 )
|
||||
|
||||
box2_title = wx.StaticBox( panel, -1, "Group 2" )
|
||||
box2 = wx.StaticBoxSizer( box2_title, wx.VERTICAL )
|
||||
grid2 = wx.FlexGridSizer( 0, 2, 0, 0 )
|
||||
|
||||
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 )
|
||||
grid2.AddWindow( radio, 0, wx.ALIGN_CENTRE|wx.LEFT|wx.RIGHT|wx.TOP, 5 )
|
||||
grid2.AddWindow( text, 0, wx.ALIGN_CENTRE|wx.LEFT|wx.RIGHT|wx.TOP, 5 )
|
||||
|
||||
box2.AddSizer( grid2, 0, wx.ALIGN_CENTRE|wx.ALL, 5 )
|
||||
vs.AddSizer( box2, 0, wx.ALIGN_CENTRE|wx.ALL, 5 )
|
||||
|
||||
panel.SetSizer( vs )
|
||||
vs.Fit( panel )
|
||||
@@ -60,19 +70,19 @@ class TestPanel( wxPanel ):
|
||||
|
||||
# Setup event handling and initial state for controls:
|
||||
for radio, text in self.group1_ctrls:
|
||||
EVT_RADIOBUTTON( self, radio.GetId(), self.OnGroup1Select )
|
||||
self.Bind(wx.EVT_RADIOBUTTON, self.OnGroup1Select, radio )
|
||||
|
||||
for radio, text in self.group2_ctrls:
|
||||
EVT_RADIOBUTTON( self, radio.GetId(), self.OnGroup2Select )
|
||||
self.Bind(wx.EVT_RADIOBUTTON, self.OnGroup2Select, radio )
|
||||
|
||||
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)
|
||||
@@ -82,6 +92,7 @@ class TestPanel( wxPanel ):
|
||||
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)
|
||||
|
Reference in New Issue
Block a user