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

Jasper Elzinga | Alexion Software <[email protected]> Wed, 5 Jun 2019 07:49:25 -0700 (PDT)
Newsgroups gmane.comp.python.wxpython.devel
Message-ID <[email protected]>
------=_Part_1365_2095713427.1559746165066
Content-Type: multipart/alternative; 
	boundary="----=_Part_1366_20208365.1559746165066"

------=_Part_1366_20208365.1559746165066
Content-Type: text/plain; charset="UTF-8"

Hello,

I'm having trouble checking the destroyed state of wx.Dialogs. When I call 
'.Destroy()' and do a 'wx.Yield()' the dialog is not reported as destroyed:

dialog = wx.Dialog(self, -1, "")
result = dialog.ShowModal()
dialog.Destroy()

wx.Yield()

print "wx version", wx.version()
print "is child", dialog in  self.GetChildren()
print "is being deleted", dialog.IsBeingDeleted()
print "not yet destroyed", bool(dialog)


Output:
wx version 3.0.2.0 msw (classic)
is child True
is being deleted False
not yet destroyed True

As far as I know this is the way it should be done according to a couple 
posts of people with similar questions.

I've tried many other things like multiple yields, time.sleep(), 
self.Refresh(), self.Update(). I've found one thing: if i create a new 
dialog and call '.ShowModal()', the first (destroyed) dialog is correctly 
reported as destroyed

I've attached my whole test script as an attachment. I've tested this in 
version 3.0.2.0 msw (the one we currently use) and in the latest version i 
get from 'pip install wxPython': 4.0.6 msw (phoenix) wxWidgets 3.0.5.

Any help would be greatly appreciated :)

Thanks,
Jasper
Alexion Software


-- 


______digitale bijlage______

De informatie verzonden met dit E-mail 
bericht is uitsluitend bestemd voor de geadresseerde. Gebruik van deze 
informatie door anderen dan de geadresseerde is niet toegestaan, evenals 
openbaarmaking, vermenigvuldiging en/of verstrekking aan derden. Alexion 
Software is niet aansprakelijk voor de juiste en volledige overbrenging van 
de inhoud van verzonden e-mail berichten, noch voor een tijdige ontvangst 
daarvan. De aan u verzonden digitale informatie mag uitsluitend gebruikt 
worden voor het desbetreffende project. De aan u verzonden digitale 
informatie wordt zonder enige verantwoordelijkheid onzerzijds verstrekt. 
Aan de door u digitaal ontvangen informatie kunnen geen rechten worden 
ontleend ten opzichte van Alexion Software. Het is raadzaam om de ontvangen 
bestanden voor het gebruik te controleren op eventuele aanwezigheid van 
virussen. Verlies van gegevens door het niet maken van back-ups is niet 
voor verantwoordelijkheid van Alexion Software.

Op al onze offertes en 
facturen zijn van toepassing Algemene Voorwaarden zoals gedeponeerd bij de 
KvK Midden-Nederland onder nummer 30174840 van ICT~Office. Deze zullen wij 
u op uw eerste verzoek kosteloos toesturen. Een kopie van deze algemene 
voorwaarden vindt u op alexion.nl/algemene-voorwaarden 
<http://alexion.nl/algemene-voorwaarden>

-- 
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/9aba148f-fc0b-449b-aca4-94661ba4a8be%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

------=_Part_1366_20208365.1559746165066
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">Hello,<br><br><div>I&#39;m having trouble checking the des=
troyed state of wx.Dialogs. When I call &#39;.Destroy()&#39; and do a &#39;=
wx.Yield()&#39; the dialog is not reported as destroyed:</div><div><br><div=
 style=3D"background-color: rgb(250, 250, 250); border-color: rgb(187, 187,=
 187); border-style: solid; border-width: 1px; overflow-wrap: break-word;" =
