python类NewId()的实例源码

Viewer.py 文件源码 项目:beremiz 作者: nucleron 项目源码 文件源码 阅读 15 收藏 0 点赞 0 评论 0
def AddDivergenceMenuItems(self, menu, delete=False):
        [ID_ADD_BRANCH, ID_DELETE_BRANCH] = [wx.NewId() for i in xrange(2)]

        # Create menu items
        self.AddMenuItems(menu, [
            (ID_ADD_BRANCH, wx.ITEM_NORMAL, _(u'Add Divergence Branch'), '', self.OnAddBranchMenu),
            (ID_DELETE_BRANCH, wx.ITEM_NORMAL, _(u'Delete Divergence Branch'), '', self.OnDeleteBranchMenu)])

        menu.Enable(ID_DELETE_BRANCH, delete)

    # Add Add Menu items to the given menu
Viewer.py 文件源码 项目:beremiz 作者: nucleron 项目源码 文件源码 阅读 17 收藏 0 点赞 0 评论 0
def AddDefaultMenuItems(self, menu, edit=False, block=False):
        if block:
            [ID_EDIT_BLOCK, ID_DELETE, ID_ADJUST_BLOCK_SIZE] = [wx.NewId() for i in xrange(3)]

            # Create menu items
            self.AddMenuItems(menu, [
                 (ID_EDIT_BLOCK, wx.ITEM_NORMAL, _(u'Edit Block'), '', self.OnEditBlockMenu),
                 (ID_ADJUST_BLOCK_SIZE, wx.ITEM_NORMAL, _(u'Adjust Block Size'), '', self.OnAdjustBlockSizeMenu),
                 (ID_DELETE, wx.ITEM_NORMAL, _(u'Delete'), '', self.OnDeleteMenu)])

            menu.Enable(ID_EDIT_BLOCK, edit)

        else:
            [ID_CLEAR_EXEC_ORDER, ID_RESET_EXEC_ORDER] = [wx.NewId() for i in xrange(2)]

            # Create menu items
            if self.CurrentLanguage == 'FBD':
                self.AddMenuItems(menu, [
                    (ID_CLEAR_EXEC_ORDER, wx.ITEM_NORMAL, _(u'Clear Execution Order'), '', self.OnClearExecutionOrderMenu),
                    (ID_RESET_EXEC_ORDER, wx.ITEM_NORMAL, _(u'Reset Execution Order'), '', self.OnResetExecutionOrderMenu)])
                menu.AppendSeparator()

            add_menu = wx.Menu(title='')
            self.AddAddMenuItems(add_menu)
            menu.AppendMenu(-1, _(u'Add'), add_menu)

        menu.AppendSeparator()

        [ID_CUT, ID_COPY, ID_PASTE] = [wx.NewId() for i in xrange(3)]

        # Create menu items
        self.AddMenuItems(menu, [
             (ID_CUT, wx.ITEM_NORMAL, _(u'Cut'), '', self.GetClipboardCallBack(self.Cut)),
             (ID_COPY, wx.ITEM_NORMAL, _(u'Copy'), '', self.GetClipboardCallBack(self.Copy)),
             (ID_PASTE, wx.ITEM_NORMAL, _(u'Paste'), '', self.GetAddMenuCallBack(self.Paste))])

        menu.Enable(ID_CUT, block)
        menu.Enable(ID_COPY, block)
        menu.Enable(ID_PASTE, self.ParentWindow.GetCopyBuffer() is not None)
Viewer.py 文件源码 项目:beremiz 作者: nucleron 项目源码 文件源码 阅读 15 收藏 0 点赞 0 评论 0
def PopupConnectionMenu(self):
        menu = wx.Menu(title='')
        connection_type = self.SelectedElement.GetType()
        for type_label, type in [(_("Connector"), CONNECTOR),
                                 (_("Continuation"), CONTINUATION)]:
            new_id = wx.NewId()
            AppendMenu(menu, help='', id=new_id, kind=wx.ITEM_RADIO, text=type_label)
            self.Bind(wx.EVT_MENU, self.GetChangeConnectionTypeMenuFunction(type), id=new_id)
            if type == connection_type:
                menu.Check(new_id, True)
        menu.AppendSeparator()
        self.AddDefaultMenuItems(menu, block=True)
        self.Editor.PopupMenu(menu)
        menu.Destroy()
