Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

wx.EVNT_TEXT_ENTER in wx.ComboBox

Help
2009-02-03
2013-05-01
  • Serge GAUTHIER
    Serge GAUTHIER
    2009-02-03

    Hi,
    I use Boa Constructor with Python 2.5 and wxPython 2.8.7 and I am not able to use the wx.EVNT_TEXT_ENTER event on wx.ComboBox. No event appends in debug mode. 
    I would like to know when the Enter key is pressed.
    Thanks
    Serge 

     
    • Serge,

      I see the same problem in the wxPython demo for the combobox.  So, for some reason this event does not work.  Maybe check on the wxPython list?

      Werner

       
      • Chelonian
        Chelonian
        2009-02-04

        The key here is to include the flag wx.TE_PROCESS_ENTER in your constructor for the comboBox.  See this thread:

        http://lists.wxwidgets.org/pipermail/wxpython-users/2007-May/064268.html

        Unfortunately Boa doesn't provide this choice in the style menu in the Inspector for some reason--so you just have to add it manually.

        Anyway, code below works:

        #Boa:Frame:Frame1

        import wx

        def create(parent):
            return Frame1(parent)

        [wxID_FRAME1, wxID_FRAME1COMBOBOX1, wxID_FRAME1PANEL1,
        ] = [wx.NewId() for _init_ctrls in range(3)]

        class Frame1(wx.Frame):
            def _init_coll_boxSizer1_Items(self, parent):
                # generated method, don't edit

                parent.AddWindow(self.comboBox1, 0, border=0, flag=0)

            def _init_sizers(self):
                # generated method, don't edit
                self.boxSizer1 = wx.BoxSizer(orient=wx.VERTICAL)

                self._init_coll_boxSizer1_Items(self.boxSizer1)

                self.panel1.SetSizer(self.boxSizer1)

            def _init_ctrls(self, prnt):
                # generated method, don't edit
                wx.Frame.__init__(self, id=wxID_FRAME1, name='', parent=prnt,
                      pos=wx.Point(308, 142), size=wx.Size(405, 489),
                      style=wx.DEFAULT_FRAME_STYLE, title='Frame1')
                self.SetClientSize(wx.Size(397, 455))

                self.panel1 = wx.Panel(id=wxID_FRAME1PANEL1, name='panel1', parent=self,
                      pos=wx.Point(0, 0), size=wx.Size(397, 455),
                      style=wx.TAB_TRAVERSAL)

                self.comboBox1 = wx.ComboBox(choices=["one", "two", "three"],
                      id=wxID_FRAME1COMBOBOX1, name='comboBox1', parent=self.panel1,
                      pos=wx.Point(0, 0), size=wx.Size(130, 21),
                      style=wx.TE_PROCESS_ENTER, value='comboBox1')
                self.comboBox1.Bind(wx.EVT_TEXT_ENTER, self.OnComboBox1TextEnter,
                      id=wxID_FRAME1COMBOBOX1)

                self._init_sizers()

            def __init__(self, parent):
                self._init_ctrls(parent)

            def OnComboBox1TextEnter(self, event):
                text = self.comboBox1.GetValue()
                message = "You entered on the word: " + text
                dlg = wx.MessageDialog(self, message, 'Caption', wx.OK | wx.ICON_INFORMATION)
                try:
                    result = dlg.ShowModal()
                finally:
                    dlg.Destroy()
                event.Skip()

        if __name__ == '__main__':
            app = wx.PySimpleApp()
            frame = create(None)
            frame.Show()

            app.MainLoop()

         
    • Barton Cline
      Barton Cline
      2009-02-17

      I've whipped up a patch - Hopefully, your connected to the CVS:
      After I do some of my own testing, I'll contact RB to see about applying it.

      BasicCompanions.py.patch

      Index: BasicCompanions.py

      RCS file: /cvsroot/boa-constructor/boa/Companions/BasicCompanions.py,v
      retrieving revision 1.21
      diff -u -r1.21 BasicCompanions.py
      --- BasicCompanions.py    2 Jul 2007 15:01:08 -0000    1.21
      +++ BasicCompanions.py    17 Feb 2009 04:42:28 -0000
      @@ -50,7 +50,7 @@
           def __init__(self, name, designer, parent, ctrlClass):
               ChoicedDTC.__init__(self, name, designer, parent, ctrlClass)
               self.windowStyles = ['wx.CB_SIMPLE', 'wx.CB_DROPDOWN', 'wx.CB_READONLY',
      -                             'wx.CB_SORT'] + self.windowStyles
      +                             'wx.CB_SORT', 'wx.TE_PROCESS_ENTER'] + self.windowStyles

           def constructor(self):
               return {'Value': 'value', 'Position': 'pos', 'Size': 'size',