wx.Panel.OnPaint doesn't exist on Linux?

This is freaking me out. I installed wxPython on an Ubuntu system, and
it seems that `wx.Panel` doesn't have an `OnPaint` method. (I get an
`AttributeError`.)

This method does exist on Windows. I have subclassed `Panel`, and I
override `OnPaint` from which I call `Panel.OnPaint`. What am I
supposed to do?

Ram.

···

--
To unsubscribe, send email to wxPython-users+unsubscribe@googlegroups.com
or visit http://groups.google.com/group/wxPython-users?hl=en

Hi,

This is freaking me out. I installed wxPython on an Ubuntu system, and
it seems that `wx.Panel` doesn't have an `OnPaint` method. (I get an
`AttributeError`.)

This method does exist on Windows. I have subclassed `Panel`, and I
override `OnPaint` from which I call `Panel.OnPaint`. What am I
supposed to do?

Are you binding an event handler to that method, i.e.:

self.Bind(wx.EVT_PAINT, self.OnPaint)

? If not, you have to do it. The fact that that particular method
exists on Windows does not guarantee it exists on other platforms, and
it is always good practice to bind an event handler if you are going
to draw yourself the panel content.

Andrea.

"Imagination Is The Only Weapon In The War Against Reality."
http://xoomer.alice.it/infinity77/

==> Never *EVER* use RemovalGroup for your house removal. You'll
regret it forever.
The Doomed City: Removal Group: the nightmare <==

···

On 18 April 2010 17:47, cool-RR wrote:

--
To unsubscribe, send email to wxPython-users+unsubscribe@googlegroups.com
or visit http://groups.google.com/group/wxPython-users?hl=en

Yes, I am binding `EVT_PAINT` to my own handler, `MyWidget.on_paint`,
from which I intend to call `Panel.OnPaint`. What am I supposed to do?

Ram.

···

On Sun, Apr 18, 2010 at 6:55 PM, Andrea Gavana <andrea.gavana@gmail.com> wrote:

Hi,

On 18 April 2010 17:47, cool-RR wrote:

This is freaking me out. I installed wxPython on an Ubuntu system, and
it seems that `wx.Panel` doesn't have an `OnPaint` method. (I get an
`AttributeError`.)

This method does exist on Windows. I have subclassed `Panel`, and I
override `OnPaint` from which I call `Panel.OnPaint`. What am I
supposed to do?

Are you binding an event handler to that method, i.e.:

self.Bind(wx.EVT_PAINT, self.OnPaint)

? If not, you have to do it. The fact that that particular method
exists on Windows does not guarantee it exists on other platforms, and
it is always good practice to bind an event handler if you are going
to draw yourself the panel content.

Andrea.

--
To unsubscribe, send email to wxPython-users+unsubscribe@googlegroups.com
or visit http://groups.google.com/group/wxPython-users?hl=en

Hi,

Hi,

This is freaking me out. I installed wxPython on an Ubuntu system, and
it seems that `wx.Panel` doesn't have an `OnPaint` method. (I get an
`AttributeError`.)

This method does exist on Windows. I have subclassed `Panel`, and I
override `OnPaint` from which I call `Panel.OnPaint`. What am I
supposed to do?

Are you binding an event handler to that method, i.e.:

self.Bind(wx.EVT_PAINT, self.OnPaint)

? If not, you have to do it. The fact that that particular method
exists on Windows does not guarantee it exists on other platforms, and
it is always good practice to bind an event handler if you are going
to draw yourself the panel content.

Andrea.

Yes, I am binding `EVT_PAINT` to my own handler, `MyWidget.on_paint`,
from which I intend to call `Panel.OnPaint`. What am I supposed to do?

You should not call `Panel.OnPaint`: just add an `event.Skip()` in
your `on_paint` handler just before doing anything else: this should
ensure that the default drawing stuff for the platform is called,
although I don't understand why you want to run the default paint
handler while you are handling the paint event yourself.

Andrea.

