Hello,
I have some computation that takes 10-20 seconds and when
waiting this
to be finished, I'd like to display a very simple window that shows a
message 'Wait ... be patient, etc...'. This looks pretty trivial, but
for some reason I cannot make it work ok. I would do the code
like this:
def myComputation(self):
waitWin = wx.theMiracleClassThatIdontFind()
waitWin.Show()
...
do my computation things
...
waitWin.Close()
I could use a wx.Dialog(), but this stops the process and my
computation
things are never done.
I could put my computation into a thread ... but what a pain
for such a
simple thing to do.
I tried to make a class derived from wx.Frame to display my
wait window,
and although I'm doing the same code than in other places (using a
panel, sizers, etc.) it doesn't work well: the controls in
that window
are never displayed.
Before I spend the time making a small sample, does anybody
have an idea
of what's wrong, or already has a simple solution ?
Raphael,
I rolled my own:
# Create a popup telling the user about the load (needed for large
files)
loadDlg = PopupDialog(None, _("Loading..."), _("Loading your
transcript.\nPlease wait...."))
...
# Destroy the Load Popup Dialog
loadDlg.Destroy()
class PopupDialog(wx.Dialog):
""" A popup dialog for temporary user messages """
def __init__(self, parent, title, msg):
# Create a dialog
wx.Dialog.__init__(self, parent, -1, title, size=(350, 150),
style=wx.CAPTION | wx.STAY_ON_TOP)
# Add sizers
box = wx.BoxSizer(wx.VERTICAL)
box2 = wx.BoxSizer(wx.HORIZONTAL)
# Add an Info graphic
bitmap = wx.EmptyBitmap(32, 32)
bitmap = wx.ArtProvider_GetBitmap(wx.ART_INFORMATION,
wx.ART_MESSAGE_BOX, (32, 32))
graphic = wx.StaticBitmap(self, -1, bitmap)
box2.Add(graphic, 0, wx.EXPAND | wx.ALIGN_CENTER | wx.ALL, 10)
# Add the message
message = wx.StaticText(self, -1, msg)
box2.Add(message, 0, wx.EXPAND | wx.ALIGN_CENTER |
wx.ALIGN_CENTER_VERTICAL | wx.ALL, 10)
box.Add(box2, 0, wx.EXPAND)
# Handle layout
self.SetAutoLayout(True)
self.SetSizer(box)
self.Fit()
self.Layout()
self.CentreOnScreen()
# Display the Dialog
self.Show()
# Make sure the screen gets fully drawn before continuing.
wx.Yield()
David