# Lumen
#
# A basic light level calculation program
#
# Created as part of a tutorial for assisting Engineers
# to learn programming with Python
#
# Copyright (c) 2006 to Ted Bell edward at edwardbellconsulting dot co dot uk
# Distributed free and without warranty of any kind
# 

import wx # This allows us to use frames in windows

e = 1 # constants set up for testing purposes only
l = 1 # I may need to start with some default values
w = 1
a = l*w
f = 1
uf = 0.85 # amend this to user input at a later stage.
n = (e*a)/(f*uf)

class MyMenu(wx.Frame): # creat the frame
    def __init__(self, parent, id, title):
        wx.Frame.__init__(self, parent, id, title='Lumen', pos=(350,200), size=wx.Size(450, 150))
        self.SetIcon(wx.Icon('bike.ico', wx.BITMAP_TYPE_ICO)) # adding a distinctive icon is optional
        menubar = wx.MenuBar() # add the menu bar
        file = wx.Menu()
        edit = wx.Menu()
        help = wx.Menu()
        file.Append(101, '&Open', 'Open a new document ') # add standard menu items
        file.Append(102, '&Save', 'Save the document ')
        file.AppendSeparator()
        quit = wx.MenuItem(file, 105, '&Quit\tCtrl+Q', 'Quit the application')
        file.AppendItem(quit)
        self.Bind(wx.EVT_MENU, self.OnQuit, id=105 ) # provide an exit
        menubar.Append(file, '&File')
        menubar.Append(edit, '&Edit')
        menubar.Append(help, '&Help')
        self.SetMenuBar(menubar)
        sizer = wx.BoxSizer(wx.VERTICAL) # set up a sizer to size the window components
       
        gs = wx.GridSizer(4, 4, 20, 5) # creat a form
        gs.AddMany([(wx.StaticText(self, -1, 'Length'), 1, wx.TE_CENTRE),
                    (wx.TextCtrl(self, l), 1, wx.EXPAND), # I need to collect the input from these fields
                    (wx.StaticText(self, -1, 'Width'), 1, wx.TE_CENTRE),
                    (wx.TextCtrl(self, w), 1, wx.EXPAND),
                    (wx.StaticText(self, -1, 'Required Level in Lux'), 1, wx.EXPAND),
                    (wx.TextCtrl(self, e), 2, wx.EXPAND),
                    (wx.StaticText(self, -1, 'Bare Lamp Lumens'), 1, wx.EXPAND),
                    (wx.TextCtrl(self, f), 2, wx.EXPAND),
                    (wx.Button(self, -1, 'Calculate'), 1, wx.EXPAND),
                    (wx.TextCtrl(self, n), 1, wx.TE_LEFT) ]) # I really need to display text here only
                    
        sizer.Add(gs, 1, 1, wx.EXPAND)
        self.SetSizer(sizer)
        self.Centre()
        
    def OnQuit(self, event):
        self.Close()
    
class MyApp(wx.App):
    def OnInit(self):
        frame = MyMenu(None, -1, 'lumen.py' )
        frame.Show(True)
        return True
    
app = MyApp(0)
app.MainLoop()

# Begin by estimating the number of fittings required.



print round(n)


# Now calculate the actual light level.

# N = input("Enter actual number of luminaires to be used ")
    # we can use capital n here as Python treats n and N as two values.
# llf = input("Enter light loss factor ")
    # we can revisit this at a later stage and break it down into parts.
# E = (N*f*uf*llf)/a
    # Again we can use capital E here to distinguish it.
# print E

# if __name__ == '__main__':
#     main()
