I have a wx application & use a ProgressDialog to inform the user when some tasks are running.
when the task is finished it goes back to the main application window.
This worked fine in Python2.7 (wx 3.0.2.0) under windows 10.
I am now using Python 3.7.9 & wxPython 4.1.1 and I have a strange behaviour I do not understand.
When the progress dialog is closed, the main application window seems to drop 1 level in the background in windows (i.e. underneath Folders or applications which were open at the same time.). E.g. If I run the application from PyCharm, once the ProgressDialog is closed, the wx window goes behind PyCharm.
The same if I run from the command line, it will go behind any windows it was previously above.
To restore it to the foreground, I have to select it from the windows taskbar again.
How do I keep the wx application window in the same hierarchical position as it was before?
With the following code I see the same behaviour but I do not understand what I am doing wrong? (or what is different to python27).
Python 27 is OK but Python 37 & 39 both have the same issue.
import wx
import time
class Application(wx.Frame):
def __init__(self, parent, title):
wx.Frame.__init__(self, parent, title=title)
self.SetMinSize(wx.Size(1050, 580))
self.Show()
self.progress_dlg = wx.ProgressDialog("Update", "Updating SVN Folders...", maximum=100)
# Update SVN
for ctr in range (5):
self.progress_dlg.Update(ctr+1, "SVN Updating:...")
time.sleep(1)
self.progress_dlg.Update(100)
app = wx.App(False)
frame = Application(None, "SVN Update")
app.MainLoop()
I found a temporary solution using self.Raise() but again this has some strange behaviour:
e.g.
The Raise() has to be immediately after the Update(MaxValue) which closes the progressDialog.
If there is another task in between, the main application stay hidden behind other windows.
# This works
self.progress_dlg.Update(100)
self.Raise()
# This does not
self.progress_dlg.Update(100)
time.sleep(3)
self.Raise()
does anyone have a similar experience on Windows10 & wxPython 4.1.1 ?
Thanks in advance for any help,
GabboCH