[wxPython-users] Character mapping

Simone simozack at yahoo.it
Wed Jan 16 08:52:10 PST 2008


Simone ha scritto:
> I'm using a wx.lib.masked.NumCtrl and I need to map the '.' key (under 
> the number 3 on the number pad) to act like a ',' key (I need it because 
> I have the decimal char set to ',' and not '.').
> 
> How can I solve this?

For everyone that could have the same problem:

I solve this by managing the EVT_CHAR of the control and setting the 
insertion point after the decimal char (for standard lenght of the 
control, the position is 15) in this way:

self.control.Bind(wx.EVT_CHAR, OnDecimalChar)

def OnDecimalChar(self, event):
     # If pressed the decimal key in the number pad
     if event.GetKeyCode() == 391:
	control = self.FindWindowById(event.GetId())
	control.SetInsertionPoint(15)

Actually, I don't need to manage the deletion of the characters between 
the current insertion point and the decimal character: this will be in 
the version 2 of my project... :)

HTH,
Simone
Chiacchiera con i tuoi amici in tempo reale! 
 http://it.yahoo.com/mail_it/foot/*http://it.messenger.yahoo.com 




More information about the wxpython-users mailing list