class=3D"prettyprint"><code class=3D"prettyprint"><div class=3D"subprettypr=
int"><span style=3D"color: #000;" class=3D"styled-by-prettify">dialog </spa=
n><span style=3D"color: #660;" class=3D"styled-by-prettify">=3D</span><span=
 style=3D"color: #000;" class=3D"styled-by-prettify"> wx</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">.</span><span style=3D"color=
: #606;" class=3D"styled-by-prettify">Dialog</span><span style=3D"color: #6=
60;" class=3D"styled-by-prettify">(</span><span style=3D"color: #008;" clas=
s=3D"styled-by-prettify">self</span><span style=3D"color: #660;" class=3D"s=
tyled-by-prettify">,</span><span style=3D"color: #000;" class=3D"styled-by-=
prettify"> </span><span style=3D"color: #660;" class=3D"styled-by-prettify"=
>-</span><span style=3D"color: #066;" class=3D"styled-by-prettify">1</span>=
<span style=3D"color: #660;" class=3D"styled-by-prettify">,</span><span sty=
le=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"col=
or: #080;" class=3D"styled-by-prettify">&quot;&quot;</span><span style=3D"c=
olor: #660;" class=3D"styled-by-prettify">)</span><span style=3D"color: #00=
0;" class=3D"styled-by-prettify"><br>result </span><span style=3D"color: #6=
60;" class=3D"styled-by-prettify">=3D</span><span style=3D"color: #000;" cl=
ass=3D"styled-by-prettify"> dialog</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">.</span><span style=3D"color: #606;" class=3D"style=
d-by-prettify">ShowModal</span><span style=3D"color: #660;" class=3D"styled=
-by-prettify">()</span><span style=3D"color: #000;" class=3D"styled-by-pret=
tify"><br>dialog</span><span style=3D"color: #660;" class=3D"styled-by-pret=
tify">.</span><span style=3D"color: #606;" class=3D"styled-by-prettify">Des=
troy</span><span style=3D"color: #660;" class=3D"styled-by-prettify">()</sp=
an><span style=3D"color: #000;" class=3D"styled-by-prettify"><br><br>wx</sp=
an><span style=3D"color: #660;" class=3D"styled-by-prettify">.</span><span =
style=3D"color: #606;" class=3D"styled-by-prettify">Yield</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">()</span><span style=3D"colo=
r: #000;" class=3D"styled-by-prettify"><br><br></span><span style=3D"color:=
 #008;" class=3D"styled-by-prettify">print</span><span style=3D"color: #000=
;" class=3D"styled-by-prettify"> </span><span style=3D"color: #080;" class=
=3D"styled-by-prettify">&quot;wx version&quot;</span><span style=3D"color: =
#660;" class=3D"styled-by-prettify">,</span><span style=3D"color: #000;" cl=
ass=3D"styled-by-prettify"> wx</span><span style=3D"color: #660;" class=3D"=
styled-by-prettify">.</span><span style=3D"color: #000;" class=3D"styled-by=
-prettify">version</span><span style=3D"color: #660;" class=3D"styled-by-pr=
ettify">()</span><span style=3D"color: #000;" class=3D"styled-by-prettify">=
<br></span><span style=3D"color: #008;" class=3D"styled-by-prettify">print<=
/span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><sp=
an style=3D"color: #080;" class=3D"styled-by-prettify">&quot;is child&quot;=
</span><span style=3D"color: #660;" class=3D"styled-by-prettify">,</span><s=
pan style=3D"color: #000;" class=3D"styled-by-prettify"> dialog </span><spa=
n style=3D"color: #008;" class=3D"styled-by-prettify">in</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> =C2=A0</span><span style=3D=
"color: #008;" class=3D"styled-by-prettify">self</span><span style=3D"color=
: #660;" class=3D"styled-by-prettify">.</span><span style=3D"color: #606;" =
class=3D"styled-by-prettify">GetChildren</span><span style=3D"color: #660;"=
 class=3D"styled-by-prettify">()</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"><br></span><span style=3D"color: #008;" class=3D"st=
