Here is a compact text based alternative to pyui.
https://github.com/balachandrana/textlayout
I have used the existing examples calculator and colormixer for illustrating layout specification . A compact representation of attribute initialization is getting implemented. The implementation is in early stage. Since there is a discussion related to positioning ui element, I thought this may be useful in getting some comments on this layout specification.
https://forum.omz-software.com/topic/3402/share-position-a-ui-control-in-a-view
The layout text specifies position and size of each ui element in the application. The lines in the text represent rows in the grid and each character in a line represents a grid cell. Each ui element is represented by a single letter (b - represents button, s - represents slider l - label etc.) A blank cell is represented '*'.If an element spans more than a cell, the characters '-' and '|' can be used to specify horizontal and vertical spanning. Overlaps are not allowed currently.
Currently attributes are represented by a dictionary. A compact representation is getting implemented.
Here is a sample layout specification for counter application with one label (counter value) and one button (tapping the button increments the counter). The label element is a single row with four horizontal cells and the button element is a rectangular box of 3*4 cells.
import ui, textlayout
cnt = 0
def button_action(sender):
global cnt
cnt += 1
sender.superview['label1'].text = 'Counter:' + str(cnt)
layout_text = '''\
********
**l---**
********
********
**b---**
**|--|**
**|--|**
********
********
'''
attributes = {
'b':[
{'action':button_action,
'font' :('Helvetica', 20),
'title':'Tap to increment counter'
}],
'l':[
{
'text': 'Counter:0',
'alignment': ui.ALIGN_CENTER,
'font':('Helvetica', 20)
}
]
}
v = textlayout.BuildView(layout_text, width=600, height=600, view_name='Counter',
attributes=attributes).build_view()
v.present('popover')