NetworkEditor.py 文件源码 项目:beremiz 作者: nucleron 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def GetConfNodeMenuItems(self):
        add_menu = [(wx.ITEM_NORMAL, (_('SDO Server'), ID_NETWORKEDITORADDMENUSDOSERVER, '', self.OnAddSDOServerMenu)),
                    (wx.ITEM_NORMAL, (_('SDO Client'), ID_NETWORKEDITORADDMENUSDOCLIENT, '', self.OnAddSDOClientMenu)),
                    (wx.ITEM_NORMAL, (_('PDO Transmit'), ID_NETWORKEDITORADDMENUPDOTRANSMIT, '', self.OnAddPDOTransmitMenu)),
                    (wx.ITEM_NORMAL, (_('PDO Receive'), ID_NETWORKEDITORADDMENUPDORECEIVE, '', self.OnAddPDOReceiveMenu)),
                    (wx.ITEM_NORMAL, (_('Map Variable'), ID_NETWORKEDITORADDMENUMAPVARIABLE, '', self.OnAddMapVariableMenu)),
                    (wx.ITEM_NORMAL, (_('User Type'), ID_NETWORKEDITORADDMENUUSERTYPE, '', self.OnAddUserTypeMenu))]

        profile = self.Manager.GetCurrentProfileName()
        if profile not in ("None", "DS-301"):
            other_profile_text = _("%s Profile") % profile
            add_menu.append((wx.ITEM_SEPARATOR, None))
            for text, indexes in self.Manager.GetCurrentSpecificMenu():
                add_menu.append((wx.ITEM_NORMAL, (text, wx.NewId(), '', self.GetProfileCallBack(text))))
        else:
            other_profile_text = _('Other Profile')

        master_menu = [(wx.ITEM_NORMAL, (_('DS-301 Profile'), ID_NETWORKEDITORMASTERMENUDS301PROFILE, '', self.OnCommunicationMenu)),
                       (wx.ITEM_NORMAL, (_('DS-302 Profile'), ID_NETWORKEDITORMASTERMENUDS302PROFILE, '', self.OnOtherCommunicationMenu)),
                       (wx.ITEM_NORMAL, (other_profile_text, ID_NETWORKEDITORMASTERMENUDSOTHERPROFILE, '', self.OnEditProfileMenu)),
                       (wx.ITEM_SEPARATOR, None),
                       (add_menu, (_('Add'), ID_NETWORKEDITORMASTERMENUADD))]

        return [(wx.ITEM_NORMAL, (_('Add slave'), ID_NETWORKEDITORCONFNODEMENUADDSLAVE, '', self.OnAddSlaveMenu)),
                (wx.ITEM_NORMAL, (_('Remove slave'), ID_NETWORKEDITORCONFNODEMENUREMOVESLAVE, '', self.OnRemoveSlaveMenu)),
                (wx.ITEM_SEPARATOR, None),
                (master_menu, (_('Master'), ID_NETWORKEDITORCONFNODEMENUMASTER))]
pluginloader.py 文件源码 项目:imagepy 作者: Image-Py 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def buildShortcut(parent):
    shortcuts = []
    for item in list(PluginsManager.plgs.values()):
        cut = ShotcutManager.get(item.title)
        if cut!=None:
            acc, code = codeSplit(cut)
            if code==-1: continue;
            nid = wx.NewId()
            parent.Bind(wx.EVT_MENU, lambda x, p=item:p().start(), id=nid)
            shortcuts.append((acc, code, nid))
    return wx.AcceleratorTable(shortcuts)
devenv.py 文件源码 项目:visualStudioAddon 作者: mohammad-suliman 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def makeSettings(self, settingsSizer):
        # Translators: label of a checkbox which toggles the announcement of breakpoints via speech
        self.announceBreakpointCheckBox=wx.CheckBox(self, wx.NewId(), label=_("&Announce breakpoints via speech"))
        self.announceBreakpointCheckBox.SetValue(config.conf["visualStudio"]["announceBreakpoints"])
        settingsSizer.Add(self.announceBreakpointCheckBox,border=10, flag=wx.BOTTOM)
        # Translators: label of a checkbox which toggles the beep on breakpoints option
        self.beepOnBreakpointCheckBox=wx.CheckBox(self, wx.NewId(), label=_("&Beep on  breakpoints"))
        self.beepOnBreakpointCheckBox.SetValue(config.conf["visualStudio"]["beepOnBreakpoints"])
        settingsSizer.Add(self.beepOnBreakpointCheckBox,border=10, flag=wx.BOTTOM)
        # Translators: label of a checkbox which toggles reporting of intelliSense menu item position info
        self.reportIntelliSensePosInfoCheckBox=wx.CheckBox(self, wx.NewId(), label=_("&Report intelliSense menu item position information"))
        self.reportIntelliSensePosInfoCheckBox.SetValue(config.conf["visualStudio"]["reportIntelliSensePosInfo"])
        settingsSizer.Add(self.reportIntelliSensePosInfoCheckBox,border=10, flag=wx.BOTTOM)