yled-by-prettify">print</span><span style=3D"color: #000;" class=3D"styled-=
by-prettify"> </span><span style=3D"color: #080;" class=3D"styled-by-pretti=
fy">&quot;is being deleted&quot;</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">,</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify"> dialog</span><span style=3D"color: #660;" class=3D"styled-b=
y-prettify">.</span><span style=3D"color: #606;" class=3D"styled-by-prettif=
y">IsBeingDeleted</span><span style=3D"color: #660;" class=3D"styled-by-pre=
ttify">()</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><=
br></span><span style=3D"color: #008;" class=3D"styled-by-prettify">print</=
span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><spa=
n style=3D"color: #080;" class=3D"styled-by-prettify">&quot;not yet destroy=
ed&quot;</span><span style=3D"color: #660;" class=3D"styled-by-prettify">,<=
/span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><sp=
an style=3D"color: #008;" class=3D"styled-by-prettify">bool</span><span sty=
le=3D"color: #660;" class=3D"styled-by-prettify">(</span><span style=3D"col=
or: #000;" class=3D"styled-by-prettify">dialog</span><span style=3D"color: =
#660;" class=3D"styled-by-prettify">)</span></div></code></div><br><br><div=
>Output:</div><div style=3D"background-color: rgb(250, 250, 250); border-co=
lor: rgb(187, 187, 187); border-style: solid; border-width: 1px; overflow-w=
rap: break-word;" class=3D"prettyprint"><code class=3D"prettyprint"><div cl=
ass=3D"subprettyprint"><span style=3D"color: #000;" class=3D"styled-by-pret=
tify">wx version </span><span style=3D"color: #066;" class=3D"styled-by-pre=
ttify">3.0</span><span style=3D"color: #660;" class=3D"styled-by-prettify">=
.</span><span style=3D"color: #066;" class=3D"styled-by-prettify">2.0</span=
><span style=3D"color: #000;" class=3D"styled-by-prettify"> msw </span><spa=
n style=3D"color: #660;" class=3D"styled-by-prettify">(</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify">classic</span><span style=3D=
"color: #660;" class=3D"styled-by-prettify">)</span><span style=3D"color: #=
000;" class=3D"styled-by-prettify"><br></span><span style=3D"color: #008;" =
class=3D"styled-by-prettify">is</span><span style=3D"color: #000;" class=3D=
"styled-by-prettify"> child </span><span style=3D"color: #008;" class=3D"st=
yled-by-prettify">True</span><span style=3D"color: #000;" class=3D"styled-b=
y-prettify"><br></span><span style=3D"color: #008;" class=3D"styled-by-pret=
tify">is</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> b=
eing deleted </span><span style=3D"color: #008;" class=3D"styled-by-prettif=
y">False</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><b=
r></span><span style=3D"color: #008;" class=3D"styled-by-prettify">not</spa=
n><span style=3D"color: #000;" class=3D"styled-by-prettify"> yet destroyed =
</span><span style=3D"color: #008;" class=3D"styled-by-prettify">True</span=
><span style=3D"color: #000;" class=3D"styled-by-prettify"><br></span></div=
></code></div></div><div><br></div><div>As far as I know this is the way it=
 should be done according to a couple posts of people with similar question=
s.<br></div><div><br></div><div>I&#39;ve tried many other things like multi=
ple yields, time.sleep(), self.Refresh(), self.Update(). I&#39;ve found one=
 thing: if i create a new dialog and call &#39;.ShowModal()&#39;, the first=
 (destroyed) dialog is correctly reported as destroyed</div><br><div>I&#39;=
ve attached my whole test script as an attachment. I&#39;ve tested this in =
version 3.0.2.0 msw (the one we currently use) and in the latest version i =
get from &#39;pip install wxPython&#39;: 4.0.6 msw (phoenix) wxWidgets 3.0.=
5.</div><div><br></div><div>Any help would be greatly appreciated :)</div><=
div></div><br>Thanks,<br>Jasper<br><div>Alexion Software</div><br></div>
<br>
<p><font size=3D"1" style=3D"background-color:white" face=3D"Verdana" color=
=3D"#808080">______digitale bijlage______</font></p><p><font size=3D"1" fac=
e=3D"Verdana" color=3D"#808080" style=3D"background-color:white">De informa=
tie verzonden met dit E-mail bericht is uitsluitend bestemd voor de geadres=
seerde. Gebruik van deze informatie door anderen dan de geadresseerde is ni=
et toegestaan, evenals openbaarmaking, vermenigvuldiging en/of verstrekking=
 aan derden. Alexion Software is niet aansprakelijk voor de juiste en volle=
