Trying to capture 'Enter' key press for wxChoice

Is it possible to capture the user hitting the 'Enter' key when focus is on the wxChoice widget?

Any advice would be greatly appreciated.

from wxPython.wx import *

···

#---------------------------------------------------------------------------

class TestChoice(wxPanel):
     def __init__(self, parent, log):
         #self.log = log
         wxPanel.__init__(self, parent, -1)

         sampleList = ['zero', 'one', 'two', 'three', 'four', 'five',
                       'six', 'seven', 'eight']

         wxStaticText(self, -1, "Select one:", wxPoint(15, 50), wxSize(75, 20))
         self.ch = wxChoice(self, 40, (80, 50), choices = sampleList,style=wxTE_PROCESS_ENTER)
         self.ch2 = wxChoice(self, 41, (80, 80), choices = sampleList)
         #EVT_TEXT_ENTER(self, 40, self.EvtChange)
         #EVT_TEXT_ENTER(self, 41, self.EvtChange)

         EVT_CHOICE(self, 40, self.EvtChoice)
         EVT_CHOICE(self, 41, self.EvtChoice)
         #EVT_TEXT(self, 40, self.EvtChange)
         #EVT_TEXT(self, 41, self.EvtChange)

     def EvtChoice(self, event):
         print 'in EvtChoice'

         event.Skip()

     def EvtEnter(self, event):
         print 'in EvtEnter'

     def EvtChange(self, event):
         print 'in EvtChange'

if __name__ == '__main__':

     app = wxPySimpleApp()
     frame = wxFrame(None, -1, "The Title")
     nb = TestChoice(frame, None)

     frame.Show(true)
     app.MainLoop()

You just attach an ON_KEY_DOWN(<parent>,<callback>) handler; then, in the handler, you test
if the evt.GetKey()==<whatever Enter KEY_CODE is>, then you call evt.Skip() to let the event
propagate on through other key event handlers. Hope that helps.
Charles Cosse

Michael Beaulieu wrote:

···

Is it possible to capture the user hitting the 'Enter' key when focus is on the wxChoice widget?

Any advice would be greatly appreciated.

from wxPython.wx import *

#---------------------------------------------------------------------------

class TestChoice(wxPanel):
    def __init__(self, parent, log):
        #self.log = log
        wxPanel.__init__(self, parent, -1)

        sampleList = ['zero', 'one', 'two', 'three', 'four', 'five',
                      'six', 'seven', 'eight']

        wxStaticText(self, -1, "Select one:", wxPoint(15, 50), wxSize(75, 20))
        self.ch = wxChoice(self, 40, (80, 50), choices = sampleList,style=wxTE_PROCESS_ENTER)
        self.ch2 = wxChoice(self, 41, (80, 80), choices = sampleList)
        #EVT_TEXT_ENTER(self, 40, self.EvtChange)
        #EVT_TEXT_ENTER(self, 41, self.EvtChange)

        EVT_CHOICE(self, 40, self.EvtChoice)
        EVT_CHOICE(self, 41, self.EvtChoice)
        #EVT_TEXT(self, 40, self.EvtChange)
        #EVT_TEXT(self, 41, self.EvtChange)

    def EvtChoice(self, event):
        print 'in EvtChoice'

        event.Skip()

    def EvtEnter(self, event):
        print 'in EvtEnter'

    def EvtChange(self, event):
        print 'in EvtChange'

if __name__ == '__main__':

    app = wxPySimpleApp()
    frame = wxFrame(None, -1, "The Title")
    nb = TestChoice(frame, None)

    frame.Show(true)
    app.MainLoop()

---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwidgets.org
For additional commands, e-mail: wxPython-users-help@lists.wxwidgets.org

I had in tried this as well:
EVT_KEY_DOWN(self.ch2, self.EvtChange) but it did not work for me.

  I'm running on Fedora Core2, wx 2.4.2.4, python 2.3.3

ccosse wrote:

···

You just attach an ON_KEY_DOWN(<parent>,<callback>) handler; then, in the handler, you test
if the evt.GetKey()==<whatever Enter KEY_CODE is>, then you call evt.Skip() to let the event
propagate on through other key event handlers. Hope that helps.
Charles Cosse

Michael Beaulieu wrote:

Is it possible to capture the user hitting the 'Enter' key when focus is on the wxChoice widget?

Any advice would be greatly appreciated.

from wxPython.wx import *

#---------------------------------------------------------------------------

class TestChoice(wxPanel):
    def __init__(self, parent, log):
        #self.log = log
        wxPanel.__init__(self, parent, -1)

        sampleList = ['zero', 'one', 'two', 'three', 'four', 'five',
                      'six', 'seven', 'eight']

        wxStaticText(self, -1, "Select one:", wxPoint(15, 50), wxSize(75, 20))
        self.ch = wxChoice(self, 40, (80, 50), choices = sampleList,style=wxTE_PROCESS_ENTER)
        self.ch2 = wxChoice(self, 41, (80, 80), choices = sampleList)
        #EVT_TEXT_ENTER(self, 40, self.EvtChange)
        #EVT_TEXT_ENTER(self, 41, self.EvtChange)

        EVT_CHOICE(self, 40, self.EvtChoice)
        EVT_CHOICE(self, 41, self.EvtChoice)
        #EVT_TEXT(self, 40, self.EvtChange)
        #EVT_TEXT(self, 41, self.EvtChange)

    def EvtChoice(self, event):
        print 'in EvtChoice'

        event.Skip()

    def EvtEnter(self, event):
        print 'in EvtEnter'

    def EvtChange(self, event):
        print 'in EvtChange'

if __name__ == '__main__':

    app = wxPySimpleApp()
    frame = wxFrame(None, -1, "The Title")
    nb = TestChoice(frame, None)

    frame.Show(true)
    app.MainLoop()

---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwidgets.org
For additional commands, e-mail: wxPython-users-help@lists.wxwidgets.org

Hi,

Try this. Create a class for the wxchoice widgets. In this example, only the "Enter" keycode is passed to the parent to process the event.

Derrick

class Choice(wxChoice):
    def __init__(self, parent, id, choices, style):
        wxChoice.__init__(self, parent, id, choices=choices, style=style)

        EVT_CHAR(self, self.onChar)
     def onChar(self, event):
        key = event.KeyCode()
        if key == WXK_RETURN:
            wxPostEvent(self.GetParent(), event)
        else:
            event.Skip()

Michael Beaulieu wrote:

···

I had in tried this as well:
EVT_KEY_DOWN(self.ch2, self.EvtChange) but it did not work for me.

I'm running on Fedora Core2, wx 2.4.2.4, python 2.3.3

ccosse wrote:

You just attach an ON_KEY_DOWN(<parent>,<callback>) handler; then, in the handler, you test
if the evt.GetKey()==<whatever Enter KEY_CODE is>, then you call evt.Skip() to let the event
propagate on through other key event handlers. Hope that helps.
Charles Cosse

Michael Beaulieu wrote:

Is it possible to capture the user hitting the 'Enter' key when focus is on the wxChoice widget?

Any advice would be greatly appreciated.

from wxPython.wx import *

#---------------------------------------------------------------------------

class TestChoice(wxPanel):
    def __init__(self, parent, log):
        #self.log = log
        wxPanel.__init__(self, parent, -1)

        sampleList = ['zero', 'one', 'two', 'three', 'four', 'five',
                      'six', 'seven', 'eight']

        wxStaticText(self, -1, "Select one:", wxPoint(15, 50), wxSize(75, 20))
        self.ch = wxChoice(self, 40, (80, 50), choices = sampleList,style=wxTE_PROCESS_ENTER)
        self.ch2 = wxChoice(self, 41, (80, 80), choices = sampleList)
        #EVT_TEXT_ENTER(self, 40, self.EvtChange)
        #EVT_TEXT_ENTER(self, 41, self.EvtChange)

        EVT_CHOICE(self, 40, self.EvtChoice)
        EVT_CHOICE(self, 41, self.EvtChoice)
        #EVT_TEXT(self, 40, self.EvtChange)
        #EVT_TEXT(self, 41, self.EvtChange)

    def EvtChoice(self, event):
        print 'in EvtChoice'

        event.Skip()

    def EvtEnter(self, event):
        print 'in EvtEnter'

    def EvtChange(self, event):
        print 'in EvtChange'

if __name__ == '__main__':

    app = wxPySimpleApp()
    frame = wxFrame(None, -1, "The Title")
    nb = TestChoice(frame, None)

    frame.Show(true)
    app.MainLoop()

