免费注册 查看新帖 |

Chinaunix

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

Frames and Dialogs → Aui_MDI [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2007-04-19 19:17 |只看该作者 |倒序浏览
# Demo: wxAuiMDIParentFrame.py
# Desp: In wxPython, wx.aui package supplies Advanced User Interface.
#       It can lead to Simple but Rich UI.
import wx
import wx.aui
class MDIParentFrame(wx.aui.AuiMDIParentFrame):            
def __init__(self, parent):
  wx.aui.AuiMDIParentFrame.__init__(self, parent, -1,
            title="Test AuiMDIParentFrame",
            size=(640, 480),
            style=wx.DEFAULT_FRAME_STYLE)
         
  # Total count of child frames that have been newed
  self.CountOfChildFrame = 0
  MenuBar = self.MakeMenuBar()
  self.SetMenuBar(MenuBar)
  self.CreateStatusBar()
  
def MakeMenuBar(self):
  MenuBar = wx.MenuBar()
  
  FileMenu = wx.Menu()
  MenuItem = FileMenu.Append(-1, "New Child Window\tCtrl-N")
  self.Bind(wx.EVT_MENU, self.OnNewChildWindow, MenuItem)
  MenuItem = FileMenu.Append(-1, "Close Parent")
  self.Bind(wx.EVT_MENU, self.OnClose, MenuItem)
  
  MenuBar.Append(FileMenu, "&File")
  
  return MenuBar
  
def OnNewChildWindow(self, event):
  self.CountOfChildFrame += 1
  ChildFrame = MDIChildFrame(self, self.CountOfChildFrame)
  ChildFrame.Show(True)
  
def OnClose(self, event):
  self.Close(True)
  
  
class MDIChildFrame(wx.aui.AuiMDIChildFrame):
def __init__(self, parent, index):
  wx.aui.AuiMDIChildFrame.__init__(self, parent, -1,
           title="Child %d" % index)
   
  # Childs can custom their own menubar      
  MenuBar = parent.MakeMenuBar()
  ChildMenu = wx.Menu()
  MenuItem = ChildMenu.Append(-1, "This is child %d's menu" % index)
  MenuBar.Append(ChildMenu, "&Child")
  self.SetMenuBar(MenuBar)
  
  Panel = wx.Panel(self)
  wx.StaticText(Panel, -1, "This is child %d " % index, (10, 10))
  Panel.SetBackgroundColour("light blue")
  
  Sizer = wx.BoxSizer()
  Sizer.Add(Panel, 1, wx.EXPAND)
  self.SetSizer(Sizer)
  
  wx.CallAfter(self.Layout)
  
  
def TestMDIParentFrame():
TheApp = wx.PySimpleApp()
ParentFrame = MDIParentFrame(None)
ParentFrame.Show(True)
TheApp.MainLoop()
  
if __name__ == "__main__":
TestMDIParentFrame()

本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u1/35936/showart_281874.html
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

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

清除 Cookies - ChinaUnix - Archiver - WAP - TOP