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?
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.
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.
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.
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?
>> 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?
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:
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?
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.