This function create a correct menu item object for the menu.
338497
def core__generate_menu_item key, values, module_name
      menu_item = {}
      menu_item[:key] = key
      menu_item[:title] = values[:title] ? core__get_menu_title_translation(values[:title], module_name) : 'Undefined'
      menu_item[:icon] = values[:icon] ? values[:icon] : 'check-circle'
      menu_item[:url] = values[:url] ? values[:url] : ''
      menu_item[:position] = values[:position] ? values[:position] : 999
      menu_item[:permission_min] = values[:permission_min] ? values[:permission_min] : 0
      menu_item[:permission_max] = values[:permission_max] ? values[:permission_max] : 999
      menu_item[:sub_items] = []

      if values[:sub_items]
        values[:sub_items].each do |key, value|
          menu_item[:sub_items].push(core__generate_menu_sub_item(key, value, module_name))
        end
      end

      return menu_item
    end
732478
public static function createMenuItem(array $item): MenuItemInterface
    {
        $menuItem = static::_getMenuItemObject($item);
        foreach ($item as $key => $value) {
            if ($key == 'children') {
                foreach ($value as $k => $v) {
                    $childItem = static::createMenuItem($v);
                    $menuItem->addMenuItem($childItem);
                }
            } elseif ($key == 'attributes') {
                foreach ($value as $k => $v) {
                    $menuItem->addAttribute($k, $v);
                }
            } elseif ($key == 'viewElement') {
                call_user_func_array([$menuItem, 'setViewElement'], $value);
            } else {
                $method = 'set' . ucfirst(Inflector::camelize($key));
                if (method_exists($menuItem, $method)) {
                    $menuItem->$method($value);
                }
            }
        }

        return $menuItem;
    }
620432
private void createMenuEntry(
        MenuItem parent,
        final CmsTreeNode<I_CmsContextMenuItem> node,
        CmsContextMenuTreeBuilder treeBuilder) {

        Command entryCommand = null;
        if (node.getChildren().size() == 0) {
            entryCommand = new Command() {

                private static final long serialVersionUID = 1L;

                public void menuSelected(MenuItem selectedItem) {

                    node.getData().executeAction(getDialogContext());
                }
            };
        }
        MenuItem entry = parent.addItem((node.getData().getTitle(A_CmsUI.get().getLocale())), entryCommand);
        for (CmsTreeNode<I_CmsContextMenuItem> child : node.getChildren()) {
            createMenuEntry(entry, child, treeBuilder);
        }
        if (treeBuilder.getVisibility(node.getData()).isInActive()) {
            entry.setEnabled(false);
        }
    }
852671
protected function createSubmenuMenu($menu): self
    {
        if (is_callable($menu)) {
            $transformer = $menu;
            $menu = $this->blueprint();
            $transformer($menu);
        }

        return $menu;
    }
366602
def _append(self, menu):
        ''''''
        menu.AppendCheckItem(self.id(), self.name, self.description)
        menu.Check(self.id(), self.checked)
147396
private void syncMenu() {
        if (bugInstance != null) {
            isBugItem.setEnabled(true);
            notBugItem.setEnabled(true);

            BugProperty isBugProperty = bugInstance.lookupProperty(BugProperty.IS_BUG);
            if (isBugProperty == null) {
                // Unclassified
                isBugItem.setSelection(false);
                notBugItem.setSelection(false);
            } else {
                boolean isBug = isBugProperty.getValueAsBoolean();
                isBugItem.setSelection(isBug);
                notBugItem.setSelection(!isBug);
            }
        } else {
            // No bug instance, so uncheck and disable the menu items
            if (DEBUG) {
                System.out.println("No bug instance found, disabling menu items");
            }
            isBugItem.setEnabled(false);
            notBugItem.setEnabled(false);
            isBugItem.setSelection(false);
            notBugItem.setSelection(false);
        }
    }
593734
function MenuItem(arg,opt) {
        
        if ($.isPlainObject(arg)) { opt = arg; arg = null; }
        
        if (!arg) arg = '<a>';
        
        this.container = $(arg)[0];
        
        if (opt) this.set(opt);
    }