onevoiceidplayer.py 文件源码 项目:voiceid 作者: sih4sing5hong5 项目源码 文件源码 阅读 17 收藏 0 点赞 0 评论 0
def _create_menu(self):
        """
        Creates a menu
        """
        menubar = wx.MenuBar()
        trainingMenu = wx.Menu()
        srMenu = wx.Menu()
        #settMenu = wx.Menu()
        testsMenu = wx.Menu()
        self.training_rec_menu_item = trainingMenu.Append(wx.NewId(), "&New", "New")
        self.max_time_menu_item = trainingMenu.Append(wx.NewId(), "&Edit max time", "Edit max time")
        self.start_rec_menu_item = srMenu.Append(wx.NewId(), "&Start", "Start")
        self.partial_time_menu_item = srMenu.Append(wx.NewId(), "&Edit partial time", "Edit partial time")
        self.sett1 = testsMenu.Append(wx.NewId(), "&Incremental", "Incremental",kind=wx.ITEM_RADIO )
        self.sett2 = testsMenu.Append(wx.NewId(), "&Fixed", "Fixed",kind=wx.ITEM_RADIO )
        self.sett3 = testsMenu.Append(wx.NewId(), "&One shot", "One shot",kind=wx.ITEM_RADIO )

        self.sett2.Enable(True)
        self.sett3.Enable(True)

        testsMenu.Check(self.sett1.GetId(), True)
        testsMenu.Check(self.sett2.GetId(), False)

        menubar.Append(trainingMenu, '&Training')
        menubar.Append(srMenu, '&Test')
        menubar.Append(testsMenu, '&Settings')

        #menubar.Append(settMenu, '&Settings')
        self.SetMenuBar(menubar)
core_type_menu.py 文件源码 项目:hachoir3 作者: vstinner 项目源码 文件源码 阅读 14 收藏 0 点赞 0 评论 0
def add_type(self, type_name):
        type_id = wx.NewId()
        self.id_to_type[type_id] = type_name
        self.menu.Append(type_id, type_name)
main_classic.py 文件源码 项目:wxpythoncookbookcode 作者: driscollis 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 0
def createMenu(self):
        """ Create the application's menu """
        menubar = wx.MenuBar()

        # Create the file menu
        fileMenu = wx.Menu()

        # Append the close item
        # Append takes an id, the text label, and a string
        # to display in the statusbar when the item is selected
        close_menu_item = fileMenu.Append(wx.NewId(),
                                          "&Close",
                                          "Closes the application")
        # Bind an event to the menu item
        self.Bind(wx.EVT_MENU, self.onClose, close_menu_item)
        # Add the fileMenu to the menu bar
        menubar.Append(fileMenu, "&File")

        # Create the help menu
        helpMenu = wx.Menu()
        about_menu_item = helpMenu.Append(wx.NewId(),
                                          "&About",
                                          "Opens the About Box")
        self.Bind(wx.EVT_MENU, self.onAboutDlg, about_menu_item)
        menubar.Append(helpMenu, "&Help")

        # Add the menu bar to the frame
        self.SetMenuBar(menubar)
main_phoenix.py 文件源码 项目:wxpythoncookbookcode 作者: driscollis 项目源码 文件源码 阅读 15 收藏 0 点赞 0 评论 0
def createMenu(self):
        """ Create the application's menu """
        menubar = wx.MenuBar()

        # Create the file menu
        fileMenu = wx.Menu()

        # Append the close item
        # Append takes an id, the text label, and a string
        # to display in the statusbar when the item is selected
        close_menu_item = fileMenu.Append(wx.NewId(),
                                          "&Close",
                                          "Closes the application")
        # Bind an event to the menu item
        self.Bind(wx.EVT_MENU, self.onClose, close_menu_item)
        # Add the fileMenu to the menu bar
        menubar.Append(fileMenu, "&File")

        # Create the help menu
        helpMenu = wx.Menu()
        about_menu_item = helpMenu.Append(wx.NewId(),
                                          "&About",
                                          "Opens the About Box")
        self.Bind(wx.EVT_MENU, self.onAboutDlg, about_menu_item)
        menubar.Append(helpMenu, "&Help")

        # Add the menu bar to the frame
        self.SetMenuBar(menubar)