---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwidgets.org
For additional commands, e-mail: wxPython-users-help@lists.wxwidgets.org

---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwidgets.org
For additional commands, e-mail: wxPython-users-help@lists.wxwidgets.org

Thanks Derrick,

I couldn't get this to run on my Linux box but it does work on Windows, which will be good enough for now.

cheers,
Mike

Derrick wrote:

···

Hi,

Try this. Create a class for the wxchoice widgets. In this example, only the "Enter" keycode is passed to the parent to process the event.

Derrick

class Choice(wxChoice):
   def __init__(self, parent, id, choices, style):
       wxChoice.__init__(self, parent, id, choices=choices, style=style)

       EVT_CHAR(self, self.onChar)

   def onChar(self, event):
       key = event.KeyCode()
       if key == WXK_RETURN:
           wxPostEvent(self.GetParent(), event)
       else:
           event.Skip()

Michael Beaulieu wrote:

I had in tried this as well:
EVT_KEY_DOWN(self.ch2, self.EvtChange) but it did not work for me.

I'm running on Fedora Core2, wx 2.4.2.4, python 2.3.3

ccosse wrote:

You just attach an ON_KEY_DOWN(<parent>,<callback>) handler; then, in the handler, you test
if the evt.GetKey()==<whatever Enter KEY_CODE is>, then you call evt.Skip() to let the event
propagate on through other key event handlers. Hope that helps.
Charles Cosse

Michael Beaulieu wrote:

Is it possible to capture the user hitting the 'Enter' key when focus is on the wxChoice widget?

Any advice would be greatly appreciated.

from wxPython.wx import *

#---------------------------------------------------------------------------

class TestChoice(wxPanel):
    def __init__(self, parent, log):
        #self.log = log
        wxPanel.__init__(self, parent, -1)

        sampleList = ['zero', 'one', 'two', 'three', 'four', 'five',
                      'six', 'seven', 'eight']

        wxStaticText(self, -1, "Select one:", wxPoint(15, 50), wxSize(75, 20))
        self.ch = wxChoice(self, 40, (80, 50), choices = sampleList,style=wxTE_PROCESS_ENTER)
        self.ch2 = wxChoice(self, 41, (80, 80), choices = sampleList)
        #EVT_TEXT_ENTER(self, 40, self.EvtChange)
        #EVT_TEXT_ENTER(self, 41, self.EvtChange)

        EVT_CHOICE(self, 40, self.EvtChoice)
        EVT_CHOICE(self, 41, self.EvtChoice)
        #EVT_TEXT(self, 40, self.EvtChange)
        #EVT_TEXT(self, 41, self.EvtChange)

    def EvtChoice(self, event):
        print 'in EvtChoice'

        event.Skip()

    def EvtEnter(self, event):
        print 'in EvtEnter'

    def EvtChange(self, event):
        print 'in EvtChange'

if __name__ == '__main__':

    app = wxPySimpleApp()
    frame = wxFrame(None, -1, "The Title")
    nb = TestChoice(frame, None)

    frame.Show(true)
    app.MainLoop()

---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwidgets.org
For additional commands, e-mail: wxPython-users-help@lists.wxwidgets.org

---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwidgets.org
For additional commands, e-mail: wxPython-users-help@lists.wxwidgets.org

Just installed WxPython v2.5.2.8 for windows.

Can anyone tell me what has happenned to the masked edit controls.
wx/lib/maskededit .py no longer seems to be there and my application no longer functions.
Was previously written in 2.5.1.5

Thanks

Hi Giles,

Haven't upgraded to 2.5 but noticed the other day looking through changes doc that they got moved.

Have a look here, under 2.5.2.7:
http://www.wxpython.org/recentchanges.php

See you
Werner

giles@nw.com.au wrote:

···

Just installed WxPython v2.5.2.8 for windows.

Can anyone tell me what has happenned to the masked edit controls.
wx/lib/maskededit .py no longer seems to be there and my application no longer functions.
Was previously written in 2.5.1.5

Thanks

---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwidgets.org
For additional commands, e-mail: wxPython-users-help@lists.wxwidgets.org

Thanks very much, I missed seeing that bit.
Gary

···

----- Original Message ----- From: "Werner F. Bruhin" <werner.bruhin@free.fr>
To: <wxPython-users@lists.wxwidgets.org>
Sent: Thursday, September 09, 2004 4:34 PM
Subject: Re: [wxPython-users] Re: WxPython 2.5.2.8

