免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 2068 | 回复: 2
打印 上一主题 下一主题

关于python图形用户界面开发的问题,求助高手,拜托拜托!!! [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2014-09-23 12:56 |只看该作者 |倒序浏览
#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():
         menuLabel = eachMenuData[0]
         menuItems = eachMenuData[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:
              label=eachItem[0]
              subMenu=self.createMenu(eachItem[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()
               
               
               
        
        

论坛徽章:
0
2 [报告]
发表于 2014-09-23 12:59 |只看该作者
这是编译结果,我不会修改,想要求助大神帮忙一下,感激不尽!!!

未命名.JPG (53.37 KB, 下载次数: 13)

未命名.JPG

论坛徽章:
0
3 [报告]
发表于 2014-09-25 19:20 |只看该作者
回复 1# florence114


    用PyQt4 现在用wx的很少了
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP