我们从Python开源项目中,提取了以下4个代码示例,用于说明如何使用wx.ID_SAVE。
def __init__(self, parent, title): self.dirname=os.getcwd() wx.Frame.__init__(self, parent, title=title, size=(1000,700)) self.SetSizeHints(1000,700,-1,-1) self.CreateStatusBar() filemenu= wx.Menu() menuOpen = filemenu.Append(wx.ID_OPEN, "&Open"," Open saved state") menuSave = filemenu.Append(wx.ID_SAVE, "&Save"," Save current state") filemenu.InsertSeparator(2) menuNew = filemenu.Append(wx.ID_NEW, "&New"," Create new session") filemenu.InsertSeparator(4) menuExit = filemenu.Append(wx.ID_EXIT,"E&xit"," Terminate the program") viewmenu = wx.Menu() vismenu = wx.Menu() self.viewmenuundock = vismenu.Append(wx.ID_ANY,"&Undock","Undock the visualisation") self.viewmenuundock.Enable(0) self.viewmenudock = vismenu.Append(wx.ID_ANY,"&Dock","Dock the visualisation") self.viewmenudock.Enable(0) self.Bind(wx.EVT_MENU, self.OnUndock, self.viewmenuundock) self.Bind(wx.EVT_MENU, self.OnDock, self.viewmenudock) if IsNotWX4(): viewmenu.AppendMenu(wx.ID_ANY,"&Visualisation", vismenu) else: viewmenu.Append(wx.ID_ANY,"&Visualisation", vismenu) self.visualdialog_docked = True editmenu = wx.Menu() self.menuCWD = editmenu.Append(wx.ID_ANY, "Current Working &Directory","Current Working Directory") self.Bind(wx.EVT_MENU, self.OnCWD, self.menuCWD) helpmenu= wx.Menu() menuAbout= helpmenu.Append(wx.ID_ABOUT, "&About"," Information about Bonsu") menuDoc= helpmenu.Append(wx.ID_HELP, "&Contents","Documentation") menuBar = wx.MenuBar() menuBar.Append(filemenu,"&File") menuBar.Append(viewmenu,"&View") menuBar.Append(editmenu,"&Edit") menuBar.Append(helpmenu,"&Help") self.SetMenuBar(menuBar) self.Bind(wx.EVT_MENU, self.OnOpen, menuOpen) self.Bind(wx.EVT_MENU, self.OnSave, menuSave) self.Bind(wx.EVT_MENU, self.OnNew, menuNew) self.Bind(wx.EVT_MENU, self.OnExit, menuExit) self.Bind(wx.EVT_MENU, self.OnAbout, menuAbout) self.Bind(wx.EVT_MENU, self.OnHelp, menuDoc) self.Bind(wx.EVT_CLOSE, self.OnExit) self.fontpointsize=wx.SystemSettings.GetFont(wx.SYS_SYSTEM_FONT).GetPointSize() self.font = wx.Font(self.fontpointsize, wx.FONTFAMILY_SWISS, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL) self.SetFont(self.font) icon = wx.Icon(os.path.join(os.path.dirname(os.path.dirname(__file__)), 'image', 'bonsu.ico'), wx.BITMAP_TYPE_ICO) wx.Frame.SetIcon(self, icon) self.nb = None self.sizer = wx.BoxSizer(wx.VERTICAL) self.Fit() self.Layout() self.Show()
def _create_menu(self): menubar = wx.MenuBar() file = wx.Menu() edit = wx.Menu() help = wx.Menu() file.Append(wx.ID_OPEN, '&Open', 'Open a schematic') file.Append(wx.ID_SAVE, '&Save', 'Save the schematic') file.AppendSeparator() file.Append(103, '&Export BOM as CSV', 'Export the BOM as CSV') file.AppendSeparator() # Create a new submenu for recent files recent = wx.Menu() file.AppendSubMenu(recent, 'Recent') self.filehistory.UseMenu(recent) self.filehistory.AddFilesToMenu() file.AppendSeparator() quit = wx.MenuItem(file, 105, '&Quit\tCtrl+Q', 'Quit the Application') file.AppendItem(quit) edit.Append(201, 'Consolidate Components', 'Consolidate duplicated components') menubar.Append(file, '&File') menubar.Append(edit, '&Edit') menubar.Append(help, '&Help') self.SetMenuBar(menubar) self.Bind(wx.EVT_MENU, self.on_quit, id=105) self.Bind(wx.EVT_MENU, self.on_open, id=wx.ID_OPEN) self.Bind(wx.EVT_MENU, self.on_consolidate, id=201) self.Bind(wx.EVT_MENU, self.on_export, id=103) self.Bind(wx.EVT_MENU, self.on_save, id=wx.ID_SAVE) self.Bind(wx.EVT_MENU_RANGE, self.on_file_history, id=wx.ID_FILE1, id2=wx.ID_FILE9)
def _init_coll_FileMenu_Items(self, parent): AppendMenu(parent, help='', id=wx.ID_NEW, kind=wx.ITEM_NORMAL, text=_(u'New') + '\tCTRL+N') AppendMenu(parent, help='', id=wx.ID_OPEN, kind=wx.ITEM_NORMAL, text=_(u'Open') + '\tCTRL+O') AppendMenu(parent, help='', id=wx.ID_CLOSE, kind=wx.ITEM_NORMAL, text=_(u'Close Tab') + '\tCTRL+W') AppendMenu(parent, help='', id=wx.ID_CLOSE_ALL, kind=wx.ITEM_NORMAL, text=_(u'Close Project') + '\tCTRL+SHIFT+W') parent.AppendSeparator() AppendMenu(parent, help='', id=wx.ID_SAVE, kind=wx.ITEM_NORMAL, text=_(u'Save') + '\tCTRL+S') AppendMenu(parent, help='', id=wx.ID_SAVEAS, kind=wx.ITEM_NORMAL, text=_(u'Save As...') + '\tCTRL+SHIFT+S') AppendMenu(parent, help='', id=ID_PLCOPENEDITORFILEMENUGENERATE, kind=wx.ITEM_NORMAL, text=_(u'Generate Program') + '\tCTRL+G') parent.AppendSeparator() AppendMenu(parent, help='', id=wx.ID_PAGE_SETUP, kind=wx.ITEM_NORMAL, text=_(u'Page Setup') + '\tCTRL+ALT+P') AppendMenu(parent, help='', id=wx.ID_PREVIEW, kind=wx.ITEM_NORMAL, text=_(u'Preview') + '\tCTRL+SHIFT+P') AppendMenu(parent, help='', id=wx.ID_PRINT, kind=wx.ITEM_NORMAL, text=_(u'Print') + '\tCTRL+P') parent.AppendSeparator() AppendMenu(parent, help='', id=wx.ID_PROPERTIES, kind=wx.ITEM_NORMAL, text=_(u'&Properties')) parent.AppendSeparator() AppendMenu(parent, help='', id=wx.ID_EXIT, kind=wx.ITEM_NORMAL, text=_(u'Quit') + '\tCTRL+Q') self.Bind(wx.EVT_MENU, self.OnNewProjectMenu, id=wx.ID_NEW) self.Bind(wx.EVT_MENU, self.OnOpenProjectMenu, id=wx.ID_OPEN) self.Bind(wx.EVT_MENU, self.OnCloseTabMenu, id=wx.ID_CLOSE) self.Bind(wx.EVT_MENU, self.OnCloseProjectMenu, id=wx.ID_CLOSE_ALL) self.Bind(wx.EVT_MENU, self.OnSaveProjectMenu, id=wx.ID_SAVE) self.Bind(wx.EVT_MENU, self.OnSaveProjectAsMenu, id=wx.ID_SAVEAS) self.Bind(wx.EVT_MENU, self.OnGenerateProgramMenu, id=ID_PLCOPENEDITORFILEMENUGENERATE) self.Bind(wx.EVT_MENU, self.OnPageSetupMenu, id=wx.ID_PAGE_SETUP) self.Bind(wx.EVT_MENU, self.OnPreviewMenu, id=wx.ID_PREVIEW) self.Bind(wx.EVT_MENU, self.OnPrintMenu, id=wx.ID_PRINT) self.Bind(wx.EVT_MENU, self.OnPropertiesMenu, id=wx.ID_PROPERTIES) self.Bind(wx.EVT_MENU, self.OnQuitMenu, id=wx.ID_EXIT) self.AddToMenuToolBar([(wx.ID_NEW, "new", _(u'New'), None), (wx.ID_OPEN, "open", _(u'Open'), None), (wx.ID_SAVE, "save", _(u'Save'), None), (wx.ID_SAVEAS, "saveas", _(u'Save As...'), None), (wx.ID_PRINT, "print", _(u'Print'), None)])
def RefreshFileMenu(self): MenuToolBar = self.Panes["MenuToolBar"] if self.Controler is not None: selected = self.TabsOpened.GetSelection() if selected >= 0: graphic_viewer = isinstance(self.TabsOpened.GetPage(selected), Viewer) else: graphic_viewer = False if self.TabsOpened.GetPageCount() > 0: self.FileMenu.Enable(wx.ID_CLOSE, True) if graphic_viewer: self.FileMenu.Enable(wx.ID_PREVIEW, True) self.FileMenu.Enable(wx.ID_PRINT, True) MenuToolBar.EnableTool(wx.ID_PRINT, True) else: self.FileMenu.Enable(wx.ID_PREVIEW, False) self.FileMenu.Enable(wx.ID_PRINT, False) MenuToolBar.EnableTool(wx.ID_PRINT, False) else: self.FileMenu.Enable(wx.ID_CLOSE, False) self.FileMenu.Enable(wx.ID_PREVIEW, False) self.FileMenu.Enable(wx.ID_PRINT, False) MenuToolBar.EnableTool(wx.ID_PRINT, False) self.FileMenu.Enable(wx.ID_PAGE_SETUP, True) project_modified = not self.Controler.ProjectIsSaved() self.FileMenu.Enable(wx.ID_SAVE, project_modified) MenuToolBar.EnableTool(wx.ID_SAVE, project_modified) self.FileMenu.Enable(wx.ID_PROPERTIES, True) self.FileMenu.Enable(wx.ID_CLOSE_ALL, True) self.FileMenu.Enable(wx.ID_SAVEAS, True) MenuToolBar.EnableTool(wx.ID_SAVEAS, True) self.FileMenu.Enable(ID_PLCOPENEDITORFILEMENUGENERATE, True) else: self.FileMenu.Enable(wx.ID_CLOSE, False) self.FileMenu.Enable(wx.ID_PAGE_SETUP, False) self.FileMenu.Enable(wx.ID_PREVIEW, False) self.FileMenu.Enable(wx.ID_PRINT, False) MenuToolBar.EnableTool(wx.ID_PRINT, False) self.FileMenu.Enable(wx.ID_SAVE, False) MenuToolBar.EnableTool(wx.ID_SAVE, False) self.FileMenu.Enable(wx.ID_PROPERTIES, False) self.FileMenu.Enable(wx.ID_CLOSE_ALL, False) self.FileMenu.Enable(wx.ID_SAVEAS, False) MenuToolBar.EnableTool(wx.ID_SAVEAS, False) self.FileMenu.Enable(ID_PLCOPENEDITORFILEMENUGENERATE, False)