wxPython does not want to catch my event

I have a masked number control and method binded to it

self.mncCijenaDo = wx.lib.masked.numctrl.NumCtrl
(id=wxID_FRMMAINMNCCIJENADO,
              name='mncCijenaDo', parent=self.pnlFilteri, pos=wx.Point
(395,
              215), size=wx.Size(127, 22), style=0, value=0)
        self.mncCijenaDo.SetDecimalChar('.')
        self.mncCijenaDo.SetFractionWidth(2)
        self.mncCijenaDo.Enable(False)
        self.mncCijenaDo.Bind(wx.EVT_TEXT_ENTER,
self.OnMncCijenaDoTextEnter, self.mncCijenaDo)

def OnMncCijenaDoTextEnter(self,
event):######################???
        print "test"

And when I Enter any number it won't catch the test text.

I don't get it.

I need that when the user types in a number and confirmes it with
enter, the Eventhandler get's done. I think that I got the right event
but it just wont work.

any idea?

Even when I use wx.EVT_TEXT and prints test, it wont make other
things, like changing the background color of another masked nuber
control

···

On 21 kol, 13:47, azrael <jura.gro...@gmail.com> wrote:

I have a masked number control and method binded to it

self.mncCijenaDo = wx.lib.masked.numctrl.NumCtrl
(id=wxID_FRMMAINMNCCIJENADO,
name='mncCijenaDo', parent=self.pnlFilteri, pos=wx.Point
(395,
215), size=wx.Size(127, 22), style=0, value=0)
self.mncCijenaDo.SetDecimalChar('.')
self.mncCijenaDo.SetFractionWidth(2)
self.mncCijenaDo.Enable(False)
self.mncCijenaDo.Bind(wx.EVT_TEXT_ENTER,
self.OnMncCijenaDoTextEnter, self.mncCijenaDo)

def OnMncCijenaDoTextEnter(self,
event):######################???
print "test"

And when I Enter any number it won't catch the test text.

I don't get it.

I need that when the user types in a number and confirmes it with
enter, the Eventhandler get's done. I think that I got the right event
but it just wont work.

any idea?

azrael wrote:

I have a masked number control and method binded to it

self.mncCijenaDo = wx.lib.masked.numctrl.NumCtrl
(id=wxID_FRMMAINMNCCIJENADO,
              name='mncCijenaDo', parent=self.pnlFilteri, pos=wx.Point
(395,
              215), size=wx.Size(127, 22), style=0, value=0)
        self.mncCijenaDo.SetDecimalChar('.')
        self.mncCijenaDo.SetFractionWidth(2)
        self.mncCijenaDo.Enable(False)
        self.mncCijenaDo.Bind(wx.EVT_TEXT_ENTER,
self.OnMncCijenaDoTextEnter, self.mncCijenaDo)

def OnMncCijenaDoTextEnter(self,
event):######################???
        print "test"

And when I Enter any number it won't catch the test text.

Hi azrael

I don't have an answer, I am afraid, but I have a couple of clues.

1. 'self.mncCijenaDo.Enable(False)'? I assume this is just for testing.

2. From the wx.widgets docs for EVT_TEXT_ENTER -
     "Respond to a wx.EVT_COMMAND_TEXT_ENTER event, generated when enter is
pressed in a text
      control (which must have wx.TE_PROCESS_ENTER style for this event to
be generated)."

   Your sample code does not have this style. This could be part of the
problem.

3. From the documentation in maskededit.py, which is a mixin for NumCtrl -
     "Event handlers are "chained", and MaskedEditMixin usually swallows
most of the
      events it sees, thereby preventing any other handlers from firing in
the chain."

4. maskededit.py has its own handler for wx.WXK_RETURN, which looks like
this -
    def _OnReturn(self, event):
         """
         Swallows the return, issues a Navigate event instead, since
         masked controls are "single line" by defn.
         """
         self.Navigate(True)
         return False

    As you can see, this swallows the Enter key and does not allow the
EVT_TEXT_ENTER handler to run.

    I proved this by adding 'event.Skip() to the above (before 'return
False') and then your message
    'test' does appear. However, I have no idea of the implications, so I
doubt if it would be
    advisable for you to modify maskededit.py like this.

5. The documentation in maskededit.py, under the subheading 'Event
Handling', seems to allow you to
override some of its event handlers. It refers to EVT_TEXT, but not to
EVT_TEXT_ENTER. I did not
really understand it, but if you can figure it out, you may be able to get
it to do what you want.

HTH

Frank Millman