jeudi 30 juin 2016

wxpython sizers - does WX.EXPAND make a difference in spacers?

Following good advice in the BoxSizer from the ground Up tutorial I am refactoring code to factor out the wx.LEFT/RIGHT/TOP/BOTTOM flags into "spacers" - so:

horizontal_sizer.Add(someControl, 0, wx.LEFT, border)

becomes:

horizontal_sizer.Add((border, 0))
horizontal_sizer.Add(someControl)

For the case above I am sure they are completely equivalent. However if wx.EXPAND and a non zero proportion is specified as in:

horizontal_sizer.Add(someControl, proportion, wx.LEFT | wx.EXPAND, border)

is this below:

horizontal_sizer.Add((border, 0))
horizontal_sizer.Add(someControl, proportion, wx.EXPAND)

completely equivalent to the above ? Visually they do seem identical but is there anything I am missing ? In other words does the wx.EXPAND influence the border and if yes how ?

Of course the examples above are trivial but in complex sizers layouts the above transformation (as suggested in the tutorial) greatly simplifies the code and makes common UI patterns stand out, that were plain unreadable in the mess of OR'ed flags and numbers.

Aucun commentaire:

Enregistrer un commentaire