tree.py 文件源码 项目:GRIPy 作者: giruenf 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def on_rightclick(self, event):
        treeid = event.GetItem()
        uid, tree_tid = self.GetItemData(treeid)
        UIM = UIManager()
        controller = UIM.get(self._controller_uid)
        OM = ObjectManager(self)

        if uid is None:  # Object attributes
            return
        if uid == controller._PSEUDOROOTUID and tree_tid is None:
            return
        #
        self.popup_obj = (uid, tree_tid)
        self.popupmenu = wx.Menu()  
        if self._is_convertible(uid):
            item = self.popupmenu.Append(wx.NewId(), 'Convert unit')
            self.Bind(wx.EVT_MENU, self.OnUnitConvert, item)
            self.popupmenu.AppendSeparator()
        #
        if tree_tid is not None:
            # Exclude all objects from a class
            menu_option_str = u'Exclude all objects [{}]'.format(tree_tid) 
        else:
            # Exclude a specific object
            obj = OM.get(uid)
            #classid, oid = uid
            menu_option_str = u'Exclude object ['
            menu_option_str = menu_option_str + str(obj.name) + u']'
        #
        item = self.popupmenu.Append(wx.NewId(), menu_option_str)
        self.Bind(wx.EVT_MENU, self.OnPopupItemSelected, item)
        #
        pos = event.GetPoint()
        self.PopupMenu(self.popupmenu, pos)
uimanager.py 文件源码 项目:GRIPy 作者: giruenf 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def new_wx_id(self):
        """
        TODO: Traduzir e melhorar isso

        Um metodo atalho para wx.NewID(), porém mantendo a sequencia dos Ids 
        dentro do UI Manager.

        P.S.: A sequencia dos Ids no wx.NewId() é perdida quando se chama de diversos modulos.
        """
        ret_val = self.__class__._wx_ID
        self.__class__._wx_ID += 1

        return ret_val
AutoGenUI.py 文件源码 项目:GRIPy 作者: giruenf 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def _bind_conditions(self, inputdesc):
        for idesc in inputdesc:
            if 'conditions' in idesc:
                name1 = idesc['name']
                for condition in idesc['conditions']:
                    name2 = condition[0]
                    widget = self.widgets[name2]
                    evt_id = wx.NewId()
                    widget.bind(self._process_event, evt_id)
                    self.eventmap[evt_id] = (name1, condition)
        #print self.eventmap
wmqttsas.py 文件源码 项目:paho.mqtt.testing 作者: eclipse 项目源码 文件源码 阅读 32 收藏 0 点赞 0 评论 0
def __init__(self):
    global myWindow
    wx.Frame.__init__(self, None, -1, "MQTT Protocol Trace", size=(600, 400))
    self.Bind(wx.EVT_CLOSE, self.OnCloseWindow)
    self.Bind(wx.EVT_LIST_ITEM_SELECTED, self.OpenDetails)

    self.list = wx.ListCtrl(self, -1, style=wx.LC_REPORT)
    self.statusBar = self.CreateStatusBar()
    menubar = wx.MenuBar()
    menu1 = wx.Menu()
    clear = menu1.Append(wx.NewId(), "&Clear")
    self.Bind(wx.EVT_MENU, self.OnClear, clear)
    saveas = menu1.Append(wx.NewId(), "&Save as")
    self.Bind(wx.EVT_MENU, self.OnSaveAs, saveas)
    menubar.Append(menu1, "&File")
    self.SetMenuBar(menubar)

    for index, title in enumerate(cols):
      self.list.InsertColumn(index, title)
      self.list.SetColumnWidth(index, widths[index])

    self.listitem = 0
    listmix.ColumnSorterMixin.__init__(self, len(cols))

    self.itemDataMap = {}

    myWindow = self
    self.thread = WorkerThread()
    self.thread.start()
