def initialiseMenus(self): menuStrip = MenuStrip() menuStrip.Dock = DockStyle.Top fileMenu = self.createMenuItem('&File') openKeys = Keys.Control | Keys.O openMenuItem = self.createMenuItem( '&Open...', lambda sender, event: self.openCommand.execute(), keys=openKeys ) saveKeys = Keys.Control | Keys.S saveMenuItem = self.createMenuItem( '&Save...', lambda sender, event: self.saveCommand.execute(), keys=saveKeys ) saveAsKeys = Keys.Control | Keys.Shift | Keys.S saveAsMenuItem = self.createMenuItem( 'S&ave As...', lambda sender, event: self.saveAsCommand.execute(), keys=saveAsKeys ) fileMenu.DropDownItems.Add(openMenuItem) fileMenu.DropDownItems.Add(saveMenuItem) fileMenu.DropDownItems.Add(saveAsMenuItem) menuStrip.Items.Add(fileMenu) self.Controls.Add(menuStrip)
def initialiseMenus(self): menuStrip = MenuStrip() menuStrip.Dock = DockStyle.Top fileMenu = self.createMenuItem('&File') openKeys = Keys.Control | Keys.O openMenuItem = self.createMenuItem( '&Open...', lambda sender, event: self.openCommand.execute(), keys=openKeys ) newKeys = Keys.Control | Keys.N newMenuItem = self.createMenuItem( '&New', lambda sender, event: self.newDocumentCommand.execute(), keys=newKeys ) saveKeys = Keys.Control | Keys.S saveMenuItem = self.createMenuItem( '&Save...', lambda sender, event: self.saveCommand.execute(), keys=saveKeys ) saveAsKeys = Keys.Control | Keys.Shift | Keys.S saveAsMenuItem = self.createMenuItem( 'S&ave As...', lambda sender, event: self.saveAsCommand.execute(), keys=saveAsKeys ) fileMenu.DropDownItems.Add(newMenuItem) fileMenu.DropDownItems.Add(openMenuItem) fileMenu.DropDownItems.Add(saveMenuItem) fileMenu.DropDownItems.Add(saveAsMenuItem) editMenu = self.createMenuItem('&Edit') newPageItem = self.createMenuItem( '&New Page...', lambda sender, event: self.newPageCommand.execute() ) renamePageItem = self.createMenuItem( '&Rename Page...', lambda sender, event: self.renameCommand.execute() ) removePageItem = self.createMenuItem( 'Remove &Page...', lambda sender, event: self.removeCommand.execute() ) editMenu.DropDownItems.Add(newPageItem) editMenu.DropDownItems.Add(renamePageItem) editMenu.DropDownItems.Add(removePageItem) menuStrip.Items.Add(fileMenu) menuStrip.Items.Add(editMenu) self.Controls.Add(menuStrip)