13.07.2015 Views

The wxPython tutorial

The wxPython tutorial

The wxPython tutorial

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Internationalizationhttp://www.zetcode.com/wxpython/in18/For example hungarian language has some characters that aremissing in Slovak language or English language. Some languageshave accents, others don't.#!/usr/bin/python# collate.pyimport wximport localeID_SORT = 1words = [u'Sund', u'S\xe4bel', u'S\xfcnde', u'Schl\xe4fe', u'Sabotage']class Collate(wx.Frame):def __init__(self, parent, id, title):wx.Frame.__init__(self, parent, id, title, size=(300, 220))panel = wx.Panel(self, -1)hbox = wx.BoxSizer(wx.HORIZONTAL)self.listbox = wx.ListBox(panel, -1)for i in words:self.listbox.Append(i)hbox.Add(self.listbox, 1, wx.EXPAND | wx.ALL, 20)btnPanel = wx.Panel(panel, -1)vbox = wx.BoxSizer(wx.VERTICAL)new = wx.Button(btnPanel, ID_SORT, 'Sort', size=(90, 30))self.Bind(wx.EVT_BUTTON, self.OnSort, id=ID_SORT)vbox.Add((-1, 20))vbox.Add(new)btnPanel.SetSizer(vbox)hbox.Add(btnPanel, 0.6, wx.EXPAND | wx.RIGHT, 20)panel.SetSizer(hbox)locale.setlocale(locale.LC_COLLATE, ('de_DE', 'UTF8'))self.Centre()self.Show(True)def OnSort(self, event):self.listbox.Clear()words.sort( lambda a,b: locale.strcoll(a, b) )for i in words:self.listbox.Append(i)app = wx.App()Collate(None, -1, 'Collate')app.MainLoop()8 de 12 27/04/2008 1:06

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!