I'm trying to create a floating toolbar with buttons that I want to be autosized to the minimum to
hold the buttons. I'm flailing.
···
#-----------------------------------------------------------------------------------
import wx
class Pallet(wx.Frame):
def __init__(self, *args, **kwargs):
super(Pallet,self).__init__(*args, **kwargs)
self.panel = wx.Panel(self, wx.ID_ANY)
self.panel.SetSizer(wx.BoxSizer(wx.HORIZONTAL))
self.createButtons()
self.Show()
def buttonLabels(self):
return ("Button1", "Button2", "Button3")
def createButtons(self):
labels= self.buttonLabels()
buttonSize=(70,30)
sizer=self.panel.GetSizer()
for label in labels:
button = wx.Button(self.panel, wx.ID_ANY, label, size=buttonSize)
sizer.Add(button,0,wx.ALIGN_CENTER)
class MyApp(wx.App):
def OnInit(self):
pallet = Pallet(None,wx.ID_ANY,style=wx.FRAME_TOOL_WINDOW)
pallet.Show()
if __name__ == '__main__':
app = MyApp(0)
app.MainLoop()
##-----------------------------------------------------------------------------------
What do I need to add to get the frame to shrink to the minimum size to hold the panel, holding the sizer, holding the buttons?
The code above is a total flail. The panel isn't maximizing size, The frame isn't shrinking...
If I skip the wx.FRAME_TOOL_WINDOW style, then just the sizing is wrong. The panel size problem goes away.
TIA,
Danny