# A "magic" *nix incantation gets put here for *nix platforms in the very first line of the main app.

# Put all imports at the top of the file unless you have a darn good reason not to.
#
# Best to put the standard package import lines first so as to stay organized.
import sys
import wx

# Put all your special hand-crafted imports next
#import gettext     # un-comment this line

#------------------------------------------------------------------------------

FOR_REAL = False       # Set to True when you want to run this app for real

#------------------------------------------------------------------------------

# Class and Def names are best spelled starting with a capitalized letter
#   so they are easily differentiated from variable names.
#
        
class StTrainingSession_Frame( wx.Frame ) :
    
    # [ self ] refers the the Python object created when instantiating 
    #   an object from the this class template definition.

    def __init__( self ) :    # Using [ *args, **kwds ] syntax is a non-informative shortcut
        
        #myFrameStyle  = wx.DEFAULT_FRAME_STYLE     # don't bother defining unless non-standard
        wx.Frame.__init__( self, parent=None, id=-1, title='My App Title' )
        
        self.SetBackgroundColour( (200, 200, 250) )              # a greenish tinge
        
        # The first control in a wx.Frame gets auto-expanded to fill the Frame
        #   whether you want it to or not. So just create a dummy on.
        #   When you create subsequent children controls to the Frame you 
        #   will have the ability to size them.
        dummyFrame_panel = wx.Panel( self ).Hide()
        
        #----
        
        container_text = wx.StaticText( self, -1, 'StTrainingSession_Frame', pos=(0, 0) )
        
        
        # Do everything you want to do in this application:
        
        # Instantiate your panel. The panel's parent,[ self ], this Frame.
        self.trainingSession_panel = StTrainingSession_Panel( self, 
                panelSize=(300, 300), panelPosn=(50, 50) )
        
        # Do whatever with your panel:
        # ...
        
        
        
        
    #end __init__
    
    #------------------------
    
    # !!! [ new ] is a built-in Python function !!!  Don't use in any other way !!!
    #
    def NewTrainingSession( 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 )
        
        #return ???     # ? necessary ?

    #end NewTrainingSession def
        
#end MainFrame class

#------------------------------------------------------------------------------

class StTrainingSession_Panel( wx.Panel ) :
    """ This panel template definition can be instantiated within ANY type
    of container control like a wx.Window, wx.SplitterWindow, wx.StaticBox, 
    wx.PopupWindow, a wx.Grid element, wx.Notebook, etc., etc., etc., as well as
    another wx.Panel !
    """
    
    def __init__( self, panelParent, panelPosn=(0, 0), panelSize=(200, 200) ) :
        
        wx.Panel.__init__( self, parent=panelParent, id=-1, 
                           pos=panelPosn, size=panelSize )
                           
        self.SetBackgroundColour( (200, 250, 200) )              # blue tinged
        
        #----
        
        container_text = wx.StaticText( self, -1, 'StTrainingSession_Panel', pos=(0, 0) )
        
        if FOR_REAL :
        
            # replace with the appropriate catalog name
            gettext.install( "testSessionAdd" ) 

            #wx.InitAllImageHandlers()       # archaic wx call that's not needed any more

            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
            
        #end if
        
    #end __init__ def
    
#end StTrainingSession_Panel class

#==============================================================================

if __name__ == "__main__" :
    
    # wx.App is archaic. 
    # There is no longer a good reason to have an OnInit definition required by wx.App.
    myApp = wx.PySimpleApp( redirect=False )    # send all text output to a command shell
    
    myFrame = StTrainingSession_Frame().Show()
    
    myApp.MainLoop() 
    
