well, once you know what you want (I don’t really) it should be achievable (at least in wxPython) ![]()
import wx
import wx.html2
class WebBrowser(wx.Frame):
def __init__(self, parent):
super().__init__(parent)
self.wv = wx.html2.WebView.New(self)
self.wv.LoadURL('https://docs.wxpython.org/')
self.height = None
self.position = self.GetPosition()
self.size = self.GetSize()
self.max = False
def evt_size(evt):
s = evt.GetSize()
h = self.height if self.height else s[1]
parent.SetPosition(self.GetPosition())
parent.SetSize(s[0], h)
evt.Skip()
self.Bind(wx.EVT_SIZE, evt_size)
self.Show()
def set_width(self, width):
self.SetSize(width, self.GetSize()[1])
def set_max(self, gui):
if self.max:
self.SetPosition(self.position)
if self.size[1] < 40:
self.size[1] = int(gui.GetSize()[1] + 40)
elif not gui.GetSize()[1] < self.size[1] - 20:
gui.SetSize((self.size[0], int(self.size[1] / 2)))
self.SetSize(self.size)
self.SetFocus()
self.max = False
else:
self.position = self.GetPosition()
self.size = self.GetSize()
self.SetPosition((0, 0))
self.SetSize(wx.DisplaySize())
self.max = True
class Gui(wx.Frame):
def __init__(self, parent):
super().__init__(parent, title='Html2 with overlay',
style=wx.DEFAULT_FRAME_STYLE
& ~(wx.MAXIMIZE_BOX) | wx.STAY_ON_TOP)
wb = WebBrowser(self)
pnl = wx.Panel(self)
hbox = wx.BoxSizer(wx.HORIZONTAL)
pnl.SetSizer(hbox)
btn = wx.Button(pnl, label='Maxi / Restore')
hbox.Add(btn, 0, wx.ALL, 10)
btn.Bind(wx.EVT_BUTTON, lambda _: wb.set_max(self))
btn = wx.Button(pnl, label='load http://www.google.com')
hbox.Add(btn, 0, wx.ALL, 10)
btn.Bind(wx.EVT_BUTTON, lambda _:
wb.wv.LoadURL('http://www.google.com'))
btn = wx.Button(pnl, label='load https://aviationweather.gov/gfa/#obs')
hbox.Add(btn, 0, wx.ALL, 10)
btn.Bind(wx.EVT_BUTTON, lambda _:
wb.wv.LoadURL('https://aviationweather.gov/gfa/#obs'))
pnl.Bind(wx.EVT_ENTER_WINDOW, lambda _: wb.SetFocus())
def evt_size(evt):
s = evt.GetSize()
wb.height = s[1]
wb.set_width(s[0])
evt.Skip()
self.Bind(wx.EVT_SIZE, evt_size)
def evt_move(evt):
wb.SetPosition(self.GetPosition())
evt.Skip()
self.Bind(wx.EVT_MOVE, evt_move)
s = self.GetSize()
s.SetHeight(int(s[1] / 2))
self.SetSize(s)
self.SetBackgroundColour('cyan')
self.SetTransparent(200)
self.Show()
app = wx.App()
Gui(None)
app.MainLoop()