def on_mainframe_updateui(win, event): eid = event.GetId() if hasattr(win, 'document') and win.document: if eid == win.IDM_DOCUMENT_WORDWRAP: if win.document.GetWrapMode: event.Enable(True) mode = win.document.GetWrapMode() if mode == wx.stc.STC_WRAP_NONE: event.Check(False) else: event.Check(True) else: event.Enable(False) elif eid == win.IDM_DOCUMENT_AUTOINDENT: if win.document.canedit: event.Enable(True) event.Check(win.pref.autoindent) else: event.Enable(False) elif eid == win.IDM_DOCUMENT_TABINDENT: if win.document.canedit: event.Enable(True) from modules import makemenu menu = makemenu.findmenu(win.menuitems, 'IDM_DOCUMENT_TABINDENT') if win.document.usetab: menu.SetText(tr('Switch To Space Indent')) else: menu.SetText(tr('Switch To Tab Indent')) else: event.Enable(False)
def makescriptmenu(win, pref): menu = makemenu.findmenu(win.menuitems, 'IDM_SCRIPT') for id in win.scriptmenu_ids: menu.Delete(id) win.scriptmenu_ids = [] if len(win.pref.scripts) == 0: id = win.IDM_SCRIPT_ITEMS menu.Append(id, tr('(Empty)')) menu.Enable(id, False) win.scriptmenu_ids = [id] else: accel = {} for description, filename in win.pref.scripts: id = wx.NewId() win.scriptmenu_ids.append(id) menu.Append(id, description) pos = description.find('\t') if pos > -1: key = description[pos + 1:] accel[id] = (key, '') wx.EVT_MENU(win, id, win.OnScriptItems) if win.old_script_accel: win.removeAccel(win.old_script_accel) win.old_script_accel = accel if accel: win.insertAccel(accel)
def makescriptmenu(win, pref): menu = makemenu.findmenu(win.menuitems, 'IDM_SCRIPT') for id in win.scriptmenu_ids: menu.Delete(id) win.scriptmenu_ids = [] if len(win.pref.scripts) == 0: id = win.IDM_SCRIPT_ITEMS menu.Append(id, tr('(Empty)')) menu.Enable(id, False) win.scriptmenu_ids=[id] else: accel = {} for description, filename in win.pref.scripts: id = wx.NewId() win.scriptmenu_ids.append(id) menu.Append(id, description) pos = description.find('\t') if pos > -1: key = description[pos+1:] accel[id] = (key, '') wx.EVT_MENU(win, id, win.OnScriptItems) if win.old_script_accel: win.removeAccel(win.old_script_accel) win.old_script_accel = accel if accel: win.insertAccel(accel)
def create_recent_snippet_menu(self): menu = makemenu.findmenu(self.menuitems, 'IDPM_RECENT') for id in self.recentmenu_ids: menu.Delete(id) self.recentmenu_ids = [] if len(self.pref.snippet_recents) == 0: id = self.IDPM_snippet_recents menu.Append(id, tr('(Empty)')) menu.Enable(id, False) self.recentmenu_ids = [id] else: for i, path in enumerate(self.pref.snippet_recents): id = wx.NewId() self.recentmenu_ids.append(id) menu.Append(id, "%d %s" % (i+1, path)) wx.EVT_MENU(self, id, self.OnRecentSnippet)
def OnOptionLanguageChange(win, event): eid = event.GetId() index = win.language_ids.index(eid) country = win.language_country[index] wx.MessageDialog(win, tr("Because you changed the language, \nit will be enabled at next startup."), tr("Change language"), wx.OK).ShowModal() ini = common.get_config_file_obj() ini.language.default = country ini.save() # change menu check status menu = makemenu.findmenu(win.menuitems, 'IDM_OPTION_LANGUAGE') for id in win.language_ids: if id == eid: menu.Check(id, True) else: menu.Check(id, False)
def create_recent_path_menu(self): menu = makemenu.findmenu(self.menuitems, 'IDPM_ADD') for id in self.dirmenu_ids: menu.Delete(id) self.dirmenu_ids = [] if len(self.pref.recent_dir_paths) == 0: id = self.IDPM_ADD_DIRS menu.Append(id, tr('(Empty)')) menu.Enable(id, False) self.dirmenu_ids = [id] else: for i, path in enumerate(self.pref.recent_dir_paths): id = wx.NewId() self.dirmenu_ids.append(id) menu.Append(id, "%d %s" % (i + 1, path)) wx.EVT_MENU(self, id, self.OnAddPath)
def create_recent_path_menu(self): menu = makemenu.findmenu(self.menuitems, 'IDPM_ADD') for id in self.dirmenu_ids: menu.Delete(id) self.dirmenu_ids = [] if len(self.pref.recent_dir_paths) == 0: id = self.IDPM_ADD_DIRS menu.Append(id, tr('(Empty)')) menu.Enable(id, False) self.dirmenu_ids = [id] else: for i, path in enumerate(self.pref.recent_dir_paths): id = wx.NewId() self.dirmenu_ids.append(id) menu.Append(id, "%d %s" % (i+1, path)) wx.EVT_MENU(self, id, self.OnAddPath)
def makeshellmenu(win, pref): menu = makemenu.findmenu(win.menuitems, 'IDM_SHELL') for id in win.shellmenu_ids: menu.Delete(id) win.shellmenu_ids = [] if len(win.pref.shells) == 0: id = win.IDM_SHELL_ITEMS menu.Append(id, tr('(Empty)')) menu.Enable(id, False) win.shellmenu_ids = [id] else: for description, filename in win.pref.shells: id = wx.NewId() win.shellmenu_ids.append(id) menu.Append(id, description) wx.EVT_MENU(win, id, win.OnShellItems)
def create_recent_session_menu(win): menu = makemenu.findmenu(win.menuitems, 'IDM_FILE_SESSION_RECENT') for id in win.recentsession_ids: menu.Delete(id) win.recentsession_ids = [] if len(win.pref.recent_sessions) == 0: id = win.IDM_FILE_SESSION_RECENT_ITEMS menu.Append(id, tr('(Empty)')) menu.Enable(id, False) win.recentsession_ids = [id] else: for i, filename in enumerate(win.pref.recent_sessions): id = wx.NewId() win.recentsession_ids.append(id) menu.Append(id, "%d %s" % (i+1, filename)) wx.EVT_MENU(win, id, win.OnOpenRecentSession)
def makeshellmenu(win, pref): menu = makemenu.findmenu(win.menuitems, 'IDM_SHELL') for id in win.shellmenu_ids: menu.Delete(id) win.shellmenu_ids = [] if len(win.pref.shells) == 0: id = win.IDM_SHELL_ITEMS menu.Append(id, tr('(Empty)')) menu.Enable(id, False) win.shellmenu_ids=[id] else: for description, filename in win.pref.shells: id = wx.NewId() win.shellmenu_ids.append(id) menu.Append(id, description) wx.EVT_MENU(win, id, win.OnShellItems)
def create_language_menu(win, filename): menu = makemenu.findmenu(win.menuitems, 'IDM_OPTION_LANGUAGE') langs = open(filename).readlines() for lang in langs: lang = lang.strip() if lang == '': continue if lang[0] == '#': continue country, language = lang.strip().split(' ', 1) id = wx.NewId() win.language_ids.append(id) win.language_country.append(country) menu.Append(id, language, 'Change language', wx.ITEM_CHECK) wx.EVT_MENU(win, id, win.OnOptionLanguageChange) index = win.language_country.index(win.app.i18n.lang) menu.Check(win.language_ids[index], True)
def init(win): menu = makemenu.findmenu(win.menuitems, "IDM_FILE_NEWMORE") menu.Delete(win.IDM_FILE_NEWMORE_NULL) create_menu(win, menu)
def init(win): menu = makemenu.findmenu(win.menuitems, 'IDM_FILE_NEWMORE') menu.Delete(win.IDM_FILE_NEWMORE_NULL) create_menu(win, menu)