wx.BusyInfo does not stick to parent, stays on top of other applications

64 views
Skip to first unread message

mbre...@gmail.com

unread,
Nov 4, 2020, 3:20:21 AM11/4/20
to wxPython-users
Dear all

I have some issues with wx.BusyInfo. I am not sure if I am doing something wrong, of if it's a bug in wxPython.

The wx.BusyInfo frame does not "stick" to its parent frame: it does not stay centered on the parent frame, and it does not move with the parent (like a normal modal dialog would). Also, maybe worse, if you bring another application to the front / focus, the BusyInfo stays on top of the windows that below to this other application, although it should be covered by those windows.

Here's the relevant code snipped from my application:
-------------------------------------
# Show busy box while tuning:
with wx.WindowDisabler():
      wait = wx.BusyInfo( "Tuning m/z scale...", parent=self._app.frame_main )
      while tune.is_running:
            sleep(0.1)
            wx.GetApp().Yield()
      del wait
-------------------------------------

Operating system: Debian Linux / Gnome-3
wxPython version & source: wxPython 4.0 from Debian repositories
Python version & source: Python 3 from Debian repositories

I have already reported this on GitHub, but no feedback so far (https://github.com/wxWidgets/Phoenix/issues/1835). Any help or insights would be highly welcome!

Thanks
Matthias

Scott Talbert

unread,
Nov 4, 2020, 9:37:20 AM11/4/20
to wxPython-users
Can you provide a self-contained runnable example that shows the problem?

Thanks,
Scott

Matthias Brennwald

unread,
Nov 4, 2020, 10:46:27 AM11/4/20
to wxpytho...@googlegroups.com


I made a simple demo program and a video to illustrate how this behaves on my system. I attached both (I hope the attachments work out).



wxBusyBox_demo.py
simplescreenrecorder-2020-11-04_16.42.40.mkv

Tim Roberts

unread,
Nov 4, 2020, 2:51:12 PM11/4/20
to wxpytho...@googlegroups.com
mbre...@gmail.com wrote:
>
> I have some issues with wx.BusyInfo. I am not sure if I am doing
> something wrong, of if it's a bug in wxPython.
>
> The wx.BusyInfo frame does not "stick" to its parent frame: it does
> not stay centered on the parent frame, and it does not move with the
> parent (like a normal modal dialog would).

I'm a little confused by this question.  A modal dialog does not
normally move with its parent, because the parent can't move. While a
modal dialog is displayed, the parent window should not be responding to
window messages at all, and therefore should not be movable.  The code
you have that does wx.GetApp().Yield() kind of violates the "rules" for
a modal dialog.

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


Matthias Brennwald

unread,
Nov 4, 2020, 4:21:37 PM11/4/20
to wxpytho...@googlegroups.com
On my GTK systems, the parent window _can_ move, and modal dialogs _do_ move with their parent window, see attachment.

No matter if the parent or the dialog can (not) move, the wx.BusyInfo box must not stay on top of windows of other applications -- this is just very wrong (as shown in the video attached to my previous message).

The code with the wx.GetApp().Yield() follows the third example from the wxPython/Phoenix documentation here:
simplescreenrecorder-2020-11-04_22.11.29.mkv

Alexander Makarenko

unread,
Dec 30, 2020, 12:57:43 PM12/30/20
to wxPython-users
I'm having the same issue, did you find a solution by any chance?

Andrea Gavana

unread,
Dec 30, 2020, 1:06:44 PM12/30/20
to wxpytho...@googlegroups.com


On Wed, 30 Dec 2020 at 18.57, Alexander Makarenko <alexan...@gmail.com> wrote:
I'm having the same issue, did you find a solution by any chance?

One easy and almost ready solution is to switch to wx.lib.agw.pybusyinfo. If you don’t like the behavior of it - which is pretty much the same as wx.BusyInfo - then it’s pure Python code and you can modify it the way you want it to be.

The other easy solution is to stop using wx.BusyInfo.

Andrea.


--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to wxpython-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/wxpython-users/6c4f4787-ca5a-48b2-b70c-01d64805cce0o%40googlegroups.com.

alexan...@gmail.com

unread,
Dec 30, 2020, 4:59:59 PM12/30/20
to wxPython-users
Makes sense, thank you

Matthias Brennwald

unread,
Jan 1, 2021, 7:05:42 AM1/1/21
to wxpytho...@googlegroups.com
On Wed, Dec 30, 2020 at 09:06, Alexander Makarenko <alexan...@gmail.com> wrote:

I'm having the same issue, did you find a solution by any chance?

Sorry for taking so long to reply on this. My solution was to ditch wx.BusyInfo, because it simply does not work as I think it should. I also considered the AGW solution, but that was very different from the native look-and-feel of the GUI, so I didn't look into this any further.

Here's how I made the "busy display" work for my case. My application works with a "main" window. So I decided to implement the "busy display" as part of my main window (code snipped below). Now I just use calls to frame_main.busy_box.activate( ... ), frame_main.busy_box.deactivate( ... ) and frame_main.busy_box.setup( ... ) to control the busy display from the main thread or from the separate long-running thread (wrapped into wx.CallAfter where necessary).

Cheers
Matthias


--------------------------------------------------


class frame_main(wx.Frame):

def __init__(self,app):

...
# Create "busy display" dialog box:
self.busy_box = busy_display(self)
...


--------------------------------------------------


class busy_display(wx.Dialog):

def __init__(self, parent):
# Create the dialog box
wx.Dialog.__init__(self, parent, style = wx.SIMPLE_BORDER )
self._panel = None
self.setup('Plase wait...')
self._is_active = False
def setup(self, infotext):
if self._panel is not None:
# kill the panel before recreating a new one:
self._panel.Destroy()
self._panel = wx.Panel(self, -1)
msg = wx.StaticText(self._panel, label=infotext, style=wx.ALIGN_CENTRE_HORIZONTAL )
h_sizer = wx.BoxSizer(wx.HORIZONTAL)
main_sizer = wx.BoxSizer(wx.VERTICAL)
h_sizer.Add(msg, 0, wx.CENTER)
main_sizer.Add((0,0), 1, wx.EXPAND)
main_sizer.Add(h_sizer, 0, wx.CENTER)
main_sizer.Add((0,0), 1, wx.EXPAND)
self._panel.SetSizer(main_sizer)
siz = main_sizer.ComputeFittingWindowSize(self)
siz.IncBy(wx.Size(80,50))
self.SetSize(siz)
def activate(self, message = 'Please wait...'):
# Show the dialog in modal mode
if not self._is_active:
self.setup(message)
self._is_active = True
self.ShowModal()
def deactivate(self):
# End the modal dialog (from the long-running process thread)
if self._is_active:
self.EndModal(0)
self._is_active = False

alexan...@gmail.com

unread,
Jan 1, 2021, 11:43:08 AM1/1/21
to wxPython-users
Thank you for sharing! Happy New Year!!!
Reply all
Reply to author
Forward
0 new messages