水曜日, 6月 24, 2009

wxWidget GUI Programming Using XRC File

  • Python wxWidget Programming Using XRC File
    XRC Tutorial
    XRC is a method of defining the layout of a GUI application in a separate XML file rather than as wxPython code within the program itself.
    For More Information See wxPyWiki

  • C/C++ wxWidget Programming Using XRC File
    XML-based resource system overview


wxPythonとXRCとAUIの関係

XRC Internationalization

Internationalization

  • wxPython and Python have different ways of handling i18n
  • Luckily both use GNU gettext files.
  • See the documentation for Python's gettext module for help doing i18n with basic Python
  • wxPython passes all strings for labels, captions, etc, through the wxLocale if it's been instantiated.
    • Which means no changes to our XRC
    • Only need to load the message catalogs before loading the XRC

The Message Catalog

  • Python includes tools for extracting messages from Python code, but not XRC
  • So we use xrc_pot.py to generate the template file.
  • By default gettext and wxPython look for catalogs in [workingdir]/locale/[code].
  • Need to use msgfmt.py to compile .po to .mo files before this will work.

Loading the Catalog

    def initI18n(self):
# initialize the wxPython translation interface
i18n_path = os.path.join(os.getcwd(), 'locale')

wx.Locale.AddCatalogLookupPathPrefix(i18n_path)
self.i18n = wx.Locale(wx.LANGUAGE_DEFAULT)

self.i18n.AddCatalog('converter')

# initialize the gettext interface
gettext.install('converter', os.path.join(os.getcwd(), 'locale'), unicode=True)



wxWidgets でクロスプラットフォーム GUIアプリを作ろう

Main GUI Tools Ride on Linux and Windows

0 件のコメント: