wx.StaticText not visible on Dialog

No UI updates can happen in your application until app.MainLoop runs.
By that time, you have already queued up a request to paint the window
and a request to destroy the window. The paint cannot happen until
MainLoop runs. The text does get displayed, but as soon as it does, the
application exits.

You need something patterned after Werner's code from earlier today:

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")
        self.timer = wx.Timer(self)
        self.Bind( wx.EVT_TIMER, self.OnTimer )
        self.timer.Start( 1000 )
        self.seconds = 0

    def OnTimer( self, event ):
        print self.seconds
        self.seconds += 1
        if self.seconds == 3:
            self.timer.Stop()
            self.Close()
            self.Destroy()

app = wx.App(0)
w = TestDialog(None)
w.Show()
app.MainLoop()

···

On Thu, 27 Apr 2006 14:42:17 +0200, Franz Steinhaeusler <franz.steinhaeusler@gmx.at> 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?

--
Tim Roberts, timr@probo.com
Providenza & Boekelheide, Inc.