Set locale the wxPython way

Should do while that class object exists of course.

···

-----Original Message-----

From: Boštjan Mejak

Sent: 1 Jul 2012 19:11:21 GMT

To: wxpython-users@googlegroups.com

Subject: Re: [wxPython-users] Set locale the wxPython way

What if I put
self.locale = wx.Locale(wx.LANGUAGE_GERMAN)

into the OnInit() method of wx.App class? Would that suffice?

To unsubscribe, send email to wxPython-users+unsubscribe@googlegroups.com

or visit http://groups.google.com/group/wxPython-users?hl=en

class MyApplication(wx.App):

def OnInit(self):

self.locale = wx.Locale(wx.LANGUAGE_GERMAN)

So something like that might work, no? Is it really necessary that I do the ‘self.locale =’ thing?

You said that you think I need to keep a reference to the returned locale object. Anyone knows if I need this reference or not?

Just try it both ways and see which works

···

On Monday, July 2, 2012 4:01:35 AM UTC-5, wxGeek wrote:

You said that you think I need to keep a reference to the returned locale object. Anyone knows if I need this reference or not?

Yes. Otherwise the locale is reset to the previous settings when the locale object is garbage collected. From the docs for the destructor:

"""
The destructor, like the constructor, also has global side effects: the previously set locale is restored and so the changes described in Init() documentation are rolled back.
"""

···

On 7/2/12 12:50 AM, Bo�tjan Mejak wrote:

class MyApplication(wx.App):

     def OnInit(self):
         self.locale = wx.Locale(wx.LANGUAGE_GERMAN)

So something like that might work, no? Is it really necessary that I do
the 'self.locale =' thing?

--
Robin Dunn
Software Craftsman