You can roll your eyes as much as you want to but running the code suggests eye rolling is inappropriate.
The posted code with a wx.SearchCtrl rather than TextCtrl
(‘4.2.1 gtk3 (phoenix) wxWidgets 3.2.2.1’)
import wx
class TitleBar(wx.TopLevelWindow):
def __init__(self, parent, **kwargs):
super().__init__(parent,
style=wx.FRAME_FLOAT_ON_PARENT|wx.NO_BORDER, **kwargs)
self.btn = wx.SearchCtrl(self, -1, "Search...")
self.Fit()
def resize(evt):
w, h = self.Size
W, H = self.Parent.Size
self.Position = self.Parent.ScreenPosition + (W-10-w, 50-h)
evt.Skip()
self.Parent.Bind(wx.EVT_SIZE, resize)
self.Parent.Bind(wx.EVT_MOVE, resize)
class TestFrame(wx.Frame):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.MenuBar = wx.MenuBar()
menu = wx.Menu()
self.Bind(wx.EVT_MENU,
lambda v: self.Close(),
menu.Append(wx.ID_EXIT, 'Exit\tCtrl-w'))
self.MenuBar.Append(menu, 'File')
self.tb = TitleBar(self)
self.tb.Show()
if __name__ == "__main__":
app = wx.App()
frm = TestFrame(None)
frm.Show()
app.MainLoop()
Result:

The searchctrl is stuck in the bottom panel as a window that needs to be clicked on to be seen.
The posted code with wx.STAY_ON_TOP and a size
import wx
class TitleBar(wx.TopLevelWindow):
def __init__(self, parent, **kwargs):
super().__init__(parent,
style=wx.FRAME_FLOAT_ON_PARENT|wx.STAY_ON_TOP|wx.NO_BORDER, **kwargs)
self.btn = wx.SearchCtrl(self, -1, "Search...", size=(250,25))
self.Fit()
def resize(evt):
w, h = self.Size
W, H = self.Parent.Size
self.Position = self.Parent.ScreenPosition + (W-10-w, 50-h)
evt.Skip()
self.Parent.Bind(wx.EVT_SIZE, resize)
self.Parent.Bind(wx.EVT_MOVE, resize)
class TestFrame(wx.Frame):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.MenuBar = wx.MenuBar()
menu = wx.Menu()
self.Bind(wx.EVT_MENU,
lambda v: self.Close(),
menu.Append(wx.ID_EXIT, 'Exit\tCtrl-w'))
self.MenuBar.Append(menu, 'File')
self.tb = TitleBar(self)
self.tb.Show()
if __name__ == "__main__":
app = wx.App()
frm = TestFrame(None)
frm.Show()
app.MainLoop()
Result:
