I’m trying to set two buttons so that one is anchored to the left of the sizer and the other to the right. I tried using wx.lib.anchors.LayoutAnchors as follows:
from wx.lib.anchors import LayoutAnchors . . . sizer_2 = wx.BoxSizer(wx.HORIZONTAL) self.btnSave = wx.Button(self.panel_1, wx.ID_ANY, "Save") self.btnSave.SetToolTip("Save comment and close") self.btnSave.SetConstraints(LayoutAnchors(self.btnSave, left=1, top=0, right=0, bottom=0)) sizer_2.Add(self.btnSave, 0, 0, 0) self.btnIMDB = wx.Button(self.panel_1, wx.ID_ANY, "IMDB") self.btnIMDB.SetToolTip("Fetch info from IMDB") self.btnIMDB.SetConstraints(LayoutAnchors(self.btnIMDB, left=0, top=0, right=1, bottom=0)) sizer_2.Add(self.btnIMDB, 0, 0, 0)
but I just get two buttons jammed together on the left edge. After looking at the example in wxDemo I came to the conclusion that what actually happens is that anchoring to the right just maintains its original distance from the right edge on resize. It does not (like vb.NET) “glue” it to the right edge. But when I resized my panel the IMDB button, alas, remained glued to the Save button so that assumption was also incorrect. Is there a simple way to say I want the IMDB button “stuck” to the right edge?