206 # Define location for searching translation files |
206 # Define location for searching translation files |
207 loc.AddCatalogLookupPathPrefix(localedir) |
207 loc.AddCatalogLookupPathPrefix(localedir) |
208 # Define locale domain |
208 # Define locale domain |
209 loc.AddCatalog(domain) |
209 loc.AddCatalog(domain) |
210 |
210 |
211 global default_locale |
211 builtins.__dict__['_'] = wx.GetTranslation |
212 default_locale = locale.getdefaultlocale()[1] |
|
213 |
|
214 # sys.stdout.encoding = default_locale |
|
215 # if Beremiz_service is started from Beremiz IDE |
|
216 # sys.stdout.encoding is None (that means 'ascii' encoding'). |
|
217 # And unicode string returned by wx.GetTranslation() are |
|
218 # automatically converted to 'ascii' string. |
|
219 def unicode_translation(message): |
|
220 return wx.GetTranslation(message).encode(default_locale) |
|
221 |
|
222 builtins.__dict__['_'] = unicode_translation |
|
223 # builtins.__dict__['_'] = wx.GetTranslation |
|
224 |
212 |
225 |
213 |
226 # Life is hard... have a candy. |
214 # Life is hard... have a candy. |
227 # pylint: disable=wrong-import-position,wrong-import-order |
215 # pylint: disable=wrong-import-position,wrong-import-order |
228 if enablewx: |
216 if enablewx: |
369 |
357 |
370 def OnTaskBarChangeName(self, evt): |
358 def OnTaskBarChangeName(self, evt): |
371 _servicename = self.pyroserver.servicename |
359 _servicename = self.pyroserver.servicename |
372 _servicename = '' if _servicename is None else _servicename |
360 _servicename = '' if _servicename is None else _servicename |
373 dlg = ParamsEntryDialog(None, _("Enter a name "), defaultValue=_servicename) |
361 dlg = ParamsEntryDialog(None, _("Enter a name "), defaultValue=_servicename) |
374 dlg.SetTests([(lambda name: len(name) is not 0, _("Name must not be null!"))]) |
362 dlg.SetTests([(lambda name: len(name) != 0, _("Name must not be null!"))]) |
375 if dlg.ShowModal() == wx.ID_OK: |
363 if dlg.ShowModal() == wx.ID_OK: |
376 self.pyroserver.servicename = dlg.GetValue() |
364 self.pyroserver.servicename = dlg.GetValue() |
377 self.pyroserver.Restart() |
365 self.pyroserver.Restart() |
378 |
366 |
379 def _LiveShellLocals(self): |
367 def _LiveShellLocals(self): |
446 def wx_evaluator(obj, *args, **kwargs): |
434 def wx_evaluator(obj, *args, **kwargs): |
447 tocall, args, kwargs = obj.call |
435 tocall, args, kwargs = obj.call |
448 obj.res = default_evaluator(tocall, *args, **kwargs) |
436 obj.res = default_evaluator(tocall, *args, **kwargs) |
449 wx_eval_lock.release() |
437 wx_eval_lock.release() |
450 |
438 |
451 main_thread_id = currentThread().ident |
439 main_thread_id = current_thread().ident |
452 def evaluator(tocall, *args, **kwargs): |
440 def evaluator(tocall, *args, **kwargs): |
453 # To prevent deadlocks, check if current thread is not one already main |
441 # To prevent deadlocks, check if current thread is not one already main |
454 current_id = currentThread().ident |
442 current_id = current_thread().ident |
455 |
443 |
456 if main_thread_id != current_id: |
444 if main_thread_id != current_id: |
457 o = type('', (object,), dict(call=(tocall, args, kwargs), res=None)) |
445 o = type('', (object,), dict(call=(tocall, args, kwargs), res=None)) |
458 wx.CallAfter(wx_evaluator, o) |
446 wx.CallAfter(wx_evaluator, o) |
459 wx_eval_lock.acquire() |
447 wx_eval_lock.acquire() |