But it’s not a modal dialog? Shouldn’t it be?
If it were a modal dialog, you should not have been able to fire up
another menu at all.
“Killed” in what sense? You wanted the process to die. Are you
saying you get a crash notice? What’s the complaint? Deleting
something that was already deleted? When you answer “Yes”, what
actions do you take? If the first message box deletes cleans up
resources, you can’t really be surprised that the second dialog runs
into trouble.
Well, that’s your opinion. I find it difficult to call this a
“serious” bug.
···
Boštjan Mejak wrote:
How I did it? Well, I made an event in my GUI app where clicking the X button puts up a message dialog to the user, saying "Do you really wanna close this app?" and the "Yes" button destroys the whole object, thus exiting the application.
But now the catch! I also made a taskbar icon which includes a menu item to also exit the application: same message dialog with Yes/No buttons.
Let's crash this baby! If you click the X button and not choosing either "Yes" or "No" but instead have this message dialog wait and in the mean time you right-click the taskbar icon and choose the "Exit" menu item and choose "Yes". Then click another "Yes" of that waiting message dialog and BOOM! Voila, we have killed the wxWidgets/wxPython process.
Please bare in mind that this is a serious bug in wxWidgets and wxPython Phoenix.
-- Tim Roberts, Providenza & Boekelheide, Inc.
timr@probo.com
Maybe I got my code wrong.
or a bit missing -- this is wierd action on the part of the user -- if you
want to support it, then you may need to put a check or two in to make sure
that it either can't happen, or it will clean itself up properly.
-CHB
···
On Fri, Mar 3, 2017 at 12:35 PM, Boštjan Mejak <bostjan.xperia@gmail.com> wrote:
On Fri, Mar 3, 2017 at 9:28 PM Tim Roberts <timr@probo.com> wrote:
Boštjan Mejak wrote:
How I did it? Well, I made an event in my GUI app where clicking the X button puts up a message dialog to the user, saying "Do you really wanna close this app?" and the "Yes" button destroys the whole object, thus exiting the application.
But it's not a modal dialog? Shouldn't it be?
But now the catch! I also made a taskbar icon which includes a menu item to also exit the application: same message dialog with Yes/No buttons.
Let's crash this baby! If you click the X button and not choosing either "Yes" or "No" but instead have this message dialog wait and in the mean time you right-click the taskbar icon and choose the "Exit" menu item and choose "Yes". Then click another "Yes" of that waiting message dialog and BOOM! Voila, we have killed the wxWidgets/wxPython process.
If it were a modal dialog, you should not have been able to fire up
another menu at all.
"Killed" in what sense? You wanted the process to die. Are you saying
you get a crash notice? What's the complaint? Deleting something that was
already deleted? When you answer "Yes", what actions do you take? If the
first message box deletes cleans up resources, you can't really be
surprised that the second dialog runs into trouble.
Please bare in mind that this is a serious bug in wxWidgets and wxPython Phoenix.
Well, that's your opinion. I find it difficult to call this a "serious"
bug.
--
Tim Roberts, timr@probo.com
Providenza & Boekelheide, Inc.
--
You received this message because you are subscribed to the Google Groups
"wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to wxpython-users+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups
"wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to wxpython-users+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
Christopher Barker, Ph.D.
Oceanographer
Emergency Response Division
NOAA/NOS/OR&R (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception
Chris.Barker@noaa.gov
I'm not sure there's a clear answer to that question. Your design clearly closes a window while an event handler for that window is still executing, thereby pulling the rug out from underneath. I think a very good argument can be made that you should not do that. It's not clear how wxWidgets could react to that situation sensibly.
I understand how you might disagree, but if I were the referee in this situation, I'd have to assign the yellow card to you.
···
On Mar 4, 2017, at 8:33 AM, Boštjan Mejak <bostjan.xperia@gmail.com> wrote:
The attached demo.py file is a demonstration of the problem I was talking about. Is it my code that is faulty or is wxPython's/wxWidgets' or Python's fault?
—
Tim Roberts, timr@probo.com
Providenza & Boekelheide, Inc.
Can you propose how should I fix my code?
You might consider making the dialog modal, as
was already hinted at.
Karsten
But my dialog is modal, isn't it?
dialog = wx.MessageDialog(parent=self,
caption="Exit Playground",
message="Are you sure to exit Playground?",
style=wx.YES_NO | wx.ICON_QUESTION)
if dialog\.ShowModal\(\) == wx\.ID\_YES:
\.\.\.
Doesn't the call to ShowModal() make it modal?
That code certainly should make the dialog modal, yes, hence sorry for the noise.
Karsten
Hi,
if there is a specific clash with the taskbar icon functionality,
would it be possible to disable the popup menu in the taskbar while
handling the closing dialog?
maybe something like
self.taskBarIcon.Unbind(wx.EVT_MENU)
in OnMainWindowClose(...)
probably with some additional code to rebind the event handler as needed.
However, I haven't checked for possible drawbacks or cornercases of
such approach.
hth,
vbr
···
2017-03-05 20:03 GMT+01:00 Boštjan Mejak <bostjan.xperia@gmail.com>:
So, what can I do?
On Sun, Mar 5, 2017 at 3:18 PM Karsten Hilbert <Karsten.Hilbert@gmx.net> > wrote:
But my dialog is modal, isn't it?
dialog = wx.MessageDialog(parent=self,
caption="Exit Playground",
message="Are you sure to exit
Playground?",
style=wx.YES_NO |
wx.ICON_QUESTION)
if dialog.ShowModal() == wx.ID_YES:
...
Doesn't the call to ShowModal() make it modal?
That code certainly should make the dialog modal, yes, hence sorry for the
noise.
Karsten
The brute-force method would be to set a flag while your modal dialog is up, and ignore the task bar action when that flag is set.
I am little confused as to why you are seeing the task bar click while a modal dialog is up, but maybe that window is considered to be owned by someone else. If so, that would be a Windows usage issue.
···
On Mar 5, 2017, at 11:03 AM, Boštjan Mejak <bostjan.xperia@gmail.com> wrote:
So, what can I do?
—
Tim Roberts, timr@probo.com
Providenza & Boekelheide, Inc.
I must say that the wx.Dialog.ShowModal() does not work as expected then.
Would you agree?
yes and no -- ShowModal should lock up all wxFrames and wxDialogs.
But the taskbar icon is not handled by wx, and it may be very tricky to
catch events from that particular source and disable them when there is a
Modal Dialog up.
But it's a fine idea to post this as a Bug Report / Feature request --
maybe it's not hard to do -- I have no idea.
It should be posted to the main wxWidgets project -- this is not a
wxPython-specific issue.
In the meantime, Tim's "Brute Force" approach may be what you need to do.
-CHB
If you actually tried my demo code, you can notice when closing the main
···
On Mon, Mar 6, 2017 at 11:43 AM, Boštjan Mejak <bostjan.xperia@gmail.com> wrote:
window (clicking on the X button) puts up a 'modal' message dialog which
allows doing other stuff. This, however, should *not* happen. Please tell
this to Robin Dunn to look into this.
I ran my code on Windows 10 (64-bit), Python 3.6 (64-bit), wxPython
Phoenix latest snapshot build.
> On 6 Mar 2017, at 08:31, Tim Roberts <timr@probo.com> wrote:
>
>> On Mar 5, 2017, at 11:03 AM, Boštjan Mejak <bostjan.xperia@gmail.com> > wrote:
>>
>> So, what can I do?
>
> The brute-force method would be to set a flag while your modal dialog is
up, and ignore the task bar action when that flag is set.
>
> I am little confused as to why you are seeing the task bar click while a
modal dialog is up, but maybe that window is considered to be owned by
someone else. If so, that would be a Windows usage issue.
> —
> Tim Roberts, timr@probo.com
> Providenza & Boekelheide, Inc.
>
> --
> You received this message because you are subscribed to the Google
Groups "wxPython-users" group.
> To unsubscribe from this group and stop receiving emails from it, send
an email to wxpython-users+unsubscribe@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups
"wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to wxpython-users+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
Christopher Barker, Ph.D.
Oceanographer
Emergency Response Division
NOAA/NOS/OR&R (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception
Chris.Barker@noaa.gov
Boštjan Mejak wrote:
I've posted a bug report on wxWidgets' Trac site and I hope someone
will take it seriously and fix this thing.
I do want to re-inject a note of reality here. It seems quite possible
(I haven't checked) that you would see the exact same behavior from a
C++ Windows application going straight to the API. If the underlying
operating system UI framework doesn't protect against this, then the
right answer would be "don't do that", in which case the wxWidgets
developers might reasonably decide this is not a bug, and categorize it
as a feature request. You need to be prepared for this to be rated as a
low-priority item. It's an uncommon circumstance, and the cost is
extremely low, since the application is being closed anyway.
I only point this out because you have a certain reputation for
over-reacting when things don't go your way. I want you to be prepared.
···
--
Tim Roberts, timr@probo.com
Providenza & Boekelheide, Inc.
Boštjan,
An untested sample of a possible work around in your demo file is
attached. The new/changed lines are all marked SJB.
demo.py (8.67 KB)
···
On 07/03/2017 19:14, Boštjan Mejak wrote:
Please tell me in a coding language what exactly should I do. Edit my demo.py file and post it back here. If that is your desure, of course. 
--
Steve (Gadget) Barnes
Any opinions in this message are my personal opinions and do not reflect
those of my employer.
While you may already have a solution I thought it worth noting:
On my;
. Windows 10 Home 64 bit Version 10.0.14393 Intel i5-7400
. Python 3.6.1:69c0db5 MSC v.1900 64 bit (AMD64) on win32
. wxPython 4.0.0a1 msw (phoenix)
running your demo.py through py.exe, I was not able to replicate your problem. It worked as expected.
First I tried:
Clicking the X of the frame and the modal dialog popped up which I initially ignored and on the task bar I right-clicked the demo app icon and chose “Close Window” (there was no “Exit”) to which it reactivated/focused on the modal dialog box which when clicking “Yes” shut down your demo app without exception.
···
Second, I restarted the demo app and :
Clicking on File Exit menu of the frame and the modal dialog popped up which I initially ignored and on the task bar I right-clicked the demo app icon and chose “Close Window” (there was no “Exit”) to which it reactivated/focused on the modal dialog box which when clicking “Yes” shut down your demo app without exception.
Thirdly I restarted the demo app and :
Right clicking on the task-bar demo app icon and chose “Close Window” (there was no “Exit” option) to which the modal dialog box popped up to which I clicked “Yes” which shut down your demo app without exception.
Fourthly I restarted the demo app and :
Right clicking on the task-bar demo app icon and chose “Close Window” (there was no “Exit” option) to which the modal dialog box popped up which I ignored. I then again right clicked on the task-bar demo app icon and chose “Close Window” (there was no “Exit” option) to which the modal dialog box kept/regained focus to which I then clicked “Yes” which shut down your demo app without exception.