fits_header_dialog.py 文件源码 项目:CAAPR 作者: Stargrazer82301 项目源码 文件源码 阅读 14 收藏 0 点赞 0 评论 0
def __init__(self, parent, raw_header_str, caption,
                 pos=wx.DefaultPosition, size=(500,300),
                 style=wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER):
        self.parent = parent
        wx.Dialog.__init__(self, parent, -1, caption, pos, size, style)
        x, y = pos
        if x == -1 and y == -1:
            self.CenterOnScreen(wx.BOTH)
        self.cur_selection = (0, 0)
        self.raw_header_str = raw_header_str
        self.raw_header_str_lower = raw_header_str.lower()
        self.text = text = wx.TextCtrl(self, -1, raw_header_str, style=wx.TE_MULTILINE | wx.TE_READONLY)

        font1 = wx.Font(12, wx.FONTFAMILY_MODERN, wx.NORMAL, wx.FONTWEIGHT_LIGHT, False)
        self.text.SetFont(font1)
        self.text.SetInitialSize((600,400))

        main_sizer = wx.BoxSizer(wx.VERTICAL)
        main_sizer.Add(self.text, 1, wx.EXPAND | wx.ALL, border=5)
        ok = wx.Button(self, wx.ID_OK, "OK")
        ok.SetDefault()
        ok.Bind(wx.EVT_BUTTON, self.on_close)

        buttons_sizer = wx.BoxSizer(wx.HORIZONTAL)
        self.search = wx.SearchCtrl(self, size=(200, -1), style=wx.TE_PROCESS_ENTER)
        self.search.ShowSearchButton(True)
        self.search.ShowCancelButton(True)
        # TODO:  make layout of search & OK button prettier (OK should be right-aligned properly)
        buttons_sizer.Add(self.search, 0, wx.ALL | wx.EXPAND)
        buttons_sizer.Add((315, 0), 1, wx.EXPAND)
        buttons_sizer.Add(ok, 0, wx.ALL)
        main_sizer.Add(buttons_sizer, 0, wx.ALL, border=4)
        self.SetSizerAndFit(main_sizer)
        self.set_cur_selection()
        self.Bind(wx.EVT_SEARCHCTRL_SEARCH_BTN, self.on_search, self.search)
        self.Bind(wx.EVT_TEXT_ENTER, self.on_search, self.search)
        self.last_search_str = ''
        self.last_find_index = 0
        self.is_dialog_still_open = True
        self.Bind(wx.EVT_CLOSE, self.on_close)
        new_id = wx.NewId()
        self.Bind(wx.EVT_MENU, self.on_cmd_w, id=new_id)
        self.SetAcceleratorTable(wx.AcceleratorTable([(wx.ACCEL_CMD, ord(str('w')), new_id)]))
ztv.py 文件源码 项目:CAAPR 作者: Stargrazer82301 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def __init__(self, parent, dpi=None, **kwargs):
        wx.Panel.__init__(self, parent, wx.ID_ANY, wx.DefaultPosition, wx.Size(512,512), **kwargs)
        self.ztv_frame = self.GetTopLevelParent()
        self.accelerator_table = []
        self.center = wx.RealPoint()
        self.zoom_rect = None
        self.eventID_to_cmap = {wx.NewId(): x for x in self.ztv_frame.available_cmaps}
        self.cmap_to_eventID = {self.eventID_to_cmap[x]: x for x in self.eventID_to_cmap}
        self.eventID_to_scaling = {wx.NewId(): x for x in self.ztv_frame.available_scalings}
        self.scaling_to_eventID = {self.eventID_to_scaling[x]: x for x in self.eventID_to_scaling}
        cmap_bitmap_height = 15
        cmap_bitmap_width = 100
        self.cmap_bitmaps = {}
        for cmap in self.ztv_frame.available_cmaps:
            temp = cm.ScalarMappable(cmap=cmap)
            rgba = temp.to_rgba(np.outer(np.ones(cmap_bitmap_height, dtype=np.uint8),
                                         np.arange(cmap_bitmap_width, dtype=np.uint8)))
            self.cmap_bitmaps[cmap] = wx.BitmapFromBufferRGBA(cmap_bitmap_width, cmap_bitmap_height,
                                                              np.uint8(np.round(rgba*255)))
        self.popup_menu_cursor_modes = ['Zoom', 'Pan']
        self.available_cursor_modes = {'Zoom':{'set-to-mode':self.set_cursor_to_zoom_mode},
                                       'Pan':{'set-to-mode':self.set_cursor_to_pan_mode}}
        self.available_key_presses = {}
        self.cursor_mode = 'Zoom'
        self.max_doubleclick_sec = 0.5  # needed to trap 'real' single clicks from the first click of a double click
        self.popup_menu_needs_rebuild = True
        self.popup_menu = None
        self.xlim = [-9e9, 9e9]
        self.ylim = [-9e9, 9e9]
        self.figure = Figure(None, dpi)
        self.axes = self.figure.add_axes([0., 0., 1., 1.])
        self.canvas = FigureCanvasWxAgg(self, -1, self.figure)
        self.Bind(wx.EVT_SIZE, self._onSize)
        self.axes_widget = AxesWidget(self.figure.gca())
        self.axes_widget.connect_event('motion_notify_event', self.on_motion)
        self.axes_widget.connect_event('figure_leave_event', self.on_cursor_leave)
        self.axes_widget.connect_event('figure_enter_event', self.on_cursor_enter)
        self.axes_widget.connect_event('button_press_event', self.on_button_press)
        self.axes_widget.connect_event('button_release_event', self.on_button_release)
        self.axes_widget.connect_event('key_press_event', self.on_key_press)
        wx.EVT_RIGHT_DOWN(self.figure.canvas, self.on_right_down)  # supercedes the above button_press_event
        pub.subscribe(self.redraw_primary_image, 'redraw-image')   
        pub.subscribe(self.reset_zoom_and_center, 'reset-zoom-and-center')
        pub.subscribe(self.set_zoom_factor, 'set-zoom-factor')
        pub.subscribe(self.set_xy_center, 'set-xy-center')
