Re: Re: wx.Dialog not reported as destroyed after '.Destroy()' is called

Eric Fahlgren <[email protected]> Thu, 6 Jun 2019 08:17:23 -0700
Newsgroups gmane.comp.python.wxpython.devel
Message-ID <CAP2Qz+XpDd81DdJnnHpRDvdahxi6B9K7JfNLe9fXJ_3eYtzLow@mail.gmail.com>
--000000000000a9b9cc058aa9365f
Content-Type: text/plain; charset="UTF-8"

Is *sending* idle events sufficient?  I think you have to flush the event
queue for the object before it is destroyed (i.e., run its event loop) or
else you'll get crashes later when those events are routed to the
now-destroyed widget.  Something like

>>> for event in ???:
>>>     widget.GetEventHandler().ProcessEvent(event)

or whatever???


On Thu, Jun 6, 2019 at 6:12 AM Mike Driscoll <[email protected]> wrote:

>
>
>
> On Thu, Jun 6, 2019 at 7:19 AM Jasper Elzinga | Alexion Software <
> [email protected]> wrote:
>
>> Thanks! This works.
>>
>> However.. returning to the mainloop is not possible in our actual use
>> case. We have a global dialog manager, and the code behind our button asks
>> it for a dialog in a loop. The dialog manager has to know wether or not a
>> dialog can be reused: if it's destroyed it can't be reused, but if it's for
>> example hidden it can. This check currently fails. We can't allow the
>> program to be accessable while the loop is running, thats why we use
>> ShowModal and why wx.CallAfter is not possible (or at least i dont know how
>> it would be possible using it).
>>
>> Any suggestions? Perhaps there is a way to simulate an idle event? This
>> way we can remain in our loop.
>>
>> Ofcourse we can always do our own "destroyed" management with a
>> 'self.destroyed' variable thats set to True by the 'Destroy' method in our
>> dialog, but this feels wrong to me :)
>>
>> Thanks,
>> Jasper
>>
>
>
> You can send your own idle events:
> https://wxpython.org/Phoenix/docs/html/wx.IdleEvent.html
>
> Just read the documentation carefully as it can increase system load.
>
> Mike
>
> -----------------
> Mike Driscoll
>
> Blog:   http://blog.pythonlibrary.org
> Books: Python 101 <https://gum.co/py101>, Python 201: Intermediate Python
> <https://gum.co/py201>, wxPython Recipes
> <https://www.apress.com/us/book/9781484232361>, Python Interviews
> <https://www.packtpub.com/web-development/python-interviews>
>
> --
> You received this message because you are subscribed to the Google Groups
> "wxPython-dev" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/wxPython-dev/CAO4gEAs5tDD4MSAS3RWAZ2h0-f6KXeqxdLsYQoM9xuHmh4d-PA%40mail.gmail.com
> <https://groups.google.com/d/msgid/wxPython-dev/CAO4gEAs5tDD4MSAS3RWAZ2h0-f6KXeqxdLsYQoM9xuHmh4d-PA%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups "wxPython-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To view this discussion on the web visit https://groups.google.com/d/msgid/wxPython-dev/CAP2Qz%2BXpDd81DdJnnHpRDvdahxi6B9K7JfNLe9fXJ_3eYtzLow%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

--000000000000a9b9cc058aa9365f
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div class=3D"gmail_default" style=3D"color:#000000">Is <i=
>sending</i> idle events sufficient?=C2=A0 I think you have to flush the ev=
ent queue for the object before it is destroyed (i.e., run its event loop) =
or else you&#39;ll get crashes later when those events are routed to the no=
w-destroyed widget.=C2=A0 Something like</div><div class=3D"gmail_default" =
style=3D"color:#000000"><br></div><div class=3D"gmail_default" style=3D"col=
or:#000000">&gt;&gt;&gt; for event in ???:</div><div class=3D"gmail_default=
" style=3D"color:#000000">&gt;&gt;&gt;=C2=A0 =C2=A0 =C2=A0widget.GetEventHa=
ndler().ProcessEvent(event)</div><div class=3D"gmail_default" style=3D"colo=
r:#000000"><br></div><div class=3D"gmail_default" style=3D"color:#000000">o=
r whatever???</div><div class=3D"gmail_default" style=3D"color:#000000"><br=
></div></div><br><div class=3D"gmail_quote"><div dir=3D"ltr" class=3D"gmail=
_attr">On Thu, Jun 6, 2019 at 6:12 AM Mike Driscoll &lt;<a href=3D"mailto:m=
[email protected]">[email protected]</a>&gt; wrote:<br></div><bloc=
kquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-left:=
1px solid rgb(204,204,204);padding-left:1ex"><div dir=3D"ltr"><div dir=3D"l=
tr"><br clear=3D"all"><div><div dir=3D"ltr" class=3D"gmail-m_-1550271069368=
125382gmail_signature"><div dir=3D"ltr"><div><div dir=3D"ltr"><div><div dir=
=3D"ltr"><div><div dir=3D"ltr"><div><br></div></div></div></div></div></div=
></div></div></div></div></div><br><div class=3D"gmail_quote"><div dir=3D"l=
tr" class=3D"gmail_attr">On Thu, Jun 6, 2019 at 7:19 AM Jasper Elzinga | Al=
exion Software &lt;<a href=3D"mailto:[email protected]" target=3D"_blank">j=
[email protected]</a>&gt; wrote:<br></div><blockquote class=3D"gmail_quote" =
style=3D"margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);pa=
dding-left:1ex"><div dir=3D"ltr">Thanks! This works.<br><br>However.. retur=
ning to the mainloop is not possible in our actual use case. We have a glob=
al dialog manager, and the code behind our button asks it for a dialog in a=
 loop. The dialog manager has to know wether or not a dialog can be reused:=
 if it&#39;s destroyed it can&#39;t be reused, but if it&#39;s for example =
