Converting the text in a TextCtrl?

Hi,

I’m trying trying to write an event that will convert a full url entered into a TextCtrl into just the domain. I’m running in recursion problems though.

Right now I’m using EVT_TEXT to call my handler.

def onText():
domain = urlparse(self.url.GetValue())[1]
self.url.SetValue(domain)

I guess it’s trying to run the event before the whole domain has been entered. How do I do this without running into the recursion problem?

Thanks!

Try binding EVT_TEXT_ENTER or EVT_KILL_FOCUS instead.

···

On Wed, Oct 8, 2008 at 3:57 PM, Erik Wickstrom erik@erikwickstrom.com wrote:

Hi,

I’m trying trying to write an event that will convert a full url entered into a TextCtrl into just the domain. I’m running in recursion problems though.

Right now I’m using EVT_TEXT to call my handler.

def onText():
domain = urlparse(self.url.GetValue())[1]
self.url.SetValue(domain)

I guess it’s trying to run the event before the whole domain has been entered. How do I do this without running into the recursion problem?

Thanks!


wxpython-users mailing list

wxpython-users@lists.wxwidgets.org

http://lists.wxwidgets.org/mailman/listinfo/wxpython-users

Aha! I’ve been meaning to ask about a similar problem with the FileBrowseButton - works just fine if you browse, but if you try to type the filename it reacts to one character at a time. Now I see what to overload (although it seems like a bug in the widget to me…)

···

On Wed, Oct 8, 2008 at 4:02 PM, Nathaniel Echols nathaniel.echols@gmail.com wrote:

Try binding EVT_TEXT_ENTER or EVT_KILL_FOCUS instead.

On Wed, Oct 8, 2008 at 3:57 PM, Erik Wickstrom erik@erikwickstrom.com wrote:

Hi,

I’m trying trying to write an event that will convert a full url entered into a TextCtrl into just the domain. I’m running in recursion problems though.

Right now I’m using EVT_TEXT to call my handler.

def onText():
domain = urlparse(self.url.GetValue())[1]
self.url.SetValue(domain)

I guess it’s trying to run the event before the whole domain has been entered. How do I do this without running into the recursion problem?


www.fsrtechnologies.com

I tried both and the event doesn’t seem to fire. With EVT_TEXT_ENTER I’m tyring pressing the enter key in the field. With EVT_KILL_FOCES I’m tabbing out…

···

On Wed, Oct 8, 2008 at 4:02 PM, Nathaniel Echols nathaniel.echols@gmail.com wrote:

Try binding EVT_TEXT_ENTER or EVT_KILL_FOCUS instead.

On Wed, Oct 8, 2008 at 3:57 PM, Erik Wickstrom erik@erikwickstrom.com wrote:

Hi,

I’m trying trying to write an event that will convert a full url entered into a TextCtrl into just the domain. I’m running in recursion problems though.

Right now I’m using EVT_TEXT to call my handler.

def onText():
domain = urlparse(self.url.GetValue())[1]
self.url.SetValue(domain)

I guess it’s trying to run the event before the whole domain has been entered. How do I do this without running into the recursion problem?

Thanks!


wxpython-users mailing list

wxpython-users@lists.wxwidgets.org

http://lists.wxwidgets.org/mailman/listinfo/wxpython-users


wxpython-users mailing list

wxpython-users@lists.wxwidgets.org

http://lists.wxwidgets.org/mailman/listinfo/wxpython-users

It may depend on which control is binding the events. Did you try both

panel.Bind(wx.EVT_TEXT_ENTER, panel.OnUpdate, my_text_ctrl)

and

my_text_ctrl.Bind(wx.EVT_TEXT_ENTER, my_text_ctrl.OnUpdate)

This can sometimes make a difference. (Unfortunately, I’m not sure which way is more appropriate. But I definitely process EVT_TEXT_ENTER events sent to a MiniFrame with no problem. . .)

···

On Wed, Oct 8, 2008 at 6:15 PM, Erik Wickstrom erik@erikwickstrom.com wrote:

I tried both and the event doesn’t seem to fire. With EVT_TEXT_ENTER I’m tyring pressing the enter key in the field. With EVT_KILL_FOCES I’m tabbing out…

On Wed, Oct 8, 2008 at 4:02 PM, Nathaniel Echols nathaniel.echols@gmail.com wrote:

Try binding EVT_TEXT_ENTER or EVT_KILL_FOCUS instead.

On Wed, Oct 8, 2008 at 3:57 PM, Erik Wickstrom erik@erikwickstrom.com wrote:

Hi,

I’m trying trying to write an event that will convert a full url entered into a TextCtrl into just the domain. I’m running in recursion problems though.

Right now I’m using EVT_TEXT to call my handler.

def onText():
domain = urlparse(self.url.GetValue())[1]
self.url.SetValue(domain)

I guess it’s trying to run the event before the whole domain has been entered. How do I do this without running into the recursion problem?

Thanks!


wxpython-users mailing list

wxpython-users@lists.wxwidgets.org

http://lists.wxwidgets.org/mailman/listinfo/wxpython-users


wxpython-users mailing list

wxpython-users@lists.wxwidgets.org

http://lists.wxwidgets.org/mailman/listinfo/wxpython-users


wxpython-users mailing list

wxpython-users@lists.wxwidgets.org

http://lists.wxwidgets.org/mailman/listinfo/wxpython-users

Erik Wickstrom wrote:

Hi,

I'm trying trying to write an event that will convert a full url entered into a TextCtrl into just the domain. I'm running in recursion problems though.

Right now I'm using EVT_TEXT to call my handler.

def onText():
  domain = urlparse(self.url.GetValue())[1]
  self.url.SetValue(domain)

I guess it's trying to run the event before the whole domain has been entered. How do I do this without running into the recursion problem?

The recursion problem comes from the fact that SetValue will generate another EVT_TEXT before the SetValue returns. You can use ChangeValue instead to avoid that, but do you really want to execute this code for every character typed?

···

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

I wouldn’t presume to answer for the OP, but in my case (which seems to be the same) the answer is NO - I wish to process the event only after all desired text has been entered.

···

On Wed, Oct 8, 2008 at 9:49 PM, Robin Dunn robin@alldunn.com wrote:

The recursion problem comes from the fact that SetValue will generate another EVT_TEXT before the SetValue returns. You can use ChangeValue instead to avoid that, but do you really want to execute this code for every character typed?


www.fsrtechnologies.com