Hi Giles,

Haven't upgraded to 2.5 but noticed the other day looking through changes doc that they got moved.

Have a look here, under 2.5.2.7:
http://www.wxpython.org/recentchanges.php

See you
Werner

giles@nw.com.au wrote:

Just installed WxPython v2.5.2.8 for windows.

Can anyone tell me what has happenned to the masked edit controls.
wx/lib/maskededit .py no longer seems to be there and my application no longer functions.
Was previously written in 2.5.1.5

Thanks

---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwidgets.org
For additional commands, e-mail: wxPython-users-help@lists.wxwidgets.org

---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwidgets.org
For additional commands, e-mail: wxPython-users-help@lists.wxwidgets.org

Hi again,

I have implemented all the changes necessary in my application to make it work with 2.5.2.8
I am now faced with the following problems still. (all visual in Windows XP SP2)

1. Most of my page headings are wrapping over 2 lines (used to fit on 1 line)
2. Toolbar only displays the top part of images and has a large blank area below the image, also overlaps the panel below it.
3. WxList control, I use in several places, the first column is always collapsed ???, rest of columns look OK.
4. Some panels overlap panels which are next to them, all panels are in sizers.

I have upgraded from Wx v2.5.1.5.

Has anyone else experienced as many changes in layout, etc. after upgrading.
My application was about 95% complete but now looks like a LOT of work still to be done.

Why has upgrading made such HUGE Layout changes to my application ?

I don't know what to do to correct all the above as the code was all working in 2.5.1.5 and can't see what has changed ?

The reasonI upgraded was after installing Service pack 2 in Windows XP, V2.5.1.5 seemed to stop working and was returning an unknown error when used. Has anyone installed Windows XP SP2 and not had to upgrade their Wx ?

Regards

Gary Giles

···

----- Original Message ----- From: "Werner F. Bruhin" <werner.bruhin@free.fr>
To: <wxPython-users@lists.wxwidgets.org>
Sent: Thursday, September 09, 2004 4:34 PM
Subject: Re: [wxPython-users] Re: WxPython 2.5.2.8

Hi Giles,

Haven't upgraded to 2.5 but noticed the other day looking through changes doc that they got moved.

Have a look here, under 2.5.2.7:
http://www.wxpython.org/recentchanges.php

See you
Werner

giles@nw.com.au wrote:

Just installed WxPython v2.5.2.8 for windows.

Can anyone tell me what has happenned to the masked edit controls.
wx/lib/maskededit .py no longer seems to be there and my application no longer functions.
Was previously written in 2.5.1.5

Thanks

---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwidgets.org
For additional commands, e-mail: wxPython-users-help@lists.wxwidgets.org

---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwidgets.org
For additional commands, e-mail: wxPython-users-help@lists.wxwidgets.org

Is your application OSS ? if so.. is there a CVS server somewhere?

···

On Fri, 10 Sep 2004 16:45:11 +0800, <giles@nw.com.au> wrote:

My application was about 95% complete but now looks like a LOT of work still to be done.

--
Peter Damoc
Hacker Wannabe

giles@nw.com.au wrote:

Hi again,

I have implemented all the changes necessary in my application to make it work with 2.5.2.8
I am now faced with the following problems still. (all visual in Windows XP SP2)

Please be sure to read and understand the Sizers section of the Migration Guide.

1. Most of my page headings are wrapping over 2 lines (used to fit on 1 line)

Please define "page headings." What windows and sizers are involved here?

2. Toolbar only displays the top part of images and has a large blank area below the image, also overlaps the panel below it.

Are the images not a standard size? Do you call toolbar.SetToolBitmapSize? Do you manage the layout of the toolbar yourself with a sizer or let the frame do it?

3. WxList control, I use in several places, the first column is always collapsed ???, rest of columns look OK.

How do you create the list ctrl and the first column? Do you autosize the first column?

4. Some panels overlap panels which are next to them, all panels are in sizers.

Without more info about how you create the panels and sizers we can't help much, except to say to read the Migration Guide again.

···

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

I need to display Pie & Bar graphs (and optionally the raw data in column format) on the screen and then have an option to print them out.

Can you tell me what is being used to accomplish this with.

Are there any easy to use charting plug-ins for WX that can easily display & print without having to duplicate the chart construction process.

Regards

Gary