Código XML:
Ver original<?xml version="1.0"?>
<!-- generated by wxGlade 0.6.4 on Wed Dec 19 11:36:00 2012 -->
<application path="/home/raz/glade/temp.py" name="" class="" option="0" language="python" top_window="frame_1" encoding="UTF-8" use_gettext="0" overwrite="0" use_new_namespace="1" for_version="2.8" is_template="0" indent_amount="4" indent_symbol="space" source_extension=".cpp" header_extension=".h">
<object class="MyFrame" name="frame_1" base="EditFrame">
<style>wxDEFAULT_FRAME_STYLE</style>
<title>frame_1</title>
<size>300, 300</size>
<object class="wxBoxSizer" name="sizer_1" base="EditBoxSizer">
<orient>wxVERTICAL</orient>
<object class="sizeritem">
<flag>wxEXPAND</flag>
<border>0</border>
<option>1</option>
<object class="wxPanel" name="panel_1" base="EditPanel">
<style>wxTAB_TRAVERSAL</style>
<object class="wxBoxSizer" name="sizer_2" base="EditBoxSizer">
<orient>wxVERTICAL</orient>
<object class="sizeritem">
<border>0</border>
<option>0</option>
<object class="wxTextCtrl" name="text_ctrl_1" base="EditTextCtrl">
</object>
</object>
</object>
</object>
</object>
<object class="sizeritem">
<flag>wxEXPAND</flag>
<border>0</border>
<option>1</option>
<object class="wxPanel" name="panel_2" base="EditPanel">
<style>wxTAB_TRAVERSAL</style>
<hidden>1</hidden>
<object class="wxBoxSizer" name="sizer_3" base="EditBoxSizer">
<orient>wxVERTICAL</orient>
<object class="sizeritem">
<border>0</border>
<option>0</option>
<object class="wxCheckBox" name="checkbox_1" base="EditCheckBox">
<label>checkbox_1</label>
</object>
</object>
</object>
</object>
</object>
<object class="sizeritem">
<border>0</border>
<option>0</option>
<object class="wxButton" name="button_1" base="EditButton">
<label>Switch</label>
<events>
<handler event="EVT_BUTTON">OnClick</handler>
</events>
</object>
</object>
</object>
</object>
</application>
Una vez generado el código pon este código dentro de OnClick
Código Python:
Ver originaldef OnClick(self, event): # wxGlade: MyFrame.<event_handler>
if self.panel_1.IsShown():
self.panel_1.Hide()
self.panel_2.Show()
else:
self.panel_1.Show()
self.panel_2.Hide()
self.Layout()
event.Skip()
Quedándote en total así:
Código Python:
Ver original#!/usr/bin/env python
# -*- coding: utf-8 -*-
# generated by wxGlade 0.6.4 on Wed Dec 19 11:21:44 2012
import wx
# begin wxGlade: extracode
# end wxGlade
class MyFrame(wx.Frame):
def __init__(self, *args, **kwds):
# begin wxGlade: MyFrame.__init__
kwds["style"] = wx.DEFAULT_FRAME_STYLE
wx.Frame.__init__(self, *args, **kwds)
self.panel_1 = wx.Panel(self, -1)
self.text_ctrl_1 = wx.TextCtrl(self.panel_1, -1, "")
self.panel_2 = wx.Panel(self, -1)
self.checkbox_1 = wx.CheckBox(self.panel_2, -1, "checkbox_1")
self.button_1 = wx.Button(self, -1, "Switch")
self.__set_properties()
self.__do_layout()
self.Bind(wx.EVT_BUTTON, self.OnClick, self.button_1)
# end wxGlade
def __set_properties(self):
# begin wxGlade: MyFrame.__set_properties
self.SetTitle("frame_1")
self.SetSize((300, 300))
self.panel_2.Hide()
# end wxGlade
def __do_layout(self):
# begin wxGlade: MyFrame.__do_layout
sizer_1 = wx.BoxSizer(wx.VERTICAL)
sizer_3 = wx.BoxSizer(wx.VERTICAL)
sizer_2 = wx.BoxSizer(wx.VERTICAL)
sizer_2.Add(self.text_ctrl_1, 0, 0, 0)
self.panel_1.SetSizer(sizer_2)
sizer_1.Add(self.panel_1, 1, wx.EXPAND, 0)
sizer_3.Add(self.checkbox_1, 0, 0, 0)
self.panel_2.SetSizer(sizer_3)
sizer_1.Add(self.panel_2, 1, wx.EXPAND, 0)
sizer_1.Add(self.button_1, 0, 0, 0)
self.SetSizer(sizer_1)
self.Layout()
# end wxGlade
def OnClick(self, event): # wxGlade: MyFrame.<event_handler>
if self.panel_1.IsShown():
self.panel_1.Hide()
self.panel_2.Show()
else:
self.panel_1.Show()
self.panel_2.Hide()
self.Layout()
event.Skip()
# end of class MyFrame
if __name__ == "__main__":
app = wx.PySimpleApp(0)
wx.InitAllImageHandlers()
frame_1 = MyFrame(None, -1, "")
app.SetTopWindow(frame_1)
frame_1.Show()
app.MainLoop()