.. wxPython Phoenix documentation This file was generated by Phoenix's sphinx generator and associated tools, do not edit by hand. Copyright: (c) 2011-2020 by Total Control Software License: wxWindows License .. include:: headings.inc .. currentmodule:: wx.lib.layoutf .. highlight:: python .. _wx.lib.layoutf.Layoutf: ========================================================================================================================================== |phoenix_title| **wx.lib.layoutf.Layoutf** ========================================================================================================================================== The class Layoutf(wxLayoutConstraints) presents a simplification of the wxLayoutConstraints syntax. The name Layoutf is chosen 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: 1. [numerical argument] for example ``r!100`` -> lc.right.Absolute(100) ) and ``w*`` -> lc.width.AsIs() 2. [numerical argument] # for example ``t_10#2`` -> lc.top.Below(, 10) 3. [numerical argument]# for example ``w%h50#2`` -> lc.width.PercentOf(, wx.Height, 50) and ``t=b#1`` -> lc.top.SameAs(, wx.Bottom) Which one you need is defined by the type. The following take type 1 (no object to compare with): * '!': 'Absolute', '?': 'Unconstrained', '*': 'AsIs' These take type 2 (need to be compared with another object) * '<': 'LeftOf', '>': 'RightOf', '^': 'Above', '_': 'Below' These take type 3 (need to be compared to another object attribute) * '=': 'SameAs', '%': 'PercentOf' For all types, the letter can be any of * 't': 'top', 'l': 'left', 'b': 'bottom', * 'r': 'right', 'h': 'height', 'w': 'width', * 'x': 'centreX', 'y': 'centreY' If the operation takes an (optional) numerical argument, place it in [numerical argument]. For type 3 directives, the letter can be any of * 't': 'wxTop', 'l': 'wxLeft', 'b': 'wx.Bottom' * 'r': 'wxRight', 'h': 'wxHeight', 'w': 'wx.Width', * 'x': 'wxCentreX', 'y': 'wx.CentreY' Note that these are the same letters as used for , so you'll only need to remember one set. Finally, the object whose attribute is referred to, is specified by #, where 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 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. | |class_hierarchy| Class Hierarchy ================================= .. raw:: html
Inheritance diagram for class Layoutf:
| |super_classes| Known Superclasses ================================== :class:`wx.LayoutConstraints` | |method_summary| Methods Summary ================================ ================================================================================ ================================================================================ :meth:`~wx.lib.layoutf.Layoutf.__init__` Initialize self. See help(type(self)) for accurate signature. :meth:`~wx.lib.layoutf.Layoutf.debug_pack` :meth:`~wx.lib.layoutf.Layoutf.pack` ================================================================================ ================================================================================ | |api| Class API =============== .. class:: Layoutf(wx.LayoutConstraints) The class Layoutf(wxLayoutConstraints) presents a simplification of the wxLayoutConstraints syntax. The name Layoutf is chosen 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: 1. [numerical argument] for example ``r!100`` -> lc.right.Absolute(100) ) and ``w*`` -> lc.width.AsIs() 2. [numerical argument] # for example ``t_10#2`` -> lc.top.Below(, 10) 3. [numerical argument]# for example ``w%h50#2`` -> lc.width.PercentOf(, wx.Height, 50) and ``t=b#1`` -> lc.top.SameAs(, wx.Bottom) Which one you need is defined by the type. The following take type 1 (no object to compare with): * '!': 'Absolute', '?': 'Unconstrained', '*': 'AsIs' These take type 2 (need to be compared with another object) * '<': 'LeftOf', '>': 'RightOf', '^': 'Above', '_': 'Below' These take type 3 (need to be compared to another object attribute) * '=': 'SameAs', '%': 'PercentOf' For all types, the letter can be any of * 't': 'top', 'l': 'left', 'b': 'bottom', * 'r': 'right', 'h': 'height', 'w': 'width', * 'x': 'centreX', 'y': 'centreY' If the operation takes an (optional) numerical argument, place it in [numerical argument]. For type 3 directives, the letter can be any of * 't': 'wxTop', 'l': 'wxLeft', 'b': 'wx.Bottom' * 'r': 'wxRight', 'h': 'wxHeight', 'w': 'wx.Width', * 'x': 'wxCentreX', 'y': 'wx.CentreY' Note that these are the same letters as used for , so you'll only need to remember one set. Finally, the object whose attribute is referred to, is specified by #, where 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 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. .. method:: __init__(self,pstr=None,winlist=None) Initialize self. See help(type(self)) for accurate signature. .. method:: debug_pack(self, pstr, winlist) .. method:: pack(self, pstr, winlist)