wx.EVT_TEXT_ENTER()

Hi,

I'm having a problem submiting text from a wx.TextCtril() I have the following lines in my code...

        self.control1 = wx.TextCtrl(self, -1, "", wx.DLG_PNT(self, 190,122), wx.DLG_SZE(self, 640, 1), style=wx.TE_PROCESS_ENTER | wx.TE_DONTWRAP)

and

        wx.EVT_TEXT_ENTER(self.control1, -1, self.killProcs(list))

The code loads without error, but before you can type and hit enter, the wx.EVT_TEXT_ENTER() runs the killProcs() function. (I know because I have killProcs output text to a different wx.TextCtrl box.

I thought wx.EVT_TEXT_ENTER() wouldn't execute until "enter" had been pressed while this TextCtrl had focus?

Sample code seems extremely hard to come by. Blind trial and error and this medium are the only ways I'm making any headway :frowning:

Dave

Junk wrote:

Hi,

I'm having a problem submiting text from a wx.TextCtril() I have the following lines in my code...

       self.control1 = wx.TextCtrl(self, -1, "", wx.DLG_PNT(self, 190,122), wx.DLG_SZE(self, 640, 1), style=wx.TE_PROCESS_ENTER | wx.TE_DONTWRAP)

and

       wx.EVT_TEXT_ENTER(self.control1, -1, self.killProcs(list))

The code loads without error, but before you can type and hit enter, the wx.EVT_TEXT_ENTER() runs the killProcs() function. (I know because I have killProcs output text to a different wx.TextCtrl box.

I thought wx.EVT_TEXT_ENTER() wouldn't execute until "enter" had been pressed while this TextCtrl had focus?

Yes, that is the way it is supposed to work. Please duplicate this problem in a small sample and send it here. Also report your platform and version.

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

Robin Dunn wrote:

Junk wrote:

Hi,

I'm having a problem submiting text from a wx.TextCtril() I have the following lines in my code...

       self.control1 = wx.TextCtrl(self, -1, "", wx.DLG_PNT(self, 190,122), wx.DLG_SZE(self, 640, 1), style=wx.TE_PROCESS_ENTER | wx.TE_DONTWRAP)

and

       wx.EVT_TEXT_ENTER(self.control1, -1, self.killProcs(list))

The code loads without error, but before you can type and hit enter, the wx.EVT_TEXT_ENTER() runs the killProcs() function. (I know because I have killProcs output text to a different wx.TextCtrl box.

I thought wx.EVT_TEXT_ENTER() wouldn't execute until "enter" had been pressed while this TextCtrl had focus?

Yes, that is the way it is supposed to work. Please duplicate this problem in a small sample and send it here. Also report your platform and version.

It sure looks to me like "self.killProcs(list)" would run self.killProcs, and then whatever is returned is passed to EVT_TEXT_ENTER.

What you need is a simpler function like this:

def killProcs(self, list):
  # This one doesn't change

def onKillProcs(self, event):
  # This is just a wrapper for the other one
  self.killProcs(self.killProcsList)

self.killProcsList = list
wx.EVT_TEXT_ENTER(self.control1, -1, self.onKillProcs)

Now when Enter is pressed, it will send the event to onKillProcs, which then calls self.killProcs. You need to keep the list somewhere such that "onKillProcs" has access to it.

John
=:->

John Meinel wrote:

Robin Dunn wrote:

Junk wrote:

Hi,

I'm having a problem submiting text from a wx.TextCtril() I have the following lines in my code...

       self.control1 = wx.TextCtrl(self, -1, "", wx.DLG_PNT(self, 190,122), wx.DLG_SZE(self, 640, 1), style=wx.TE_PROCESS_ENTER | wx.TE_DONTWRAP)

and

       wx.EVT_TEXT_ENTER(self.control1, -1, self.killProcs(list))

The code loads without error, but before you can type and hit enter, the wx.EVT_TEXT_ENTER() runs the killProcs() function. (I know because I have killProcs output text to a different wx.TextCtrl box.

I thought wx.EVT_TEXT_ENTER() wouldn't execute until "enter" had been pressed while this TextCtrl had focus?

Yes, that is the way it is supposed to work. Please duplicate this problem in a small sample and send it here. Also report your platform and version.

It sure looks to me like "self.killProcs(list)" would run self.killProcs, and then whatever is returned is passed to EVT_TEXT_ENTER.

Oops, thanks for spotting that.

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!