Hi,
given this code:
import wx
import time
class TestDialog(wx.Dialog):
def __init__(self, parent):
wx.Dialog.__init__(self, None, -1)
self.label = wx.StaticText(self, -1, "Test Static Text")
app = wx.App(0)
w = TestDialog(None)
w.Show()
for i in range(3):
time.sleep(1)
#wx.Yield()
print i
w.Destroy()
app.MainLoop()
The static text is not visible.
What is wrong here?
···
--
Franz Steinhaeusler
Hi Franz,
I can only make it work using ShowModal(), but I assume you have some reason not to use that?
It seems that using Show() on a dialog only draws the frame.
Try this:
try:
w.ShowModal()
time.sleep(1)
w.Hide()
time.sleep(1)
w.Show()
w.label.Show()
w.Layout()
time.sleep(1)
w.Show()
time.sleep(1)
finally:
w.Destroy()
See you
Werner
Franz Steinhaeusler wrote:
···
Hi,
given this code:
import wx
import time
class TestDialog(wx.Dialog):
def __init__(self, parent):
wx.Dialog.__init__(self, None, -1)
self.label = wx.StaticText(self, -1, "Test Static Text")
app = wx.App(0)
w = TestDialog(None)
w.Show()
for i in range(3):
time.sleep(1)
#wx.Yield()
print i
w.Destroy()
app.MainLoop()
The static text is not visible.
What is wrong here?
--
Franz Steinhaeusler
---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwidgets.org
For additional commands, e-mail: wxPython-users-help@lists.wxwidgets.org
Hi Franz,
I can only make it work using ShowModal(), but I assume you have some
reason not to use that?
Hi Werner,
Yes, not directly, but I found this codesnippet and wanted to
investigate further.
It seems that using Show() on a dialog only draws the frame.
That is strange, I cannot imagine, that this is intended.
Try this:
try:
w.ShowModal()
time.sleep(1)
w.Hide()
time.sleep(1)
w.Show()
w.label.Show()
w.Layout()
time.sleep(1)
w.Show()
time.sleep(1)
finally:
w.Destroy()
See you
Werner
This will create a second window.
You see this, after you close the window, a second one appears.
···
On Thu, 27 Apr 2006 16:18:46 +0200, "Werner F. Bruhin" <werner.bruhin@free.fr> wrote:
--
Franz Steinhaeusler
It appears that Show() doesn't work completely[1] until
wx.App.MainLoop() is called. Your program creates a Dialog and destroys
it again before MainLoop actually makes the Dialog appear. As there
are no windows, the loop exits immediately. You can easily test this
by moving app.MainLoop() between w.Show() and the for loop. When you
close the Dialog, the program waits three seconds before exiting.
I guess your desired behaviour is: pop up dialog, wait three seconds,
destroy dialog. You can do this by creating a Timer object with a 3s
delay either in the __init__ method of TestDialog or just before the
app.MainLoop(). Remember to use wx.CallAfter to Destroy the Dialog from
the thread if you do this...
Simon.
[1] On the Linux box I'm using right now, you don't get anything at all;
on the WinXP machine next to me you get the window appearing but with
painting oddities and no text.
···
On Thu, Apr 27, 2006 at 02:42:17PM +0200, Franz Steinhaeusler wrote:
Hi,
given this code:
import wx
import time
class TestDialog(wx.Dialog):
def __init__(self, parent):
wx.Dialog.__init__(self, None, -1)
self.label = wx.StaticText(self, -1, "Test Static Text")
app = wx.App(0)
w = TestDialog(None)
w.Show()
for i in range(3):
time.sleep(1)
#wx.Yield()
print i
w.Destroy()
app.MainLoop()
The static text is not visible.
What is wrong here?
Just force an Update:
(...)
for i in range(3):
w.Update()
wx.Yield()
time.sleep(1)
(...)
Ricardo
···
On Thu, 2006-04-27 at 14:42 +0200, Franz Steinhaeusler wrote:
Hi,
given this code:
import wx
import time
class TestDialog(wx.Dialog):
def __init__(self, parent):
wx.Dialog.__init__(self, None, -1)
self.label = wx.StaticText(self, -1, "Test Static Text")
app = wx.App(0)
w = TestDialog(None)
w.Show()
for i in range(3):
time.sleep(1)
#wx.Yield()
print i
w.Destroy()
app.MainLoop()
The static text is not visible.
What is wrong here?
Hi,
Just force an Update:
(...)
for i in range(3):
w.Update()
wx.Yield()
time.sleep(1)
(...)
Ricardo
Hello Simon and Ricardo,
thank you both.
this works
w.Update()
for i in range(3):
time.sleep(1)
[Simon]
You can easily test this
by moving app.MainLoop() between w.Show() and the for loop. When you
close the Dialog, the program waits three seconds before exiting.
and also the solution with the mainloop.
···
On Thu, 27 Apr 2006 16:00:23 +0100, Ricardo Pedroso <ricardo.pedroso@netvisao.pt> wrote:
On Thu, 2006-04-27 at 14:42 +0200, Franz Steinhaeusler wrote:
--
Franz Steinhaeusler
It happens that this is true for wxGTK but not for wxMSW, both 2.6.3.2
There are some inconsistencies with the wx.Yield, probably due to how
those platforms manage their paint events.
PS: Every time I need to use wx.Yield/.Refresh/.Update I test asap on
both platforms. On Mac I don't know, I don't have one.
Ricardo
···
On Thu, 2006-04-27 at 20:23 -0700, Robin Dunn wrote:
Ricardo Pedroso wrote:
> Just force an Update:
>
> (...)
> for i in range(3):
> w.Update()
> wx.Yield()
> time.sleep(1)
Actually, for the record just the yield would probably be enough in this
case. Update forces any pending paint events to be delivered
immediately, but they should be delivered in the yield anyway.