Hi everyone,
I have 2 panel-classes, with two controls. After a switch from one to the other,
the content is still on screen, but I want to destroy or override the content
after a switch. What is the solution?
Here the code:
from wxPython.wx import *
from wxPython.calendar import *
ID_KAL = 201
ID_TXT = 202
class MyFrame(wxFrame):
def __init__(self, parent, ID, title):
wxFrame.__init__(self, parent, ID, title,
wxDefaultPosition, wxSize(400,300))
menu= wxMenu()
menu.Append(ID_KAL, "&Calendar", "...")
menu.Append(ID_TXT, "&Text", "...")
menuBar = wxMenuBar()
menuBar.Append(menu, "&Switch")
self.SetMenuBar(menuBar)
EVT_MENU(self, ID_KAL , self.OnCal)
EVT_MENU(self, ID_TXT , self.OnText)
def OnCal(self,event):
self.pan=MyCal(self)
self.pan.Show(true)
def OnText(self,event):
self.pan=MyText(self)
self.pan.Show(true)
class MyCal(wxPanel):
def __init__(self,parent):
wxPanel.__init__(self,parent,wxSIMPLE_BORDER)
self.Refresh()
width, height = (400,300)
self.SetDimensions(0, 0,width,height)
self.SetBackgroundColour(wxNamedColour("MEDIUM ORCHID"))
self.cal = wxCalendarCtrl(self,-1, wxDateTime_Now(),wxPoint(100, 50),
wxSize(200, 180),
style = wxCAL_SHOW_HOLIDAYS | wxCAL_SUNDAY_FIRST)
self.cal.grid_color = 'BLUE'
class MyText(wxPanel):
def __init__(self,parent):
wxPanel.__init__(self,parent,wxSIMPLE_BORDER)
width, height = (400,300)
self.SetDimensions(0, 0,width,height)
self.SetBackgroundColour(wxNamedColour("Green"))
txt = wxStaticText(self, -1," ", wxPoint(5,5), wxSize(-1, 50))
txt.SetBackgroundColour(wxGREEN)
txt.SetForegroundColour(wxBLACK)
txt.SetLabel("This is a test\n")
class MyApp(wxApp):
def OnInit(self):
frame = MyFrame(NULL, -1, "Switch between 2 panels")
frame.Show(true)
self.SetTopWindow(frame)
return true
app = MyApp(0)
app.MainLoop()
···
_______________________________________________
wxPython-users mailing list
wxPython-users@lists.sourceforge.net
http://lists.sourceforge.net/mailman/listinfo/wxpython-users