I think I have the terminology wrong ... Please correct me where I've
stuffed it up.
I have a class (edited to save space, but you get the idea from it) :
class stTrainingSession(wx.Frame):
def __init__(self, *args, **kwds):
kwds["style"] = wx.DEFAULT_FRAME_STYLE
wx.Frame.__init__(self, *args, **kwds)
def new(self):
coaches = stDataClasses.Coaches.getAll()
venues = stDataClasses.Venues.getAll()
squads = stDataClasses.Squads.getAll()
#self.date = wx.calendar.CalendarCtrl(self, -1)
#panel.date = wx.DatePickerCtrl(panel, -1)
self.date = wx.DatePickerCtrl(self, -1)
.
.
.
def __set_properties(self):
self.SetTitle(_("SessionCreator"))
def __do_layout(self):
sizer_1 = wx.BoxSizer(wx.VERTICAL)
sizer_1.Add(self.date, 0, 0, 0)
sizer_1.Add(self.startTime, 0, 0, 0)
.
.
self.SetSizer(sizer_1)
sizer_1.Fit(self)
self.Layout()
blah blah ...
I call it like this :
class MyApp(wx.App):
def OnInit(self):
wx.InitAllImageHandlers()
SessionCreator = stTrainingSession(None, -1, "")
SessionEditor = stTrainingSession(None, -1, "")
SessionCreator.new()
self.SetTopWindow(SessionCreator)
SessionCreator.Show()
trainingSession = stDataClasses.TrainingSessions.FromId(3)
#trainingSession.edit(SessionCreator,trainingSession)
#SessionEditor.edit(trainingSession)
print trainingSession
return 1
# end of class MyApp
if __name__ == "__main__":
import gettext
gettext.install("testSessionAdd") # replace with the appropriate
catalog name
testSessionAdd = MyApp(0)
testSessionAdd.MainLoop()
That's pretty ugly, I know .. (bear with me, I'm new at Python/
wxPython and SQLAlchemy and the learning curve is being climbed!)
I want to be able to convert, if that's the write way to say it, the
trainingsession object, which is essentially a form and a submission
handler, into a panel so I can embed it in another application. Ie:
this object should end up as a panel within a parent/master
application (which will take care of all the menu bars and so on).
Can anyone here suggest how I should change the class so I can call it
a panel and then use that panel in a parent frame?
I get lost in traceback hell when I start creating a wx.Panel in the
new() method and trying to set/read any variables called after that
panel, any hints or pointers to some handy doco much appreciated!