本文整理汇总了Python中wx.Locale方法的典型用法代码示例。如果您正苦于以下问题:Python wx.Locale方法的具体用法?Python wx.Locale怎么用?Python wx.Locale使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类wx
的用法示例。
在下文中一共展示了wx.Locale方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setUpClass
# 需要导入模块: import wx [as 别名]
# 或者: from wx import Locale [as 别名]
def setUpClass(cls):
WXGladeBaseTest.setUpClass()
xrc2wxg._write_timestamp = False
# create an simply application
cls.app = wx.App()
cls.locale = wx.Locale(wx.LANGUAGE_DEFAULT)
compat.wx_ArtProviderPush(main.wxGladeArtProvider())
import history
common.history = history.History()
cls.frame = main.wxGladeFrame()
# suppress wx error messages
cls.nolog = wx.LogNull()
#cls.app.SetAssertMode(0) # avoid triggering of wx assertions; sometimes needed for debugging
# hide all windows
#cls.frame.Hide()
#cls.frame.hide_all()
示例2: update_language
# 需要导入模块: import wx [as 别名]
# 或者: from wx import Locale [as 别名]
def update_language(new_language):
global locale, language
language = new_language
if locale:
del locale
locale = wx.Locale(language)
if locale.IsOk():
locale.AddCatalogLookupPathPrefix(os.path.join(get_module_path(), "locale"))
locale.AddCatalog("guiminer")
else:
locale = None
示例3: OnInit
# 需要导入模块: import wx [as 别名]
# 或者: from wx import Locale [as 别名]
def OnInit(self):
"""Starts tray icon loop."""
frame = wx.Frame(None)
self.locale = wx.Locale(wx.LANGUAGE_ENGLISH_US)
self.SetTopWindow(frame)
TaskBarIcon(frame)
return True
示例4: getlanguageDict
# 需要导入模块: import wx [as 别名]
# 或者: from wx import Locale [as 别名]
def getlanguageDict():
languageDict = {}
for lang in [x for x in dir(wx) if x.startswith("LANGUAGE")]:
i = wx.Locale(wx.LANGUAGE_DEFAULT).GetLanguageInfo(getattr(wx, lang))
if i:
languageDict[i.CanonicalName] = i.Description
return languageDict
# -----------------------------------------------------------------------------
# m a k e P O ( ) -- Build the Portable Object file for the application --
# ^^^^^^^^^^^^^^^
#
示例5: OnInit
# 需要导入模块: import wx [as 别名]
# 或者: from wx import Locale [as 别名]
def OnInit(self):
sys.stdout = sys.__stdout__
sys.stderr = sys.__stderr__
# replace text based exception handler by a graphical exception dialog
sys.excepthook = self.graphical_exception_handler
# use graphical implementation to show caught exceptions
self._exception_orig = logging.exception # Reference to original implementation of logging.exception()
logging.exception = self.exception
# needed for wx >= 2.3.4 to disable wxPyAssertionError exceptions
if not config.debugging:
self.SetAssertMode(0)
common.init_preferences()
self.locale = wx.Locale(wx.LANGUAGE_DEFAULT) # avoid PyAssertionErrors
#compat.wx_ArtProviderPush(wxGladeArtProvider())
frame = wxGladeFrame()
self.SetTopWindow(frame)
self.SetExitOnFrameDelete(True)
self.Bind(wx.EVT_IDLE, self.OnIdle)
return True
示例6: getlanguageDict
# 需要导入模块: import wx [as 别名]
# 或者: from wx import Locale [as 别名]
def getlanguageDict():
languageDict = {}
for lang in [x for x in dir(wx) if x.startswith("LANGUAGE")]:
i = wx.Locale(wx.LANGUAGE_DEFAULT).GetLanguageInfo(getattr(wx, lang))
if i:
languageDict[i.CanonicalName] = i.Description
return languageDict
# -----------------------------------------------------------------------------
# m a k e P O ( ) -- Build the Portable Object file for the application --
# ^^^^^^^^^^^^^^^
#
示例7: __init__
# 需要导入模块: import wx [as 别名]
# 或者: from wx import Locale [as 别名]
def __init__(self):
self.onExitFuncs = []
wx.App.__init__(self, 0)
lang_id = LCID_TO_WX.get(kernel32.GetUserDefaultUILanguage(), None)
if lang_id is not None:
self.locale = wx.Locale(lang_id)
self.shouldVeto = False
self.firstQuery = True
self.endSession = False
self.frame = wx.Frame(None)
self.hwnd = self.frame.GetHandle()
示例8: SetupI18n
# 需要导入模块: import wx [as 别名]
# 或者: from wx import Locale [as 别名]
def SetupI18n():
# Get folder containing translation files
localedir = os.path.join(beremiz_dir, "locale")
# Get the default language
langid = wx.LANGUAGE_DEFAULT
# Define translation domain (name of translation files)
domain = "Beremiz"
# Define locale for wx
loc = builtins.__dict__.get('loc', None)
if loc is None:
wx.LogGui.EnableLogging(False)
loc = wx.Locale(langid)
wx.LogGui.EnableLogging(True)
builtins.__dict__['loc'] = loc
# Define location for searching translation files
loc.AddCatalogLookupPathPrefix(localedir)
# Define locale domain
loc.AddCatalog(domain)
import locale
global default_locale
default_locale = locale.getdefaultlocale()[1]
# sys.stdout.encoding = default_locale
# if Beremiz_service is started from Beremiz IDE
# sys.stdout.encoding is None (that means 'ascii' encoding').
# And unicode string returned by wx.GetTranslation() are
# automatically converted to 'ascii' string.
def unicode_translation(message):
return wx.GetTranslation(message).encode(default_locale)
builtins.__dict__['_'] = unicode_translation
# builtins.__dict__['_'] = wx.GetTranslation
# Life is hard... have a candy.
# pylint: disable=wrong-import-position,wrong-import-order
示例9: AddCatalog
# 需要导入模块: import wx [as 别名]
# 或者: from wx import Locale [as 别名]
def AddCatalog(locale_dir):
if os.path.exists(locale_dir) and os.path.isdir(locale_dir):
domain = GetDomain(locale_dir)
if domain is not None:
global locale
if locale is None:
# Define locale for wx
wx.LogGui.EnableLogging(False)
locale = wx.Locale(wx.LANGUAGE_DEFAULT)
wx.LogGui.EnableLogging(True)
locale.AddCatalogLookupPathPrefix(locale_dir)
locale.AddCatalog(domain)
示例10: getlanguageDict
# 需要导入模块: import wx [as 别名]
# 或者: from wx import Locale [as 别名]
def getlanguageDict():
languageDict = {}
getSupportedLanguageDict('Beremiz')
if wx.VERSION >= (3, 0, 0):
_app = wx.App()
else:
_app = wx.PySimpleApp()
for lang in [x for x in dir(wx) if x.startswith("LANGUAGE")]:
i = wx.Locale(wx.LANGUAGE_DEFAULT).GetLanguageInfo(getattr(wx, lang))
if i:
languageDict[i.CanonicalName] = i.Description
return languageDict
示例11: start
# 需要导入模块: import wx [as 别名]
# 或者: from wx import Locale [as 别名]
def start(self):
result = True
self.help_file = self.app_name + '.htb'
#SETUP LANGUAGE
lang_catalog = getdefaultlocale()[0]
list_trans = []
current_trans = -1
i = 0
self.wx_coding = 'ansi'
if wx.USE_UNICODE:
self.wx_coding = 'unicode'
if os.path.exists('lang/%s'%lang_catalog):
for dir_name in os.listdir('lang'):
if os.path.exists('lang/%s/%s_%s.mo'%(dir_name, self.app_name, self.wx_coding)):
if dir_name == lang_catalog:
current_trans = i
self.help_file = 'lang/' + dir_name + '/'+ self.help_file
list_trans.append(gettext.GNUTranslations(open('lang/%s/%s_%s.mo'%(dir_name, self.app_name, self.wx_coding), 'rb')))
i += 1
if len(list_trans) > 0:
try:
list_trans[current_trans].install(unicode = wx.USE_UNICODE)
except:
print print_error()
if current_trans == -1:
trans = gettext.NullTranslations()
trans.install(unicode = wx.USE_UNICODE)
# SETUP WX LANGUAGE TRANSLATION TO OS DEFAULT LANGUAGE
# WX DIRECTORY MUST BE TO CONTAIN LANG DIRECTORY
self.locale = wx.Locale(wx.LANGUAGE_DEFAULT)
# CHECK EXISTS INSTANCE
name_user = wx.GetUserId()
name_instance = self.app_name + '::'
self.instance_checker = wx.SingleInstanceChecker(name_instance + name_user)
if self.instance_checker.IsAnotherRunning():
wx.MessageBox(_('Software is already running.'), _('Warning'))
return False
# CREATE HTML HELP CONTROLLER
wx.FileSystem.AddHandler(wx.ZipFSHandler())
self.help_controller = HtmlHelpController()
if os.path.exists(self.help_file):
self.help_controller.AddBook(self.help_file)
#ABOUT APPLICATION
self.developers = [_('Max Kolosov')]
self.copyright = _('(C) 2009 Max Kolosov')
self.web_site = ('http://vosolok2008.narod.ru', _('Home page'))
self.email = ('mailto:maxkolosov@inbox.ru', _('email for feedback'))
self.license = _('BSD license')
self.about_description = _('wxPython bass music player.')
#CREATE MAIN FRAME
self.main_frame = main_frame(None, wx.ID_ANY, self.app_name, app = self)
self.SetTopWindow(self.main_frame)
self.main_frame.Show()
return result
示例12: start
# 需要导入模块: import wx [as 别名]
# 或者: from wx import Locale [as 别名]
def start(self):
result = True
self.help_file = self.app_name + '.htb'
#SETUP LANGUAGE
lang_catalog = getdefaultlocale()[0]
list_trans = []
current_trans = -1
i = 0
if os.path.exists('lang/%s'%lang_catalog):
for dir_name in os.listdir('lang'):
if os.path.exists('lang/%s/%s.mo'%(dir_name, self.app_name)):
if dir_name == lang_catalog:
current_trans = i
self.help_file = 'lang/' + dir_name + '/'+ self.help_file
list_trans.append(gettext.GNUTranslations(open('lang/%s/%s.mo'%(dir_name, self.app_name), 'rb')))
i += 1
if len(list_trans) > 0:
try:
list_trans[current_trans].install(unicode = True)#wx.USE_UNICODE
except:
print_error()
if current_trans == -1:
trans = gettext.NullTranslations()
trans.install(unicode = True)#wx.USE_UNICODE
# SETUP WX LANGUAGE TRANSLATION TO OS DEFAULT LANGUAGE
# WX DIRECTORY MUST BE TO CONTAIN LANG DIRECTORY
self.locale = wx.Locale(wx.LANGUAGE_DEFAULT)
# CHECK EXISTS INSTANCE
name_user = wx.GetUserId()
name_instance = self.app_name + '::'
self.instance_checker = wx.SingleInstanceChecker(name_instance + name_user)
if self.instance_checker.IsAnotherRunning():
wx.MessageBox(_('Software is already running.'), _('Warning'))
return False
# CREATE HTML HELP CONTROLLER
#~ wx.FileSystem.AddHandler(wx.ZipFSHandler())
self.help_controller = HtmlHelpController()
if os.path.exists(self.help_file):
self.help_controller.AddBook(self.help_file)
#ABOUT APPLICATION
self.developers = [_('Maxim Kolosov')]
self.copyright = _('(C) 2013 Max Kolosov')
self.web_site = ('http://pybass.sf.net', _('Home page'))
self.email = ('mailto:pyirrlicht@gmail.com', _('email for feedback'))
self.license = _('BSD license')
self.about_description = _('wxPython bass music player.')
#CREATE MAIN FRAME
self.main_frame = main_frame(None, wx.ID_ANY, self.app_name, app = self)
self.SetTopWindow(self.main_frame)
self.main_frame.Show()
return result