#! /usr/bin/env python
# -*- coding: utf-8 -*-

import wx

import home

class MyApp(wx.App):

    @home.lang_etc # Any app running SOFA must use this decorator on OnInit
    def OnInit(self):
        self.frame = MyFrame(None, title="Menu which can run SOFA")
        self.SetTopWindow(self.frame)
        self.frame.Show()


class MyFrame(wx.Frame):

    def __init__(self, parent, id=wx.ID_ANY, title="", pos=wx.DefaultPosition, 
            size=(300,80), style=wx.DEFAULT_FRAME_STYLE, name="MyFrame"):
        super(MyFrame, self).__init__(parent, id, title, pos, size, style, name)
        self.panel = wx.Panel(self)
        szr = wx.FlexGridSizer(rows=1, cols=2, hgap=20, vgap=0)
        szr.AddGrowableCol(1,2) # idx, propn
        btn_open_sofa = wx.Button(self.panel, -1, "Open SOFA")
        btn_open_sofa.Bind(wx.EVT_BUTTON, self.on_btn_open_sofa)
        btn_exit = wx.Button(self.panel, -1, "Exit")
        btn_exit.Bind(wx.EVT_BUTTON, self.on_btn_exit)
        szr.Add(btn_open_sofa, 0, wx.ALL, 20)
        szr.Add(btn_exit, 0, wx.ALL|wx.ALIGN_RIGHT, 20)
        self.panel.SetSizer(szr)
        self.Layout()
                
    def on_btn_open_sofa(self, event):
        frame = home.StartFrame()
        frame.CentreOnScreen(wx.VERTICAL)
        frame.Show()
        
    def on_btn_exit(self, event):
        self.Destroy()


if __name__ == "__main__":
    app = MyApp(False)
    app.MainLoop()