174449
def MenuItem(parent, menu, label='', longtext='', action=None, default=True,
             **kws):
    
    item = menu.Append(-1, label, longtext, **kws)
    kind = item.GetKind()
    if kind == wx.ITEM_CHECK:
        item.Check(default)
    if callable(action):
        parent.Bind(wx.EVT_MENU, action, item)
    return item
1362001
private function createMenuItemCreateForm(MenuItem $entity)
    {
        $form = $this->createForm(new MenuItemType(), $entity, array(
            'action' => $this->generateUrl('admin_menu_item_create', array('id' => $entity->getMenu()->getId())),
            'method' => 'POST',
        ));

        $form->add('submit', 'submit', array('label' => 'Create'));

        return $form;
    }
670226
private function buildMenu()
    {
        foreach ($this->menuEntries as $menuEntry) {
            $this->buildMenuItem($menuEntry[0], $menuEntry[1], $menuEntry[2], $menuEntry[3], $menuEntry[4], $menuEntry[5], $menuEntry[6]);
        }
    }
1285078
private void fillMenu() {
        isBugItem = new MenuItem(menu, SWT.RADIO);
        isBugItem.setText("Bug");
        notBugItem = new MenuItem(menu, SWT.RADIO);
        notBugItem.setText("Not Bug");

        isBugItem.addSelectionListener(new SelectionAdapter() {
            /*
             * (non-Javadoc)
             *
             * @see
             * org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse
             * .swt.events.SelectionEvent)
             */
            @Override
            public void widgetSelected(SelectionEvent e) {
                if (bugInstance != null) {
                    classifyWarning(bugInstance, true);
                }
            }
        });

        notBugItem.addSelectionListener(new SelectionAdapter() {
            /*
             * (non-Javadoc)
             *
             * @see
             * org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse
             * .swt.events.SelectionEvent)
             */
            @Override
            public void widgetSelected(SelectionEvent e) {
                if (bugInstance != null) {
                    classifyWarning(bugInstance, false);
                }
            }
        });

        menu.addMenuListener(new MenuAdapter() {
            @Override
            public void menuShown(MenuEvent e) {
                // Before showing the menu, sync its contents
                // with the current BugInstance (if any)
                if (DEBUG) {
                    System.out.println("Synchronizing menu!");
                }
                syncMenu();
            }
        });
    }
77966
def OnMenu(self, event):
        """"""

        __id = event.GetId()
        try:
            menuitem = event.GetEventObject().FindItemById(__id)
            selected_text = menuitem.GetItemLabel()
            self.search.SetValue(selected_text)
        except AttributeError:
            # Not called by menu
            event.Skip()
877470
def CreateMenuBar(self):
        """"""
        menubar = wx.MenuBar()
        menu = wx.Menu()
        menu.Append(ID_OPEN, _('&Open Profile'), _('Open a cProfile file'))
        menu.Append(ID_OPEN_MEMORY, _('Open &Memory'), _('Open a Meliae memory-dump file'))
        menu.AppendSeparator()
        menu.Append(ID_EXIT, _('&Close'), _('Close this RunSnakeRun window'))
        menubar.Append(menu, _('&File'))
        menu = wx.Menu()
#        self.packageMenuItem = menu.AppendCheckItem(
#            ID_PACKAGE_VIEW, _('&File View'),
#            _('View time spent by package/module')
#        )
        self.percentageMenuItem = menu.AppendCheckItem(
            ID_PERCENTAGE_VIEW, _('&Percentage View'),
            _('View time spent as percent of overall time')
        )
        self.rootViewItem = menu.Append(
            ID_ROOT_VIEW, _('&Root View (Home)'),
            _('View the root of the tree')
        )
        self.backViewItem = menu.Append(
            ID_BACK_VIEW, _('&Back'), _('Go back in your viewing history')
        )
        self.upViewItem = menu.Append(
            ID_UP_VIEW, _('&Up'),
            _('Go "up" to the parent of this node with the largest cumulative total')
        )
        self.moreSquareViewItem = menu.AppendCheckItem(
            ID_MORE_SQUARE, _('&Hierarchic Squares'),
            _('Toggle hierarchic squares in the square-map view')
        )

        # This stuff isn't really all that useful for profiling,
        # it's more about how to generate graphics to describe profiling...
        self.deeperViewItem = menu.Append(
            ID_DEEPER_VIEW, _('&Deeper'), _('View deeper squaremap views')
        )
        self.shallowerViewItem = menu.Append(
            ID_SHALLOWER_VIEW, _('&Shallower'), _('View shallower squaremap views')
        )
