-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample.py
More file actions
33 lines (26 loc) · 867 Bytes
/
example.py
File metadata and controls
33 lines (26 loc) · 867 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import pygrid as g
schema = g.RowSchema(
[
# Every column must nave a name
{'name': 'ID'}
,{'name': 'PRODUCT'}
# Specify 'left' or 'right' for cell alignment (left by default)
,{'name': 'PRICE', 'align': 'right'}
])
num_columns = len(schema)
rs = g.RowSet(schema)
header = g.Row(num_columns).append(*[c['name'] for c in schema.columns])
row_1 = g.Row(num_columns).append('001', 'Apple Mac Pro', '6,000.00')
row_2 = g.Row(num_columns).append('002', 'Apple iPhone', '1,100.00')
row_3 = g.Row(num_columns).append('003', 'Apple iPad', '1,200.00')
row_4 = g.Row(num_columns).append('004', 'Apple Watch', '700.00')
row_5 = g.Row(num_columns).append('005', 'Apple Home Pod', '200.00')
rs.append(header)
rs.append(row_1)
rs.append(row_2)
rs.append(row_3)
rs.append(row_4)
rs.append(row_5)
product_grid = g.Table()
product_grid.append(rs)
print(product_grid)