Hi!
I'm developing a wxPython 2.3.2.1 application with Python 2.2 on Linux
which should run on Linux and on Windows. This is my first Python
application, so please bear with me
In my program I've a wxNotebook containing some pages. A certain page
should only be accessible, when the user entered something on the
previous page. At first, I wanted to do the check in a
EVT_NOTEBOOK_PAGE_CHANGING event, because that seemed to be the natural
place to do something like this because of the Veto() function.
Because this check should only be done on one special page, I thought I
could use wxNotebookEvent::GetSelection() to see where I'm going to.
However, the manual says:
wxNotebookEvent::GetSelection
int GetSelection() const
Returns the currently selected page, or -1 if none was selected.
NB: under Windows, GetSelection() will return the same value as
GetOldSelection() when called from EVT_NOTEBOOK_PAGE_CHANGING
handler and not the page which is going to be selected.
Bummer. So I can't use EVT_NOTEBOOK_PAGE_CHANGING.
Next I tried hooking up a EVT_PAINT event for the panel which is on the
notebook page. I thought, I could "deadvance" the user to the previous
page depending on whether he entered something or not. So, I did in the
event:
if self.DateiName is None:
# Nothing has been entered yet
# Go back to previous page
self.Notebook.AdvanceSelection(false)
But this results in funny results, but certainly the selection (shown
page) is not always advanced to the previous page. Sometimes it's two
pages backward, sometimes one. The same happens, when I exchange
AdvanceSelection with:
self.Notebook.SetSelection(self.Notebook.GetSelection() - 1)
I suppose, I'm sometimes de-advanced two pages, because the EVT_PAINT is
called twice, even if GetSelection() already returns the previous page.
Next I tried to hook this all up into EVT_NOTEBOOK_PAGE_CHANGED. But
there, AdvanceSelection() and SetSelection() doesn't seem to do anything
at all. The page does not change.
Well, I'm now out of ideas. How can I deny changing the page *TO* a
certain page in a consistent way which will also work on Windows?
Alexander Skwar
···
--
How to quote: http://learn.to/quote (german) http://quote.6x.to (english)
Homepage: http://www.iso-top.de | Jabber: askwar@a-message.de
iso-top.de - Die günstige Art an Linux Distributionen zu kommen
Uptime: 15 hours 7 minutes