[wxpython-users] Catching user leaving the window

Werner F. Bruhin werner.bruhin at free.fr
Mon Sep 8 08:37:56 PDT 2008


Tim,

...
>>
>>
>>     Did you try EVT_LEAVE_WINDOW ? I would think that would work no
>>     matter which widget you're using, unless the OS doesn't support it.
>>
>>
>> Doesn't that track mouse-movement? Wouldn't it be a bit extreme to 
>> rollback your database-transaction and already-entered data just b/c 
>> the user moves the mouse? ;-)
I would obviously put up a dialog or something. ;-)

With the page changing events this works nicely, I just veto it and tell 
the user that they should save/commit the data.

Here is what the app does:
- user selects a wine from an objectlistview
- system fills the controls on multiple pages on the flatnotebook
- user selects e.g. the page with ratings
- starts to create a new rating
- user switches to another notebook page
- page changing event fires, I veto it if there is unsaved data and 
inform user to save data

Above is fine, but if user does not change page but goes "outside" the 
notebook I have not found a way to intercept this action.

Ideally I like an event which I can veto, then all would be fine.

If that does not exist I am happy with an event telling me that he went 
"outside" the notebook, I can then try to save the data if it passes 
validation, or throw it away (rollback) to prevent a SQLAlchemy 
exception (it does not like a partially created object - which is fine 
with me).

I can not do it on close, as no window/frame is closed.
>>
>> You could perhaps try window activate/deactivate events, I think that 
>> these apply only to the whole wx.Frame; not to individual widgets.
Will look into this one.

Thanks
Werner
>>
>> Cheers,
>>
>> --Tim
>>
>>
>
> Yeah, but sometimes you gotta get extreme! Anyway, I suppose Werner 
> could just track changes and catch the OnClose event and ask the user 
> if they want to save or not.
>
> -------------------
> Mike Driscoll
>
> Blog:   http://blog.pythonlibrary.org
> Python Extension Building Network:     http://www.pythonlibrary.org
>
>
> _______________________________________________
> wxpython-users mailing list
> wxpython-users at lists.wxwidgets.org
> http://lists.wxwidgets.org/mailman/listinfo/wxpython-users
>
>



More information about the wxpython-users mailing list