My app requires me to place widgets on top of awx.html2 panel.
I’ve tried different panels and positioning options, to no avail. The wx.html2 panel is always the top most panel and any defined widgets are below it, regardless of setting Lower() or Raise().
I have verified that I can replace the wx.html2 widget with a wx.StaticText widget and as I expect can position widgets on top, so this appears to be an issue only with the html2 widget.
As far as I remember, wxWidgets - and by extension wxPython - makes no guarantees nor promises when it comes to the z-order of overlapping widgets. I believe the behaviour is undefined.
It might be possible to make it work - I have no idea how as I haven’t ever done it myself. It may also turn out to be impossible to make it cross-platform.
Do you really need other widgets on top of a wx.html2 window? What type of widgets? Do you have a sketch of how your app should look like?
You’ll note that the app overlays the page’s header, while still allowing the user to select the html widgets on the displayed page. The app sets the hidden area by resizing a StaticText box’s height to remove just the unwanted section at the top of the web page.
Having tried to reproduce it in my prototype, however, I found that wx.html2 is unable to display the loop at all, which is very disappointing as I was hoping to take advantage of the smaller library with less restrictive licensing terms (even though I plan on offering the App for free.
The page that I was trying to display in my prototype (that fails to render at all) is: https://aviationweather.gov.gfa/#cigvis. In trying to debug why the page won’t display, it appears that there is a problem with the javascript that displays the loops.
well, Ithink there is always the possibility of having a frame stay on top of html2, but the positioning must be handmade (in contrast to those lovely sizers)
import wx
import wx.html2
class WebBrowser(wx.Frame):
def __init__(self, parent):
super().__init__(parent)
wx.html2.WebView.New(self).LoadURL('https://docs.wxpython.org/')
def evt_destroy(_):
if parent.__nonzero__():
parent.Destroy()
self.Bind(wx.EVT_WINDOW_DESTROY, evt_destroy)
self.Show()
class Gui(wx.Frame):
def __init__(self, parent):
super().__init__(parent, title='Browser with overlay',
style=wx.DEFAULT_FRAME_STYLE|wx.STAY_ON_TOP)
WebBrowser(self)
self.Show()
app = wx.App()
Gui(None)
app.MainLoop()
Unfortunately, this opens a new window with the browser in it, not underlying the GUI frame, as I wanted. I had tried this option earlier and got the windows to always be synchronized (one directly on top of the other) moving both when the top window moved. But I ran into problems resizing the top window when the bottom window was resized using the lower right corner.