ztv.py 文件源码 项目:CAAPR 作者: Stargrazer82301 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def __init__(self, parent, dpi=None, **kwargs):
        wx.Panel.__init__(self, parent, wx.ID_ANY, wx.DefaultPosition, wx.Size(512,512), **kwargs)
        self.ztv_frame = self.GetTopLevelParent()
        self.accelerator_table = []
        self.center = wx.RealPoint()
        self.zoom_rect = None
        self.eventID_to_cmap = {wx.NewId(): x for x in self.ztv_frame.available_cmaps}
        self.cmap_to_eventID = {self.eventID_to_cmap[x]: x for x in self.eventID_to_cmap}
        self.eventID_to_scaling = {wx.NewId(): x for x in self.ztv_frame.available_scalings}
        self.scaling_to_eventID = {self.eventID_to_scaling[x]: x for x in self.eventID_to_scaling}
        cmap_bitmap_height = 15
        cmap_bitmap_width = 100
        self.cmap_bitmaps = {}
        for cmap in self.ztv_frame.available_cmaps:
            temp = cm.ScalarMappable(cmap=cmap)
            rgba = temp.to_rgba(np.outer(np.ones(cmap_bitmap_height, dtype=np.uint8),
                                         np.arange(cmap_bitmap_width, dtype=np.uint8)))
            self.cmap_bitmaps[cmap] = wx.BitmapFromBufferRGBA(cmap_bitmap_width, cmap_bitmap_height,
                                                              np.uint8(np.round(rgba*255)))
        self.popup_menu_cursor_modes = ['Zoom', 'Pan']
        self.available_cursor_modes = {'Zoom':{'set-to-mode':self.set_cursor_to_zoom_mode},
                                       'Pan':{'set-to-mode':self.set_cursor_to_pan_mode}}
        self.available_key_presses = {}
        self.cursor_mode = 'Zoom'
        self.max_doubleclick_sec = 0.5  # needed to trap 'real' single clicks from the first click of a double click
        self.popup_menu_needs_rebuild = True
        self.popup_menu = None
        self.xlim = [-9e9, 9e9]
        self.ylim = [-9e9, 9e9]
        self.figure = Figure(None, dpi)
        self.axes = self.figure.add_axes([0., 0., 1., 1.])
        self.canvas = FigureCanvasWxAgg(self, -1, self.figure)
        self.Bind(wx.EVT_SIZE, self._onSize)
        self.axes_widget = AxesWidget(self.figure.gca())
        self.axes_widget.connect_event('motion_notify_event', self.on_motion)
        self.axes_widget.connect_event('figure_leave_event', self.on_cursor_leave)
        self.axes_widget.connect_event('figure_enter_event', self.on_cursor_enter)
        self.axes_widget.connect_event('button_press_event', self.on_button_press)
        self.axes_widget.connect_event('button_release_event', self.on_button_release)
        self.axes_widget.connect_event('key_press_event', self.on_key_press)
        wx.EVT_RIGHT_DOWN(self.figure.canvas, self.on_right_down)  # supercedes the above button_press_event
        pub.subscribe(self.redraw_primary_image, 'redraw-image')   
        pub.subscribe(self.reset_zoom_and_center, 'reset-zoom-and-center')
        pub.subscribe(self.set_zoom_factor, 'set-zoom-factor')
        pub.subscribe(self.set_xy_center, 'set-xy-center')
