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

"[email protected]" <[email protected]> Fri, 1 Jan 2021 08:43:08 -0800 (PST)
Newsgroups gmane.comp.python.wxpython
Message-ID <[email protected]>
Thank you for sharing! Happy New Year!!!

On Friday, January 1, 2021 at 7:05:42 AM UTC-5 [email protected] wrote:

> On Wed, Dec 30, 2020 at 09:06, Alexander Makarenko <[email protected]> 
> 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
>

-- 
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 [email protected].
To view this discussion on the web visit https://groups.google.com/d/msgid/wxpython-users/a4f8b79d-9699-47a0-8cf5-4067d978bb48n%40googlegroups.com.