#        wx.ToolTip.Enable(True)
        menubar.Append(menu, _('&View'))
        
        self.viewTypeMenu =wx.Menu( )
        menubar.Append(self.viewTypeMenu, _('View &Type'))
        
        self.SetMenuBar(menubar)

        wx.EVT_MENU(self, ID_EXIT, lambda evt: self.Close(True))
        wx.EVT_MENU(self, ID_OPEN, self.OnOpenFile)
        wx.EVT_MENU(self, ID_OPEN_MEMORY, self.OnOpenMemory)
        
        wx.EVT_MENU(self, ID_PERCENTAGE_VIEW, self.OnPercentageView)
        wx.EVT_MENU(self, ID_UP_VIEW, self.OnUpView)
        wx.EVT_MENU(self, ID_DEEPER_VIEW, self.OnDeeperView)
        wx.EVT_MENU(self, ID_SHALLOWER_VIEW, self.OnShallowerView)
        wx.EVT_MENU(self, ID_ROOT_VIEW, self.OnRootView)
        wx.EVT_MENU(self, ID_BACK_VIEW, self.OnBackView)
        wx.EVT_MENU(self, ID_MORE_SQUARE, self.OnMoreSquareToggle)
452655
private void fillMenu() {
        // Create a selection listener to handle when the
        // user selects a warning severity.
        SelectionListener menuItemSelectionListener = new SelectionAdapter() {
            /*
             * (non-Javadoc)
             *
             * @see
             * org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse
             * .swt.events.SelectionEvent)
             */
            @Override
            public void widgetSelected(SelectionEvent e) {
                Widget w = e.widget;
                int index;
                for (index = 0; index < severityItemList.length; ++index) {
                    if (w == severityItemList[index]) {
                        break;
                    }
                }

                if (index < severityItemList.length) {
                    if (bugInstance != null) {
                        bugInstance.setProperty(BugProperty.SEVERITY, String.valueOf(index + 1));
                    }
                }
            }
        };

        severityItemList = new MenuItem[SEVERITY_LABEL_LIST.length];
        for (int i = 0; i < SEVERITY_LABEL_LIST.length; ++i) {
            MenuItem menuItem = new MenuItem(menu, SWT.RADIO);
            menuItem.setText(SEVERITY_LABEL_LIST[i]);
            menuItem.addSelectionListener(menuItemSelectionListener);

            severityItemList[i] = menuItem;
        }

        // Keep menu in sync with current BugInstance.
        menu.addMenuListener(new MenuAdapter() {
            /*
             * (non-Javadoc)
             *
             * @see
             * org.eclipse.swt.events.MenuAdapter#menuShown(org.eclipse.swt.
             * events.MenuEvent)
             */
            @Override
            public void menuShown(MenuEvent e) {
                syncMenu();
            }
        });
    }
828638
def get_menu(self, name):
        """"""
        if name not in self._menus:
            self._menus[name] = self.menuBar().addMenu(name)
        return self._menus[name]
75538
public function makeSureMenusExist()
    {
        $locales = array_unique($this->getLocales());
        $required = array();

        foreach ($this->menuNames as $name) {
            $required[$name] = $locales;
        }

        $menuObjects = $this->em->getRepository($this->menuEntityClass)->findAll();

        foreach ($menuObjects as $menu) {
            if (array_key_exists($menu->getName(), $required)) {
                $index = array_search($menu->getLocale(), $required[$menu->getName()]);
                if ($index !== false) {
                    unset($required[$menu->getName()][$index]);
                }
            }
        }

        foreach ($required as $name => $locales) {
            foreach ($locales as $locale) {
                $className = $this->menuEntityClass;
                $menu = new $className();
                $menu->setName($name);
                $menu->setLocale($locale);
                $this->em->persist($menu);
            }
        }

        $this->em->flush();
    }
969042
def prime_menu_items(self, menu_items):
        
        for item in menu_items:
            item = self._prime_menu_item(item)
            if item is not None:
                yield item