vlistEx 控件需要使用特定的数据结构
使用 fields 定义表头
使用 [@rowindex] 可以自动生成行号
数据需要通过 setTable 方法设置
索引注意事项:
aardio 中数组索引从 0 开始
Python 返回的元组在 aardio 中被转换为数组,同样使用从 0 开始的索引
数据格式:
var t = { fields={"序号","值1","值2","值3"} };
var tt = {};
tt["序号"] = "[@rowindex]";
tt["值1"] = tostring(pyList[0]);
tt["值2"] = tostring(pyList[1]);
tt["值3"] = tostring(pyList[2]);
table.push(t, tt);
表格设置:
mainForm.listview.setTable(t,,{50,150,150,150},1);
这个实现现在可以正确地:
显示 Python 返回的数据
自动生成行号
完整实例代码:
Code AardioLine:40复制
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.33.34.35.36.37.38.39.40.import
win
.ui;import
console;import
py3;import
godking.vlistEx;- mainForm =
win
.form(text="Python结果显示"
;right=500
;bottom=400
) - mainForm.add(
- vlist={cls=
"vlistEx"
;left=10
;top=10
;right=384
;bottom=344
;db=1
;dl=1
;dr=1
;dt=1
;edge=1
;transparent=1
;z=1
} - )
var
pyCode = - py3.exec(pyCode)
var
pyList = py3.main.getList(12
,23
);var
t = { fields={"序号"
,"年龄"
,"金额"
,"备注"
} };for
(i=1
;20
;1
){-
var
tt={}; - tt[
"序号"
]="[@rowindex]"
; - tt[
"年龄"
]=pyList[0
]; - tt[
"金额"
]=pyList[1
]; - tt[
"备注"
]=pyList[2
]; - ..
table
.push(t,tt); - }
- mainForm.vlist.setTable(t,,
100
,1
); - mainForm.show();
win
.loopMessage();