The class Layoutf(wxLayoutConstraints) presents a simplification of the wxLayoutConstraints syntax. The name Layoutf is choosen because of the similarity with C’s printf function.
Quick Example:
lc = Layoutf('t=t#1;l=r10#2;r!100;h%h50#1', (self, self.panel))
is equivalent to:
lc = wx.LayoutContraints()
lc.top.SameAs(self, wx.Top)
lc.left.SameAs(self.panel, wx.Right, 10)
lc.right.Absolute(100)
lc.height.PercentOf(self, wx.Height, 50)
Usage:
You can give a constraint string to the Layoutf constructor, or use the ‘pack’ method. The following are equivalent:
lc = Layoutf('t=t#1;l=r#2;r!100;h%h50#1', (self, self.panel))
and:
lc = Layoutf()
lc.pack('t=t#1;l=r#2;r!100;h%h50#1', (self, self.panel))
Besides ‘pack’ there’s also ‘debug_pack’ which does not set constraints, but prints traditional wxLayoutConstraint calls to stdout.
The calls to the Layoutf constructor and pack methods have the following argument list:
(constraint_string, objects_tuple)
Constraint String syntax:
Constraint directives are separated by semi-colons. You generally (always?) need four directives to completely describe a subwindow’s location.
A single directive has either of the following forms:
r!100
-> lc.right.Absolute(100) )
and w*
-> lc.width.AsIs()t_10#2
-> lc.top.Below(<second obj>, 10)w%h50#2
-> lc.width.PercentOf(<second obj>, wx.Height, 50) and t=b#1
-> lc.top.SameAs(<first obj>, wx.Bottom)Which one you need is defined by the <compare operation> type. The following take type 1 (no object to compare with):
These take type 2 (need to be compared with another object)
These take type 3 (need to be compared to another object attribute)
For all types, the <own attribute> letter can be any of
If the operation takes an (optional) numerical argument, place it in [numerical argument]. For type 3 directives, the <compare attribute> letter can be any of
Note that these are the same letters as used for <own attribute>, so you’ll only need to remember one set. Finally, the object whose attribute is refered to, is specified by #<compare object nr>, where <compare object nr> is the 1-based (stupid, I know, but I’ve gotten used to it) index of the object in the objects_tuple argument.
Bugs:
Not entirely happy about the logic in the order of arguments after the <compare operation> character.
Not all wxLayoutConstraint methods are included in the syntax. However, the type 3 directives are generally the most used. Further excuse: wxWindows layout constraints are at the time of this writing not documented.
Layoutf
(wx.LayoutConstraints)¶The class Layoutf(wxLayoutConstraints) presents a simplification of the wxLayoutConstraints syntax. The name Layoutf is choosen because of the similarity with C’s printf function.
Quick Example:
lc = Layoutf('t=t#1;l=r10#2;r!100;h%h50#1', (self, self.panel))
is equivalent to:
lc = wx.LayoutContraints()
lc.top.SameAs(self, wx.Top)
lc.left.SameAs(self.panel, wx.Right, 10)
lc.right.Absolute(100)
lc.height.PercentOf(self, wx.Height, 50)
Usage:
You can give a constraint string to the Layoutf constructor, or use the ‘pack’ method. The following are equivalent:
lc = Layoutf('t=t#1;l=r#2;r!100;h%h50#1', (self, self.panel))
and:
lc = Layoutf()
lc.pack('t=t#1;l=r#2;r!100;h%h50#1', (self, self.panel))
Besides ‘pack’ there’s also ‘debug_pack’ which does not set constraints, but prints traditional wxLayoutConstraint calls to stdout.
The calls to the Layoutf constructor and pack methods have the following argument list:
(constraint_string, objects_tuple)
Constraint String syntax:
Constraint directives are separated by semi-colons. You generally (always?) need four directives to completely describe a subwindow’s location.
A single directive has either of the following forms:
r!100
-> lc.right.Absolute(100) )
and w*
-> lc.width.AsIs()t_10#2
-> lc.top.Below(<second obj>, 10)w%h50#2
-> lc.width.PercentOf(<second obj>, wx.Height, 50) and t=b#1
-> lc.top.SameAs(<first obj>, wx.Bottom)Which one you need is defined by the <compare operation> type. The following take type 1 (no object to compare with):
These take type 2 (need to be compared with another object)
These take type 3 (need to be compared to another object attribute)
For all types, the <own attribute> letter can be any of
If the operation takes an (optional) numerical argument, place it in [numerical argument]. For type 3 directives, the <compare attribute> letter can be any of
Note that these are the same letters as used for <own attribute>, so you’ll only need to remember one set. Finally, the object whose attribute is refered to, is specified by #<compare object nr>, where <compare object nr> is the 1-based (stupid, I know, but I’ve gotten used to it) index of the object in the objects_tuple argument.
Bugs:
Not entirely happy about the logic in the order of arguments after the <compare operation> character.
Not all wxLayoutConstraint methods are included in the syntax. However, the type 3 directives are generally the most used. Further excuse: wxWindows layout constraints are at the time of this writing not documented.
__init__
(self, pstr=None, winlist=None)¶debug_pack
(self, pstr, winlist)¶pack
(self, pstr, winlist)¶