FlatNotebook event bug

Hello,

I have a FlatNotebook (ChildNotebook) inside a page of another FlatNotebook (MasterNotebook). Both Notebooks seem works fine, but if Bind EVT_FLATNOTEBOOK_PAGE_CHANGING event on both notebooks the event is not fired properly. (i do not tryed with other events)

When change the page in MasterNotebook the event is fired properly, but when change the page in the ChildNotebook the event is first fired for ChildNotebook and then is *also fired for MasterNotebook* with the event properties of the Child.

I attach a simple demo.

Note: I try it with the Editra version of FlatNotebook with the same issue.

The system:
Windows XP SP3
Python 2.5
wxPython 2.8.10.1

Thanks.

FlatNotebookEvent.py (2.85 KB)

···

--
*****************************************
Oswaldo Hernández
oswaldo (@) soft-com (.) es
*****************************************
PD:
Antes de imprimir este mensaje, asegúrese de que es necesario.
El medio ambiente está en nuestra mano.

Hi,

···

2009/9/14 Oswaldo Hernández <listas@soft-com.es>:

Hello,

I have a FlatNotebook (ChildNotebook) inside a page of another FlatNotebook (MasterNotebook). Both
Notebooks seem works fine, but if Bind EVT_FLATNOTEBOOK_PAGE_CHANGING event on both notebooks the
event is not fired properly. (i do not tryed with other events)

When change the page in MasterNotebook the event is fired properly, but when change the page in the
ChildNotebook the event is first fired for ChildNotebook and then is *also fired for MasterNotebook*
with the event properties of the Child.

Your calling evt.Skip() in the OnChildPageChanging. When you call
Skip() it means let the event continue to propagate. So what you are
seeing is expected. If you don't want it to propagate to the parent
control then don't call Skip().

Cody

Cody Precord escribió:

Hi,

Hello,

I have a FlatNotebook (ChildNotebook) inside a page of another FlatNotebook (MasterNotebook). Both
Notebooks seem works fine, but if Bind EVT_FLATNOTEBOOK_PAGE_CHANGING event on both notebooks the
event is not fired properly. (i do not tryed with other events)

When change the page in MasterNotebook the event is fired properly, but when change the page in the
ChildNotebook the event is first fired for ChildNotebook and then is *also fired for MasterNotebook*
with the event properties of the Child.

Your calling evt.Skip() in the OnChildPageChanging. When you call
Skip() it means let the event continue to propagate. So what you are
seeing is expected. If you don't want it to propagate to the parent
control then don't call Skip().

But MasterNotebook and ChildNotebook are different objects. I think that the event may not be propagated from one object to other.

I also use Skip() on MasterNotebook and when the page is changing on it the event is not propagated to Child.

···

2009/9/14 Oswaldo Hernández <listas@soft-com.es>:

--
*****************************************
Oswaldo Hernández
oswaldo (@) soft-com (.) es
*****************************************
PD:
Antes de imprimir este mensaje, asegúrese de que es necesario.
El medio ambiente está en nuestra mano.

Hi,

Cody Precord escribió:

Hi,

Hello,

I have a FlatNotebook (ChildNotebook) inside a page of another FlatNotebook (MasterNotebook). Both
Notebooks seem works fine, but if Bind EVT_FLATNOTEBOOK_PAGE_CHANGING event on both notebooks the
event is not fired properly. (i do not tryed with other events)

When change the page in MasterNotebook the event is fired properly, but when change the page in the
ChildNotebook the event is first fired for ChildNotebook and then is *also fired for MasterNotebook*
with the event properties of the Child.

Your calling evt.Skip() in the OnChildPageChanging. When you call
Skip() it means let the event continue to propagate. So what you are
seeing is expected. If you don't want it to propagate to the parent
control then don't call Skip().

But MasterNotebook and ChildNotebook are different objects. I think that the event may not be
propagated from one object to other.

I also use Skip() on MasterNotebook and when the page is changing on it the event is not propagated
to Child.

Events propagate upwards in the hierarchy from child to parent. If you
were to bind the event to your Frame you would see that skipping it in
the masternotebook would allow it to propagate to the frame.

You ChildNotebook is a child of the MasterNotebook so calling skip in
its event handler will tell the event to propagate up to its parent
the MasterNotebook's handler.

So in short you should only call Skip() when you want the event to
continue to propagate.

Regards,

Cody

···

2009/9/14 Oswaldo Hernández <listas@soft-com.es>:

2009/9/14 Oswaldo Hernández <listas@soft-com.es>:

As Cody already said, by calling Skip() for the child, it propagates
to the parent, which in this case is MasterNotebook. Calling Skip on
the MasterNotebook will not propagate to the Child because the Child
is not the parent of the MasterNotebook.

···

On Sep 14, 10:04 am, Oswaldo Hernández <lis...@soft-com.es> wrote:

Cody Precord escribió:

> Hi,

> 2009/9/14 Oswaldo Hernández <lis...@soft-com.es>:
>> Hello,

>> I have a FlatNotebook (ChildNotebook) inside a page of another FlatNotebook (MasterNotebook). Both
>> Notebooks seem works fine, but if Bind EVT_FLATNOTEBOOK_PAGE_CHANGING event on both notebooks the
>> event is not fired properly. (i do not tryed with other events)

>> When change the page in MasterNotebook the event is fired properly, but when change the page in the
>> ChildNotebook the event is first fired for ChildNotebook and then is *also fired for MasterNotebook*
>> with the event properties of the Child.

> Your calling evt.Skip() in the OnChildPageChanging. When you call
> Skip() it means let the event continue to propagate. So what you are
> seeing is expected. If you don't want it to propagate to the parent
> control then don't call Skip().

But MasterNotebook and ChildNotebook are different objects. I think that the event may not be
propagated from one object to other.

I also use Skip() on MasterNotebook and when the page is changing on it the event is not propagated
to Child.

--
*****************************************
Oswaldo Hernández
oswaldo (@) soft-com (.) es
*****************************************

-------------------
Mike Driscoll

Blog: http://blog.pythonlibrary.org

Cody Precord escribió:

Hi,

Cody Precord escribió:

Hi,

Hello,

I have a FlatNotebook (ChildNotebook) inside a page of another FlatNotebook (MasterNotebook). Both
Notebooks seem works fine, but if Bind EVT_FLATNOTEBOOK_PAGE_CHANGING event on both notebooks the
event is not fired properly. (i do not tryed with other events)

When change the page in MasterNotebook the event is fired properly, but when change the page in the
ChildNotebook the event is first fired for ChildNotebook and then is *also fired for MasterNotebook*
with the event properties of the Child.

Your calling evt.Skip() in the OnChildPageChanging. When you call
Skip() it means let the event continue to propagate. So what you are
seeing is expected. If you don't want it to propagate to the parent
control then don't call Skip().

But MasterNotebook and ChildNotebook are different objects. I think that the event may not be
propagated from one object to other.

I also use Skip() on MasterNotebook and when the page is changing on it the event is not propagated
to Child.

Events propagate upwards in the hierarchy from child to parent. If you
were to bind the event to your Frame you would see that skipping it in
the masternotebook would allow it to propagate to the frame.

You ChildNotebook is a child of the MasterNotebook so calling skip in
its event handler will tell the event to propagate up to its parent
the MasterNotebook's handler.

So in short you should only call Skip() when you want the event to
continue to propagate.

OK, I am wrong. Making more tests i find out that the event is propagated for all the containers of the widget including the frame.

Thanks.

···

2009/9/14 Oswaldo Hernández <listas@soft-com.es>:

2009/9/14 Oswaldo Hernández <listas@soft-com.es>:

--
*****************************************
Oswaldo Hernández
oswaldo (@) soft-com (.) es
*****************************************
PD:
Antes de imprimir este mensaje, asegúrese de que es necesario.
El medio ambiente está en nuestra mano.

Or you can specify the source of the event (3rd arg to Bind) to restrict the binding to only those events that come from that source. By default it is binding to the events from all sources whose events propagate through the widget doing the Bind.

         self.MasterNb.Bind(fnb.EVT_FLATNOTEBOOK_PAGE_CHANGING, self.OnMasterPageChaging, self.MasterNb)

···

On 9/14/09 7:48 AM, Cody Precord wrote:

Hi,

2009/9/14 Oswaldo Hernández<listas@soft-com.es>:

Hello,

I have a FlatNotebook (ChildNotebook) inside a page of another FlatNotebook (MasterNotebook). Both
Notebooks seem works fine, but if Bind EVT_FLATNOTEBOOK_PAGE_CHANGING event on both notebooks the
event is not fired properly. (i do not tryed with other events)

When change the page in MasterNotebook the event is fired properly, but when change the page in the
ChildNotebook the event is first fired for ChildNotebook and then is *also fired for MasterNotebook*
with the event properties of the Child.

Your calling evt.Skip() in the OnChildPageChanging. When you call
Skip() it means let the event continue to propagate. So what you are
seeing is expected. If you don't want it to propagate to the parent
control then don't call Skip().

--
Robin Dunn
Software Craftsman