dige overbrenging van de inhoud van verzonden e-mail berichten, noch voor e=
en tijdige ontvangst daarvan. De aan u verzonden digitale informatie mag ui=
tsluitend gebruikt worden voor het desbetreffende project. De aan u verzond=
en digitale informatie wordt zonder enige verantwoordelijkheid onzerzijds v=
erstrekt. Aan de door u digitaal ontvangen informatie kunnen geen rechten w=
orden ontleend ten opzichte van Alexion Software. Het is raadzaam om de ont=
vangen bestanden voor het gebruik te controleren op eventuele aanwezigheid =
van virussen. Verlies van gegevens door het niet maken van back-ups is niet=
 voor verantwoordelijkheid van Alexion Software.</font></p><p><font size=3D=
"1" style=3D"background-color:white" face=3D"Verdana" color=3D"#808080">Op =
al onze offertes en facturen zijn van toepassing Algemene Voorwaarden zoals=
 gedeponeerd bij de KvK Midden-Nederland onder nummer 30174840 van ICT~Offi=
ce. Deze zullen wij u op uw eerste verzoek kosteloos toesturen. Een kopie v=
an deze algemene voorwaarden vindt u op <a href=3D"http://alexion.nl/algeme=
ne-voorwaarden" target=3D"_blank">alexion.nl/algemene-<wbr>voorwaarden</a><=
/font></p>

<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/9aba148f-fc0b-449b-aca4-94661ba4a8be%40googlegroups=
.com?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.com/d/ms=
gid/wxPython-dev/9aba148f-fc0b-449b-aca4-94661ba4a8be%40googlegroups.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 />

------=_Part_1366_20208365.1559746165066--

------=_Part_1365_2095713427.1559746165066
Content-Type: text/plain; charset=US-ASCII; name=output.txt
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename=output.txt
X-Attachment-Id: a48f53f3-fe64-404a-b7af-b8e98dc5ea8b
Content-ID: <a48f53f3-fe64-404a-b7af-b8e98dc5ea8b>

wx version 3.0.2.0 msw (classic)
is child True
is being deleted False
not yet destroyed True

wx version 4.0.6 msw (phoenix) wxWidgets 3.0.5
is child True
is being deleted False
not yet destroyed True


------=_Part_1365_2095713427.1559746165066
Content-Type: text/x-python; charset=US-ASCII; name=dialogdestroytest.py
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename=dialogdestroytest.py
X-Attachment-Id: fff4d9a8-ec06-4941-a96b-9a5a12f5dfa2
Content-ID: <fff4d9a8-ec06-4941-a96b-9a5a12f5dfa2>

import wx

class Frame(wx.Frame):

	def __init__(self):
		wx.Frame.__init__(self, None, -1, "Test")

		button = wx.Button(self, -1, "Test")
		button.Bind(wx.EVT_BUTTON, self.OnButton)

		self.Bind(wx.EVT_CLOSE, self.OnClose)

	def OnButton(self, event):
		dialog = wx.Dialog(self, -1, "")
		result = dialog.ShowModal()
		dialog.Destroy()

		wx.Yield()

		print "wx version", wx.version()
		print "is child", dialog in  self.GetChildren()
		print "is being deleted", dialog.IsBeingDeleted()
		print "not yet destroyed", bool(dialog)

	def OnClose(self, event):
		self.Destroy()


app = wx.App()
win = Frame()
win.Show(True)
app.MainLoop()

------=_Part_1365_2095713427.1559746165066--