Пример #1
0
 def parent(self):
     """Returns the parent window."""
     try:
         return self._parent
     except AttributeError:
         awx.WARNING("Popup menu doesn't have parent")
         return None
Пример #2
0
    def _make_menu(self):
        """Build the menu taking into account the options of the superclasses."""
        base_classes = list(self.__class__.__bases__) + [self.__class__]
        base_classes.reverse()

        assert not hasattr(self, "menu_title_by_id")
        assert not hasattr(self, "menu_titles")
        self.menu_title_by_id, self.menu_titles = OrderedDict(), OrderedDict()

        for cls in base_classes:
            try:
                menus = cls.MENU_TITLES
            except AttributeError as exc:
                awx.WARNING("exc ", exc, " for cls", cls)
                continue

            self.menu_titles.update(menus)

            for title in menus:
                self.menu_title_by_id[wx.NewId()] = title

            # Add sentinel for Menu separator.
            self.menu_title_by_id["separator_" +
                                  str(len(self.menu_titles))] = None

        for (id, title) in self.menu_title_by_id.items():
            if title is None:
                sepid = int(id.split("_")[-1])
                if sepid != len(self.menu_titles):
                    self.AppendSeparator()
            else:
                # Register menu handlers with EVT_MENU, on the menu.
                self.Append(id, title)
                wx.EVT_MENU(self, id, self.OnMenuSelection)