"Imagination Is The Only Weapon In The War Against Reality."
http://xoomer.alice.it/infinity77/

==> Never *EVER* use RemovalGroup for your house removal. You'll
regret it forever.
The Doomed City: Removal Group: the nightmare <==

···

On 18 April 2010 18:11, cool-RR wrote:

On Sun, Apr 18, 2010 at 6:55 PM, Andrea Gavana <andrea.gavana@gmail.com> wrote:

On 18 April 2010 17:47, cool-RR wrote:

--
To unsubscribe, send email to wxPython-users+unsubscribe@googlegroups.com
or visit http://groups.google.com/group/wxPython-users?hl=en

Are you sure it’s right? I mean, if I subclass Panel and bind EVT_PAINT to my own handler, won’t it cancel the binding to the original handler?

I’ll explain a bit more about what I’m doing. In my paint handler I check whether some buttons need to be disabled/enabled, and a few other things like that. Then I disable/enable the buttons as needed, and call the original paint handler with the event.

Is there any cross-platform way to call the event handler?

Ram.

···

On Sun, Apr 18, 2010 at 7:20 PM, Andrea Gavana andrea.gavana@gmail.com wrote:

Hi,

On 18 April 2010 18:11, cool-RR wrote:

On Sun, Apr 18, 2010 at 6:55 PM, Andrea Gavana andrea.gavana@gmail.com wrote:

Hi,

On 18 April 2010 17:47, cool-RR wrote:

This is freaking me out. I installed wxPython on an Ubuntu system, and

it seems that wx.Panel doesn’t have an OnPaint method. (I get an

AttributeError.)

This method does exist on Windows. I have subclassed Panel, and I

override OnPaint from which I call Panel.OnPaint. What am I

supposed to do?

Are you binding an event handler to that method, i.e.:

self.Bind(wx.EVT_PAINT, self.OnPaint)

? If not, you have to do it. The fact that that particular method

exists on Windows does not guarantee it exists on other platforms, and

it is always good practice to bind an event handler if you are going

to draw yourself the panel content.

Andrea.

Yes, I am binding EVT_PAINT to my own handler, MyWidget.on_paint,

from which I intend to call Panel.OnPaint. What am I supposed to do?

You should not call Panel.OnPaint: just add an event.Skip() in

your on_paint handler just before doing anything else: this should

ensure that the default drawing stuff for the platform is called,

although I don’t understand why you want to run the default paint

handler while you are handling the paint event yourself.

Andrea.

To unsubscribe, send email to wxPython-users+unsubscribe@googlegroups.com

or visit http://groups.google.com/group/wxPython-users?hl=en

Hi,

Hi,

>> Hi,
>>
>>> This is freaking me out. I installed wxPython on an Ubuntu system, and
>>> it seems that `wx.Panel` doesn't have an `OnPaint` method. (I get an
>>> `AttributeError`.)
>>>
>>> This method does exist on Windows. I have subclassed `Panel`, and I
>>> override `OnPaint` from which I call `Panel.OnPaint`. What am I
>>> supposed to do?
>>
>> Are you binding an event handler to that method, i.e.:
>>
>> self.Bind(wx.EVT_PAINT, self.OnPaint)
>>
>> ? If not, you have to do it. The fact that that particular method
>> exists on Windows does not guarantee it exists on other platforms, and
>> it is always good practice to bind an event handler if you are going
>> to draw yourself the panel content.
>>
>> Andrea.
>
> Yes, I am binding `EVT_PAINT` to my own handler, `MyWidget.on_paint`,
> from which I intend to call `Panel.OnPaint`. What am I supposed to do?

You should not call `Panel.OnPaint`: just add an `event.Skip()` in
your `on_paint` handler just before doing anything else: this should
ensure that the default drawing stuff for the platform is called,
although I don't understand why you want to run the default paint
handler while you are handling the paint event yourself.

Andrea.

