示例#1
0
    def OnMenuOpen(self, event: wx.MenuEvent) -> None:
        if event.GetMenu() is not self:
            # We may be just opening one of the submenus but we only
            # want to do this when opening the main menu.
            event.Skip()
            return

        main_window = wx.GetApp().GetTopWindow()
        all_windows = {
            w
            for w in wx.GetTopLevelWindows() if w is not main_window
        }

        for window in all_windows.difference(self._id_to_window.values()):
            if not window.Title:
                # We have bogus top-level windows because of the use
                # of AuiManager on the logging window (see issue #617)
                # so skip windows without a title.
                continue
            menu_item = wx.MenuItem(self, wx.ID_ANY, window.Title)
            self.Bind(wx.EVT_MENU, self.OnWindowTitle, menu_item)
            self._id_to_window[menu_item.Id] = window

            # Place this menu item after the "Reset window positions"
            # but before the log viewer and debug window.
            position = len(self._id_to_window)
            self.Insert(position, menu_item)
示例#2
0
    def OnMenuOpen(self, event: wx.MenuEvent) -> None:
        if event.GetMenu() is not self:
            # We may be just opening one of the submenus but we only
            # want to do this when opening the main menu.
            event.Skip()
            return

        main_window = wx.GetApp().GetTopWindow()
        all_windows = {
            w
            for w in wx.GetTopLevelWindows() if w is not main_window
        }

        for window in all_windows.difference(self._id_to_window.values()):
            if not window.Title:
                # We have bogus top-level windows because of the use
                # of AuiManager on the logging window (see issue #617)
                # so skip windows without a title.
                continue
            sub_menu = wx.Menu()
            for label, method in [
                ('Show/Hide', self.OnShowOrHide),
                ('Raise to top', self.OnRaiseToTop),
                ('Move to mouse', self.OnMoveToMouse),
            ]:
                menu_item = sub_menu.Append(wx.ID_ANY, label)
                sub_menu.Bind(wx.EVT_MENU, method, menu_item)
                self._id_to_window[menu_item.Id] = window

            # Place this submenu after the "Reset window positions"
            # but before the log viewer and debug window.
            position = len(self._id_to_window) / 3
            self.Insert(position, wx.ID_ANY, window.Title, sub_menu)
示例#3
0
    def TriggerItem(self, item):
        'Steps to take when a item is clicked.'

        if item.method is not None:
            wx.CallAfter(item.method, item)
        elif self.Parent.callback:
            wx.CallAfter(self.Parent.callback, item)
        else:
            menuevent = MenuEvent(wx.wxEVT_COMMAND_MENU_SELECTED, item.id)
            self.Parent.AddPendingEvent(menuevent)
        self.Parent.CloseRoot()
示例#4
0
 def OnPopupMenu(self, event: wx.MenuEvent):
     id = event.GetId()
     if id == self.RESET_LEGEND:
         self.reset = True
         self.RepaintLegend()
示例#5
0
 def on_file_history(self, event: wx.MenuEvent):
     self.load(self.app.frame.file_history.GetHistoryFile(event.GetId() - wx.ID_FILE1))