custom slider and register events

This is my try for creating custom widget. I am trying to create a custom slider. It’s working fine but I am not able to set wx.CommandEvent for
various stats(LEFT_UP, LEFT_DOWN, MOTION etc.)

I have used wx.PyPanel for making the slider. Is it OK? or what ever I have done, I mean look wise can be done If I subclass wx.Slider for making
a custom slider

Thanks

slider.zip (2.52 KB)

Hello,

This is my try for creating custom widget. I am trying to create a custom slider. It’s working fine but I am not able to set wx.CommandEvent for
various stats(LEFT_UP, LEFT_DOWN, MOTION etc.)

  1. When constructing an event object you need to pass an event type (i.e wx.wxEVT_, not wx.EVT_),

See line 80 in your sample.

  1. You are rebinding EVT_LEFT_UP in your Frame and not skipping the event so it doesn’t propagate down to your other handler inside your slider class.

  2. I think you want to check for HasCapture instead of GetCapture.

···

On 8/6/08, Prashant Saxena animator333@yahoo.com wrote:

I have used wx.PyPanel for making the slider. Is it OK? or what ever I have done, I mean look wise can be done If I subclass wx.Slider for making
a custom slider

Thanks


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

Cody,

Does every Event (e.g., wx.EVT_*) have an EventType analog (e.g.,
wx.wxEVT_*) If so, where do I find them?

I'm trying to create a Notebook event for a unittest, but
wx.wxEVT_NOTEBOOK_PAGE_CHANGED doesn't appeart to exist.

···

On Wed, Aug 6, 2008 at 11:29 AM, Cody Precord <codyprecord@gmail.com> wrote:

1) When constructing an event object you need to pass an event type (i.e
wx.wxEVT_*, not wx.EVT_*),
See line 80 in your sample.

--
Stand Fast,
tjg. [Timothy Grant]

Hello,

  1. When constructing an event object you need to pass an event type (i.e
    wx.wxEVT_, not wx.EVT_),
    See line 80 in your sample.

Cody,

Does every Event (e.g., wx.EVT_*) have an EventType analog (e.g.,

wx.wxEVT_*) If so, where do I find them?

I’m trying to create a Notebook event for a unittest, but
wx.wxEVT_NOTEBOOK_PAGE_CHANGED doesn’t appeart to exist.

If they are a command event (notebook commands are) they typically are as follows

wx.wxEVT_COMMAND_*

Most/all events should have an associated event type though they are not always named in a predictable manner. I am sure they are in the documentation somewhere. But I typically just do something like the following in a python shell to find what I am looking for,

for x in dir(wx):

if ‘NOTEBOOK_PAGE_CHANGED’ in x:

print x

You should see a wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED in there

Regards,

Cody

···

On 8/6/08, Timothy Grant timothy.grant@gmail.com wrote:

On Wed, Aug 6, 2008 at 11:29 AM, Cody Precord codyprecord@gmail.com wrote:

Thanks Cody,

I appreciate your help.

···

On Wed, Aug 6, 2008 at 12:32 PM, Cody Precord <codyprecord@gmail.com> wrote:

Hello,

On 8/6/08, Timothy Grant <timothy.grant@gmail.com> wrote:

On Wed, Aug 6, 2008 at 11:29 AM, Cody Precord <codyprecord@gmail.com> >> wrote:
>
> 1) When constructing an event object you need to pass an event type (i.e
> wx.wxEVT_*, not wx.EVT_*),
> See line 80 in your sample.

Cody,

Does every Event (e.g., wx.EVT_*) have an EventType analog (e.g.,
wx.wxEVT_*) If so, where do I find them?

I'm trying to create a Notebook event for a unittest, but
wx.wxEVT_NOTEBOOK_PAGE_CHANGED doesn't appeart to exist.

If they are a command event (notebook commands are) they typically are as
follows

wx.wxEVT_COMMAND_*

Most/all events should have an associated event type though they are not
always named in a predictable manner. I am sure they are in the
documentation somewhere. But I typically just do something like the
following in a python shell to find what I am looking for,

for x in dir(wx):
    if 'NOTEBOOK_PAGE_CHANGED' in x:
        print x

You should see a wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED in there

Regards,
Cody

--
Stand Fast,
tjg. [Timothy Grant]

Cody Precord wrote:

Hello,

     >
     > 1) When constructing an event object you need to pass an event
    type (i.e
     > wx.wxEVT_*, not wx.EVT_*),
     > See line 80 in your sample.

    Cody,

    Does every Event (e.g., wx.EVT_*) have an EventType analog (e.g.,
    wx.wxEVT_*) If so, where do I find them?

    I'm trying to create a Notebook event for a unittest, but
    wx.wxEVT_NOTEBOOK_PAGE_CHANGED doesn't appeart to exist.

If they are a command event (notebook commands are) they typically are as follows
wx.wxEVT_COMMAND_*
Most/all events should have an associated event type though they are not always named in a predictable manner. I am sure they are in the documentation somewhere. But I typically just do something like the following in a python shell to find what I am looking for,
for x in dir(wx):
    if 'NOTEBOOK_PAGE_CHANGED' in x:
        print x
You should see a wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED in there

If you don't care what the actual name of the eventType is then there is a shortcut to get the value using the binder object. They have a typeId property that returns the value. As you can see here it is the same as the wxEVT_* version:

  >>> import wx
  >>> wx.EVT_NOTEBOOK_PAGE_CHANGED.typeId
  10125
  >>>
  >>> wx.wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED
  10125
  >>>

Some events are composites of other events, (EVT_MOUSE_EVENTS and EVT_SCROLL for example) so there is also another attribute that is a list of eventType ID values:

  >>> wx.EVT_NOTEBOOK_PAGE_CHANGED.evtType
  [10125]
  >>> wx.EVT_SCROLL.evtType
  [10055, 10056, 10057, 10058, 10059, 10060, 10061, 10062, 10063]

···

On 8/6/08, *Timothy Grant* <timothy.grant@gmail.com > <mailto:timothy.grant@gmail.com>> wrote:
    On Wed, Aug 6, 2008 at 11:29 AM, Cody Precord <codyprecord@gmail.com > <mailto:codyprecord@gmail.com>> wrote:

  >>>

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