Ejemplo n.º 1
0
    def createMenuItem(self, text, handler=None, keys=None):
        menuItem = ToolStripMenuItem()
        menuItem.Text = text

        if keys:
            menuItem.ShortcutKeys = keys
        if handler:
            menuItem.Click += handler
        return menuItem
Ejemplo n.º 2
0
 def createMenuItem(self, name, text, clickHandler=None, keys=None):
     menuItem = ToolStripMenuItem(
         Name = name,
         Text = text
     )
     if keys:
         menuItem.ShortcutKeys = keys
     if clickHandler:
         menuItem.Click += clickHandler
     return menuItem
    def __init__(self):
        self.Text = 'Simple Menu'
        self.Size = Size(250, 200)

        ms = MenuStrip()
        ms.Parent = self
        
        filem = ToolStripMenuItem("&File")         
        exit = ToolStripMenuItem("&Exit", None,
            self.OnExit)  
        exit.ShortcutKeys = Keys.Control | Keys.X
        filem.DropDownItems.Add(exit)

        ms.Items.Add(filem)
        self.MainMenuStrip = ms
        
        self.CenterToScreen()