FlatNotebook - condition based page closing using 'x' button

What’s ‘Veto’ method…? I am new to wxPython.

Here is the code:
def OnPageClosing(self, event=None):
page = self._notebook.GetPageText(event.GetSelection())
if page == ‘myPage’:
return #don’t close

It’s not working.

···

----- Original Message ----
From: Robin Dunn robin@alldunn.com
To: wxpython-users@lists.wxwidgets.org
Sent: Friday, June 20, 2008 10:07:17 PM
Subject: Re: [wxpython-users] FlatNotebook - condition based page closing using ‘x’ button

Prashant Saxena wrote:

Hi,

have bind the ‘FlatNoteBook’ with ‘EVT_FLATNOTEBOOK_PAGE_CLOSING’ event.
When closing a page using ‘x’ button this event is getting called
properly. Inside the event
definition, based on a condition I am not able to cancel the closing
operation.

For example inside the ‘‘EVT_FLATNOTEBOOK_PAGE_CLOSING’’ function:

if page name is ‘abs’ then close it
else don’t.

Is there any other event for this task or …?

Call the event object’s Veto method if you want to prevent the page from
closing.


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


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

Prashant Saxena wrote:

What's 'Veto' method....? I am new to wxPython.

Try Google. It's cool. I found this in the top 2 results: http://zetcode.com/wxpython/events/

It allows you to cancel the event so that nothing happens when the event is fired. you will probably find this helpful too:

http://wiki.wxpython.org/EventPropagation

Here is the code:
def OnPageClosing(self, event=None):
    page = self._notebook.GetPageText(event.GetSelection())
    if page == 'myPage':
       return #don't close

It's not working.

I recommend that you read through the wiki, get the "wxPython in Action" book and download the Docs & Demo program from the wxPython website. You will learn a lot from those sources.

···

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

Blog: http://blog.pythonlibrary.org
Python Extension Building Network: http://www.pythonlibrary.org