def __init__(self, *args, **kargs): """Initialize that main app and its attributes @postcondition: application is created and ready to be run in mainloop """ wx.App.__init__(self, *args, **kargs) events.AppEventHandlerMixin.__init__(self) # Attributes self._log = dev_tool.DEBUGP self._lock = False self._windows = dict() # Setup Locale locale.setlocale(locale.LC_ALL, '') self.locale = wx.Locale(ed_i18n.GetLangId( profiler.Profile_Get('LANG'))) if self.locale.GetCanonicalName() in ed_i18n.GetAvailLocales(): self.locale.AddCatalogLookupPathPrefix(ed_glob.CONFIG['LANG_DIR']) self.locale.AddCatalog(ed_glob.PROG_NAME) else: del self.locale self.locale = None # Setup Plugins after locale as they may have resource that need to # be loaded. self._pluginmgr = plugin.PluginManager() self._log("[app][info] Registering Editra's ArtProvider") wx.ArtProvider.PushProvider(ed_art.EditraArt())
def init_locale(): """ Initialize the Language Settings. """ the_locale = wx.Locale(ed_i18n.GetLangId(Profile_Get('LANG'))) if the_locale.GetCanonicalName() in ed_i18n.GetAvailLocales(): lc = ed_glob.CONFIG['LANG_DIR'] + 'defis\\' wx.GetApp().GetLog()('----- init_locale ----- %s' % lc) gettext.bindtextdomain('defis', lc) gettext.textdomain('defis')
def OnInit(self): """Initialize the Editor @note: this gets called before __init__ @postcondition: custom artprovider and plugins are loaded """ self._log = dev_tool.DEBUGP self._log("[app][info] Editra is Initializing") self._isfirst = False # Is the first instance self._instance = None # Setup Locale locale.setlocale(locale.LC_ALL, '') self.locale = wx.Locale(ed_i18n.GetLangId( profiler.Profile_Get('LANG'))) if self.locale.GetCanonicalName() in ed_i18n.GetAvailLocales(): self.locale.AddCatalogLookupPathPrefix(ed_glob.CONFIG['LANG_DIR']) self.locale.AddCatalog(ed_glob.PROG_NAME) else: del self.locale self.locale = None # Check and set encoding if necessary if not profiler.Profile_Get('ENCODING'): profiler.Profile_Set('ENCODING', locale.getpreferredencoding()) # Setup the Error Reporter if profiler.Profile_Get('REPORTER', 'bool', True): sys.excepthook = dev_tool.ExceptionHook #---- Bind Events ----# self.Bind(wx.EVT_ACTIVATE_APP, self.OnActivate) self.Bind(wx.EVT_MENU, self.OnNewWindow, id=ed_glob.ID_NEW_WINDOW) self.Bind(wx.EVT_MENU, self.OnCloseWindow) self.Bind(ed_event.EVT_NOTIFY, self.OnNotify) self.Bind(ed_ipc.EVT_COMMAND_RECV, self.OnCommandRecieved) return True
profiler.Profile_Set('SESSION_KEY', key) profiler.Profile_Set('ISBINARY', hasattr(sys, 'frozen')) path = profiler.Profile_Get('MYPROFILE') profiler.Profile().Write(path) self._server = ed_ipc.EdIpcServer( self, profiler.Profile_Get('SESSION_KEY')) self._server.start() self._isfirst = True else: self._isfirst = True # Setup Locale locale.setlocale(locale.LC_ALL, '') self.locale = wx.Locale(ed_i18n.GetLangId( profiler.Profile_Get('LANG'))) if self.locale.GetCanonicalName() in ed_i18n.GetAvailLocales(): self.locale.AddCatalogLookupPathPrefix(ed_glob.CONFIG['LANG_DIR']) self.locale.AddCatalog(ed_glob.PROG_NAME) else: del self.locale self.locale = None # Setup the Error Reporter if profiler.Profile_Get('REPORTER', 'bool', True): sys.excepthook = dev_tool.ExceptionHook #---- Bind Events ----# self.Bind(wx.EVT_ACTIVATE_APP, self.OnActivate) self.Bind(wx.EVT_MENU, self.OnNewWindow, id=ed_glob.ID_NEW_WINDOW) self.Bind(wx.EVT_MENU, self.OnCloseWindow) self.Bind(ed_event.EVT_NOTIFY, self.OnNotify)