Attachment 'Lumen_4.py'

Download

   1 # Lumen
   2 #
   3 # A basic light level calculation program
   4 #
   5 # Created as part of a tutorial for assisting Engineers
   6 # to learn programming with Python
   7 #
   8 # Copyright (c) 2006 to Ted Bell edward at edwardbellconsulting dot co dot uk
   9 # Distributed free and without warranty of any kind
  10 # 
  11 
  12 import wx # This allows us to use frames in windows
  13 
  14 e = 1 # constants set up for testing purposes only
  15 l = 1 # I may need to start with some default values
  16 w = 1
  17 a = l*w
  18 f = 1
  19 uf = 0.85 # amend this to user input at a later stage.
  20 n = (e*a)/(f*uf)
  21 
  22 class MyMenu(wx.Frame): # creat the frame
  23     def __init__(self, parent, id, title):
  24         wx.Frame.__init__(self, parent, id, title='Lumen', pos=(350,200), size=wx.Size(450, 150))
  25         self.SetIcon(wx.Icon('bike.ico', wx.BITMAP_TYPE_ICO)) # adding a distinctive icon is optional
  26         menubar = wx.MenuBar() # add the menu bar
  27         file = wx.Menu()
  28         edit = wx.Menu()
  29         help = wx.Menu()
  30         file.Append(101, '&Open', 'Open a new document ') # add standard menu items
  31         file.Append(102, '&Save', 'Save the document ')
  32         file.AppendSeparator()
  33         quit = wx.MenuItem(file, 105, '&Quit\tCtrl+Q', 'Quit the application')
  34         file.AppendItem(quit)
  35         self.Bind(wx.EVT_MENU, self.OnQuit, id=105 ) # provide an exit
  36         menubar.Append(file, '&File')
  37         menubar.Append(edit, '&Edit')
  38         menubar.Append(help, '&Help')
  39         self.SetMenuBar(menubar)
  40         sizer = wx.BoxSizer(wx.VERTICAL) # set up a sizer to size the window components
  41        
  42         gs = wx.GridSizer(4, 4, 20, 5) # creat a form
  43         gs.AddMany([(wx.StaticText(self, -1, 'Length'), 1, wx.TE_CENTRE),
  44                     (wx.TextCtrl(self, l), 1, wx.EXPAND), # I need to collect the input from these fields
  45                     (wx.StaticText(self, -1, 'Width'), 1, wx.TE_CENTRE),
  46                     (wx.TextCtrl(self, w), 1, wx.EXPAND),
  47                     (wx.StaticText(self, -1, 'Required Level in Lux'), 1, wx.EXPAND),
  48                     (wx.TextCtrl(self, e), 2, wx.EXPAND),
  49                     (wx.StaticText(self, -1, 'Bare Lamp Lumens'), 1, wx.EXPAND),
  50                     (wx.TextCtrl(self, f), 2, wx.EXPAND),
  51                     (wx.Button(self, -1, 'Calculate'), 1, wx.EXPAND),
  52                     (wx.TextCtrl(self, n), 1, wx.TE_LEFT) ]) # I really need to display text here only
  53                     
  54         sizer.Add(gs, 1, 1, wx.EXPAND)
  55         self.SetSizer(sizer)
  56         self.Centre()
  57         
  58     def OnQuit(self, event):
  59         self.Close()
  60     
  61 class MyApp(wx.App):
  62     def OnInit(self):
  63         frame = MyMenu(None, -1, 'lumen.py' )
  64         frame.Show(True)
  65         return True
  66     
  67 app = MyApp(0)
  68 app.MainLoop()
  69 
  70 # Begin by estimating the number of fittings required.
  71 
  72 
  73 
  74 print round(n)
  75 
  76 
  77 # Now calculate the actual light level.
  78 
  79 # N = input("Enter actual number of luminaires to be used ")
  80     # we can use capital n here as Python treats n and N as two values.
  81 # llf = input("Enter light loss factor ")
  82     # we can revisit this at a later stage and break it down into parts.
  83 # E = (N*f*uf*llf)/a
  84     # Again we can use capital E here to distinguish it.
  85 # print E
  86 
  87 # if __name__ == '__main__':
  88 #     main()

Attached Files

To refer to attachments on a page, use attachment:filename, as shown below in the list of files. Do NOT use the URL of the [get] link, since this is subject to change and can break easily.
  • [get | view] (2009-10-04 09:16:03, 0.1 KB) [[attachment:Lumen_1.py]]
  • [get | view] (2009-10-04 09:16:03, 0.1 KB) [[attachment:Lumen_1a.py]]
  • [get | view] (2009-10-04 09:16:03, 0.1 KB) [[attachment:Lumen_1b.py]]
  • [get | view] (2009-10-04 09:16:03, 0.2 KB) [[attachment:Lumen_2.py]]
  • [get | view] (2009-10-04 09:16:03, 1.0 KB) [[attachment:Lumen_3.py]]
  • [get | view] (2009-10-04 09:16:03, 3.2 KB) [[attachment:Lumen_4.py]]
  • [get | view] (2009-10-04 09:16:03, 3.6 KB) [[attachment:bike.ico]]
 All files | Selected Files: delete move to page copy to page

You are not allowed to attach a file to this page.

NOTE: To edit pages in this wiki you must be a member of the TrustedEditorsGroup.