I’ve added some controls inside the panel of a Python programme I’m developing. But the close[X], expand, and minimize window buttons from my Panel must be hidden or removed to meet the criteria. What would I do? How would I enter this in WxPython?
It’s not clear to me how you are getting Close, Minimize and Maximize buttons on a Panel. Normally those buttons only appear on top-level windows such as Frame and Dialog.
Is there a particular reason why you say “not Frame”? It is fairly easy to remove those buttons (and also the title bar) from a Frame by passing the appropriate style value, as shown in the example below.
import wx
class MyFrame(wx.Frame):
def __init__(self, *args, **kw):
super().__init__(*args, **kw)
panel = wx.Panel(self)
panel.SetBackgroundColour(wx.Colour(160, 210, 240))
sizer = wx.BoxSizer(wx.VERTICAL)
b1 = wx.Button(panel, label="Do Something")
sizer.Add(b1, 0, wx.ALIGN_CENTRE|wx.TOP, 16)
b2 = wx.Button(panel, label="Do Other")
sizer.Add(b2, 0, wx.ALIGN_CENTRE|wx.TOP, 8)
panel.SetSizer(sizer)
sizer.Layout()
self.Bind(wx.EVT_BUTTON, self.OnButton, b1)
self.Bind(wx.EVT_BUTTON, self.OnButton, b2)
def OnButton(self, evt):
print(evt.GetEventObject().GetLabel())
app = wx.App()
f1 = MyFrame(None, title="Title", pos=(100, 0), style=wx.CAPTION)
f1.Show()
f2 = MyFrame(None, pos=(100, 300), style=wx.BORDER_NONE)
f2.Show()
app.MainLoop()