hidden it can. This check currently fails. We can&#39;t allow the program t=
o be accessable while the loop is running, thats why we use ShowModal and w=
hy wx.CallAfter is not possible (or at least i dont know how it would be po=
ssible using it).<br><br>Any suggestions? Perhaps there is a way to simulat=
e an idle event? This way we can remain in our loop.<br><br>Ofcourse we can=
 always do our own &quot;destroyed&quot; management with a &#39;self.destro=
yed&#39; variable thats set to True by the &#39;Destroy&#39; method in our =
dialog, but this feels wrong to me :)<br><br>Thanks,<br>Jasper</div>=C2=A0=
=C2=A0</blockquote><div><br></div><div>You can send your own idle events:=
=C2=A0<a href=3D"https://wxpython.org/Phoenix/docs/html/wx.IdleEvent.html" =
target=3D"_blank">https://wxpython.org/Phoenix/docs/html/wx.IdleEvent.html<=
/a>=C2=A0</div><div><br></div><div>Just read the documentation carefully as=
 it can increase system load.</div><div><br></div><div>Mike</div><div><br><=
/div><div><div>-----------------<br>Mike Driscoll<br><br>Blog:=C2=A0=C2=A0=
=C2=A0<a href=3D"http://blog.pythonlibrary.org/" target=3D"_blank">http://b=
log.pythonlibrary.org</a><br></div>Books:=C2=A0<a href=3D"https://gum.co/py=
101" target=3D"_blank">Python 101</a>,=C2=A0<a href=3D"https://gum.co/py201=
" target=3D"_blank">Python 201: Intermediate Python</a>,<a href=3D"https://=
www.apress.com/us/book/9781484232361" target=3D"_blank">=C2=A0wxPython Reci=
pes</a>,=C2=A0<a href=3D"https://www.packtpub.com/web-development/python-in=
terviews" target=3D"_blank">Python Interviews</a>=C2=A0<br><br class=3D"gma=
il-m_-1550271069368125382gmail-Apple-interchange-newline"></div></div></div=
>

<p></p>

-- <br>
You received this message because you are subscribed to the Google Groups &=
quot;wxPython-dev&quot; group.<br>
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:[email protected]" target=
=3D"_blank">[email protected]</a>.<br>
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/d/msgid/wxPython-dev/CAO4gEAs5tDD4MSAS3RWAZ2h0-f6KXeqxdLsYQoM9xuHmh4d-PA=
%40mail.gmail.com?utm_medium=3Demail&amp;utm_source=3Dfooter" target=3D"_bl=
ank">https://groups.google.com/d/msgid/wxPython-dev/CAO4gEAs5tDD4MSAS3RWAZ2=
h0-f6KXeqxdLsYQoM9xuHmh4d-PA%40mail.gmail.com</a>.<br>
For more options, visit <a href=3D"https://groups.google.com/d/optout" targ=
et=3D"_blank">https://groups.google.com/d/optout</a>.<br>
</blockquote></div>

<p></p>

-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;wxPython-dev&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:[email protected]">wxPyth=
[email protected]</a>.<br />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/d/msgid/wxPython-dev/CAP2Qz%2BXpDd81DdJnnHpRDvdahxi6B9K7JfNLe9fXJ_3eYtzL=
ow%40mail.gmail.com?utm_medium=3Demail&utm_source=3Dfooter">https://groups.=
google.com/d/msgid/wxPython-dev/CAP2Qz%2BXpDd81DdJnnHpRDvdahxi6B9K7JfNLe9fX=
J_3eYtzLow%40mail.gmail.com</a>.<br />
For more options, visit <a href=3D"https://groups.google.com/d/optout">http=
s://groups.google.com/d/optout</a>.<br />

--000000000000a9b9cc058aa9365f--