Are you sure it's right? I mean, if I subclass `Panel` and bind `EVT_PAINT`
to my own handler, won't it cancel the binding to the original handler?
I'll explain a bit more about what I'm doing. In my paint handler I check
whether some buttons need to be disabled/enabled, and a few other things
like that. Then I disable/enable the buttons as needed, and call the
original paint handler with the event.
Is there any cross-platform way to call the event handler?

Yes:

event.Skip()

Andrea.

"Imagination Is The Only Weapon In The War Against Reality."
http://xoomer.alice.it/infinity77/

==> Never *EVER* use RemovalGroup for your house removal. You'll
regret it forever.
The Doomed City: Removal Group: the nightmare <==

···

On 18 April 2010 18:31, cool-RR wrote:

On Sun, Apr 18, 2010 at 7:20 PM, Andrea Gavana <andrea.gavana@gmail.com> > wrote:

On 18 April 2010 18:11, cool-RR wrote:
> On Sun, Apr 18, 2010 at 6:55 PM, Andrea Gavana <andrea.gavana@gmail.com> >> > wrote:
>> On 18 April 2010 17:47, cool-RR wrote:

--
To unsubscribe, send email to wxPython-users+unsubscribe@googlegroups.com
or visit http://groups.google.com/group/wxPython-users?hl=en

I did it and it seems to work. I have no idea why it’s working, but I guess I’ll leave it at that.

Thanks,

Ram.

···

On Sun, Apr 18, 2010 at 7:34 PM, Andrea Gavana andrea.gavana@gmail.com wrote:

You should not call Panel.OnPaint: just add an event.Skip() in

your on_paint handler just before doing anything else: this should

ensure that the default drawing stuff for the platform is called,

although I don’t understand why you want to run the default paint

handler while you are handling the paint event yourself.

Andrea.

Are you sure it’s right? I mean, if I subclass Panel and bind EVT_PAINT

to my own handler, won’t it cancel the binding to the original handler?

I’ll explain a bit more about what I’m doing. In my paint handler I check

whether some buttons need to be disabled/enabled, and a few other things

like that. Then I disable/enable the buttons as needed, and call the

original paint handler with the event.

Is there any cross-platform way to call the event handler?

Yes:

event.Skip()

Andrea.

To unsubscribe, send email to wxPython-users+unsubscribe@googlegroups.com

or visit http://groups.google.com/group/wxPython-users?hl=en

Event bindings are added to a table of bindings that is maintained by each instance. The event processing system searches until it finds a handler to call, and it will continue the search if that handler calls event.Skip(). So the binding in the base class still exists, but if you want it to still be called you need to call Skip from yours.

That said, there is probably no reason to let the default Panel EVT_PAINT handler to still be run if you are implementing your own EVT_PAINT handler.

···

On 4/18/10 10:31 AM, cool-RR wrote:

Are you sure it's right? I mean, if I subclass `Panel` and bind
`EVT_PAINT` to my own handler, won't it cancel the binding to the
original handler?

--
Robin Dunn
Software Craftsman

--
To unsubscribe, send email to wxPython-users+unsubscribe@googlegroups.com
or visit http://groups.google.com/group/wxPython-users?hl=en

I get it now, thanks.

Ram.

···

On Tue, Apr 20, 2010 at 9:31 PM, Robin Dunn robin@alldunn.com wrote:

On 4/18/10 10:31 AM, cool-RR wrote:

Are you sure it’s right? I mean, if I subclass Panel and bind

EVT_PAINT to my own handler, won’t it cancel the binding to the

original handler?

Event bindings are added to a table of bindings that is maintained by each instance. The event processing system searches until it finds a handler to call, and it will continue the search if that handler calls event.Skip(). So the binding in the base class still exists, but if you want it to still be called you need to call Skip from yours.

That said, there is probably no reason to let the default Panel EVT_PAINT handler to still be run if you are implementing your own EVT_PAINT handler.

Robin Dunn

To unsubscribe, send email to wxPython-users+unsubscribe@googlegroups.com

or visit http://groups.google.com/group/wxPython-users?hl=en