key event and TextCntrl

I try to submit textcntrl on press enter I used this code :

cnrl=wx.TextCtrl(search, 11, ‘’, (20, 5), (120, 20))

def OnKeyDown(self, event):
keycode = event.GetKeyCode()

I try to textcntrl do something on press enter I try to use this code :

cnrl=wx.TextCtrl(search, 11, ‘’, (20, 5), (120, 20))

wx.Button(search, 12 , “Go”, (140, 5), (30, 18))
cnrl.Bind(wx.EVT_KEY_DOWN, self.OnKeyDown)

def OnKeyDown(self, event):
global cnrl, frame
keycode = event.GetKeyCode()

    print keycode

and I discovered that wx automatically replace the focus with the wx.Button on pressing enter and ignore the keypress.
how can I solve that?

thanks!

Hello,

Use wx.TextCtrl(...., style=wx.TE_PROCESS_ENTER) and wx.EVT_TEXT_ENTER

···

On Oct 11, 2008, at 10:58 AM, יהודה wrote:

I try to textcntrl do something on press enter I try to use this code :

cnrl=wx.TextCtrl(search, 11, '', (20, 5), (120, 20))
    wx.Button(search, 12 , "Go", (140, 5), (30, 18))
    cnrl.Bind(wx.EVT_KEY_DOWN, self.OnKeyDown)

def OnKeyDown(self, event):
        global cnrl, frame
        keycode = event.GetKeyCode()
        print keycode

and I discovered that wx automatically replace the focus with the wx.Button on pressing enter and ignore the keypress.
how can I solve that?

thanks!

_______________________________________________
wxpython-users mailing list
wxpython-users@lists.wxwidgets.org
http://lists.wxwidgets.org/mailman/listinfo/wxpython-users

cool thanks!

:slight_smile:

···

On Sat, Oct 11, 2008 at 6:42 PM, Cody Precord codyprecord@gmail.com wrote:

Hello,

Use wx.TextCtrl(…, style=wx.TE_PROCESS_ENTER) and wx.EVT_TEXT_ENTER

On Oct 11, 2008, at 10:58 AM, יהודה wrote:

I try to textcntrl do something on press enter I try to use this code :

cnrl=wx.TextCtrl(search, 11, ‘’, (20, 5), (120, 20))

wx.Button(search, 12 , "Go", (140, 5), (30, 18))

cnrl.Bind(wx.EVT_KEY_DOWN, self.OnKeyDown)

def OnKeyDown(self, event):

    global cnrl, frame

    keycode = event.GetKeyCode()

    print keycode

and I discovered that wx automatically replace the focus with the wx.Button on pressing enter and ignore the keypress.

how can I solve that?

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


http://kaze.co.il
יש קצה חוט לרעיון שלך