Viewer.py 文件源码 项目:beremiz 作者: nucleron 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def AddAddMenuItems(self, menu):
        [ID_ADD_BLOCK, ID_ADD_VARIABLE, ID_ADD_CONNECTION,
         ID_ADD_COMMENT] = [wx.NewId() for i in xrange(4)]

        # Create menu items
        self.AddMenuItems(menu, [
            (ID_ADD_BLOCK, wx.ITEM_NORMAL, _(u'Block'), '', self.GetAddMenuCallBack(self.AddNewBlock)),
            (ID_ADD_VARIABLE, wx.ITEM_NORMAL, _(u'Variable'), '', self.GetAddMenuCallBack(self.AddNewVariable)),
            (ID_ADD_CONNECTION, wx.ITEM_NORMAL, _(u'Connection'), '', self.GetAddMenuCallBack(self.AddNewConnection)),
            None])

        if self.CurrentLanguage != "FBD":
            [
                ID_ADD_POWER_RAIL, ID_ADD_CONTACT, ID_ADD_COIL,
            ] = [wx.NewId() for i in xrange(3)]

            # Create menu items
            self.AddMenuItems(menu, [
                (ID_ADD_POWER_RAIL, wx.ITEM_NORMAL, _(u'Power Rail'), '', self.GetAddMenuCallBack(self.AddNewPowerRail)),
                (ID_ADD_CONTACT, wx.ITEM_NORMAL, _(u'Contact'), '', self.GetAddMenuCallBack(self.AddNewContact))])

            if self.CurrentLanguage != "SFC":
                self.AddMenuItems(menu, [
                     (ID_ADD_COIL, wx.ITEM_NORMAL, _(u'Coil'), '', self.GetAddMenuCallBack(self.AddNewCoil))])

            menu.AppendSeparator()

        if self.CurrentLanguage == "SFC":
            [
                ID_ADD_INITIAL_STEP, ID_ADD_STEP, ID_ADD_TRANSITION,
                ID_ADD_ACTION_BLOCK, ID_ADD_DIVERGENCE, ID_ADD_JUMP,
            ] = [wx.NewId() for i in xrange(6)]

            # Create menu items
            self.AddMenuItems(menu, [
                (ID_ADD_INITIAL_STEP, wx.ITEM_NORMAL, _(u'Initial Step'), '', self.GetAddMenuCallBack(self.AddNewStep, True)),
                (ID_ADD_STEP, wx.ITEM_NORMAL, _(u'Step'), '', self.GetAddMenuCallBack(self.AddNewStep)),
                (ID_ADD_TRANSITION, wx.ITEM_NORMAL, _(u'Transition'), '', self.GetAddMenuCallBack(self.AddNewTransition)),
                (ID_ADD_ACTION_BLOCK, wx.ITEM_NORMAL, _(u'Action Block'), '', self.GetAddMenuCallBack(self.AddNewActionBlock)),
                (ID_ADD_DIVERGENCE, wx.ITEM_NORMAL, _(u'Divergence'), '', self.GetAddMenuCallBack(self.AddNewDivergence)),
                (ID_ADD_JUMP, wx.ITEM_NORMAL, _(u'Jump'), '', self.GetAddMenuCallBack(self.AddNewJump)),
                None])

        self.AddMenuItems(menu, [
             (ID_ADD_COMMENT, wx.ITEM_NORMAL, _(u'Comment'), '', self.GetAddMenuCallBack(self.AddNewComment))])

    # Add Default Menu items to the given menu
