edifice.GridView#
- class edifice.GridView(layout='', key_to_code=None, **kwargs)[source]#
Bases:
QtWidgetElement
[QWidget
]Grid layout widget for rendering children on a 2D rectangular grid.
Underlying Qt Layout QGridLayout
Grid views allow you to precisely control 2D positioning of widgets. specifying the exact location of children relative to each other (with proper alignment) requires extensive fine tuning of style attributes. The GridView allows you to lay out widgets at specified grid indices and size.
Children will be laid out according to the layout argument. Each child is assigned a character code (by default, the first character of the key; this can be changed via the key_to_code prop). The layout argument describes pictorially where the child should be laid out. For example:
aabc aabd effg
describes a layout of 7 children (labeled a to g) in a 3x4 grid. Child a occupies the top left 2x2 portion of the grid, child b occupies a 2x1 portion of the grid starting from the third column of the first row, etc.
You can also leave certain spots empty using ‘_’:
aa__ aabc
Here is a complete example of using GridView:
def render(self): return ed.GridView(layout=''' 789+ 456- 123* 00./ ''')( ed.Button("7").set_key("7"), ed.Button("8").set_key("8"), ed.Button("9").set_key("9"), ed.Button("+").set_key("+"), ed.Button("4").set_key("4"), ed.Button("5").set_key("5"), ed.Button("6").set_key("6"), ed.Button("-").set_key("-"), ed.Button("1").set_key("1"), ed.Button("2").set_key("2"), ed.Button("3").set_key("3"), ed.Button("*").set_key("*"), ed.Button("0").set_key("0"), ed.Button(".").set_key("."), ed.Button("*").set_key("/"), )
- Parameters:
layout – description of layout as described above
key_to_code – mapping from key to a single character representing that child in the layout string
Methods
__init__
([layout, key_to_code])register_ref
(reference)Registers provided
Reference
to this Element.set_key
(key)Set the key of an
Element
.Attributes
children
The children of this Element.
props
The props of this Element.
underlying
The underlying QWidget, which may not exist if this Element has not rendered.