#coding:utf-8
import wx
class MainWindow(wx.Frame):
def __init__(self,parent):
wx.Frame.__init__(self, parent, -1, size = (640, 480), style=wx.DEFAULT_FRAME_STYLE|wx.MAXIMIZE)
self.createMenuBar()
def menuData(self):
return(("&File",
("&New","Create a new design",self.On_New),
("&Open...","Open an existing design",self.On_Open),
("&Close","Close the design",self.On_Close),
("&Save","Save the design",self.On_Save),
("&Save As...","Save the design under a new name",self.On_Save_As),
("","",""),
("&Materials",
("&Open Material","Open an existing material",self.On_Open_Material),
("&New Material","Create a new material",self.On_New_Material)),
("","",""),
("&Exit", "Exit the application",self.On_Exit)),
("&Design",
("&Properties","Show and modify the filter properties",self.On_Properties),
("","",""),
("&Stack", "Design the selected filter using a stack formula",self.On_Stack),
("","",""),
("&Analyze",
("&Plot","plot the optical properties",self.On_Analyze_Plot),
("&Table","show the optical properties in table",self.On_Analyze_Table))),
("&Optimize",
("&Target",
("&Add Reflection Target", "Add a reflection target to the project",self.On_Add_Target),
("&Add Transmission Target", "Add a transmission target to the project",self.On_Add_Target),
("&Add Reflection Spectrum Target", "Add a reflection spectrum target to the project",self.On_Add_Target),
("&Add Transmission Spectrum Target", "Add a transmission spectrum target to the project",self.On_Add_Target),
("&Add Reflection Color Target", "Add a reflection color target to the project",self.On_Add_Target),
("&Add Transmission Color Target", "Add a transmission color target to the project",self.On_Add_Target)),
("&Refine", "Refine the selected filter",self.On_Optimize),
("&Needles", "Synthesize the selected filter with the needle method")),
("&Color",
("Color &Parameters", "Show and modify the Color properties",self.On_Color_Properties),
("Plot &From", "",self.On_Plot_From)))
def createMenuBar(self):
menuBar = wx.MenuBar()
for eachMenuData in self.menuData():
for i in range(0,4):
menuLabel = eachMenuData[i][0]
menuItems = eachMenuData[i][1]
menuBar.Append(self.createMenu(menuItems), menuLabel)
self.SetMenuBar(menuBar)
def createMenu(self,menuData):
menu = wx.Menu()
for eachItem in menuData:
if len(eachItem)==2:
for i in range(0,4):
label=eachItem[i][0]
subMenu=self.createMenu(eachItem[i][1])
menu.AppendMenu(wx.NewId(),label,subMenu)
else :
self.createMenuItem(menu,*eachItem)
return menu
def createMenuItem(self,menu,label,status,handler,kind=wx.ITEM_NORMAL):
if not label:
menu.AppendSeparator()
return
menuItem=menu.Append(-1,label,status,kind)
self.Bind(wx.EVT_MENU,handler,menuItem)
def On_New(self, event): pass
def On_New_Material(self, event): pass
def On_Open(self, event): pass
def On_Open_Material(self, event): pass
def On_Close(self, event): pass
def On_Save(self, event): pass
def On_Save_As(self, event): pass
def On_Exit(self, event): pass
def On_Properties(self, event): pass
def On_Stack(self,event):pass
def On_Analyze_Plot(self, event): pass
def On_Analyze_Table(self, event): pass
def On_Add_Target(self, event): pass
def On_Optimize(self, event): pass
def On_Color_Properties(self, event): pass
def On_Plot_From(self, event): pass
if __name__=='__main__':
app = wx.PySimpleApp()
frame = MainWindow(None)
frame.Show(True)
app.MainLoop()