lib.py 文件源码 项目:smartschool 作者: asifkodur 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def Set_Context_Menu(self):

        # Context menu 1 
        self.Context_Menu = wx.Menu()

        C_Menu_Undo = wx.MenuItem(self.Context_Menu, wx.NewId(), '&Undo                             Ctrl+Z')
        self.Context_Menu.AppendItem(C_Menu_Undo)        
        self.Context_Menu.Bind(wx.EVT_MENU, self.OnUndo, C_Menu_Undo)
        C_Menu_Undo.Enable(False)

        C_Menu_Redo = wx.MenuItem(self.Context_Menu, wx.NewId(), '&Redo                              Ctrl+Y')
        self.Context_Menu.AppendItem(C_Menu_Redo)        
        self.Context_Menu.Bind(wx.EVT_MENU, self.OnRedo, C_Menu_Redo)
        C_Menu_Redo .Enable(False)

        self.Context_Menu.AppendSeparator()

        C_Menu_Cut = wx.MenuItem(self.Context_Menu, wx.NewId(), 'Cu&t                                   Ctrl+X')
        self.Context_Menu.AppendItem(C_Menu_Cut)        
        self.Context_Menu.Bind(wx.EVT_MENU, self.OnCut, C_Menu_Cut)

        C_Menu_Copy= wx.MenuItem(self.Context_Menu, wx.NewId(), '&Copy                               Ctrl+C')
        self.Context_Menu.AppendItem(C_Menu_Copy)
        self.Context_Menu.Bind(wx.EVT_MENU, self.OnCopy, C_Menu_Copy)

        C_Menu_Paste= wx.MenuItem(self.Context_Menu, wx.NewId(), '&Paste                               Ctrl+V ')

        self.Context_Menu.AppendItem(C_Menu_Paste)
        self.Context_Menu.Bind(wx.EVT_MENU, self.OnPaste, C_Menu_Paste)        #C_Menu_Paste.Enable(False)      



        C_Menu_Delete= wx.MenuItem(self.Context_Menu, wx.NewId(), '&Delete')
        self.Context_Menu.AppendItem(C_Menu_Delete)
        self.Context_Menu.Bind(wx.EVT_MENU, self.OnDelete, C_Menu_Delete)
        # End of Context Menu 1

        #Menu 2(Add/Remove)
        self.Context_Menu2 = wx.Menu()

        self.C_Menu_Add = wx.MenuItem(self.Context_Menu2, 140, '&Add Row             \n ')
        self.Context_Menu2.AppendItem(self.C_Menu_Add)        
        self.Context_Menu2.Bind(wx.EVT_MENU, self.OnAddClick, self.C_Menu_Add)
        self.C_Menu_Add.Enable(False)

        self.C_Menu_Remove = wx.MenuItem(self.Context_Menu2, 141, '&Remove Row              \n')
        self.Context_Menu2.AppendItem(self.C_Menu_Remove)        
        self.Context_Menu2.Bind(wx.EVT_MENU, self.OnRemoveClick, self.C_Menu_Remove)
        self.C_Menu_Remove.Enable(False)
track.py 文件源码 项目:GRIPy 作者: giruenf 项目源码 文件源码 阅读 38 收藏 0 点赞 0 评论 0
def _create_selected_obj_menus(self, menu):
        self._ids_functions = {}
        selected_obj_menus = OrderedDict()
        UIM = UIManager()
        tocs = UIM.list('track_object_controller', self._controller_uid)
        for toc in tocs:
            if toc.model.selected:
                obj = toc.get_object()
                if obj:
                    obj_submenu = wx.Menu()
                    #
                    funcs = FunctionManager.functions_available_for_class(obj.__class__)
                    for f in funcs:
                        #print 
                        #print f['name']
                        #print f['friendly_name']
                        #print f['function']
                        #print f['args']
                        #print f['kwargs'] 

                        id_ = wx.NewId() 
                        obj_submenu.Append(id_, f['friendly_name'])
                        self.track.Bind(wx.EVT_MENU, self._object_menu_selection, id=id_) 
                        self._ids_functions[id_] = (f['function'], (obj))
                    #
                    obj_submenu.AppendSeparator() 
                    id_ = wx.NewId() 
                    obj_submenu.Append(id_, 'Remove from track')
                    self.track.Bind(wx.EVT_MENU, self._object_menu_selection, id=id_)    
                    self._ids_functions[id_] = (self._remove_object_helper, 
                                                   (toc.uid)
                    )
                    #
                    obj_submenu.AppendSeparator() 
                    id_ = wx.NewId() 
                    obj_submenu.Append(id_, 'Delete object')
                    self.track.Bind(wx.EVT_MENU, self._object_menu_selection, id=id_)    
                    self._ids_functions[id_] = (self._delete_object_helper, 
                                                   (toc.get_object().uid)
                    )
                    #
                    selected_obj_menus[obj] = obj_submenu 
        if selected_obj_menus:
            for obj, obj_submenu in selected_obj_menus.items():
                menu.AppendSubMenu(obj_submenu, obj.get_friendly_name())
            menu.AppendSeparator()


问题


面经


文章

微信
公众号

扫码关注公众号