颜色表框行我有一个表格框,其中有文本,也有按钮,我想给它上色超过 1 种颜色
col1 = {1, 2, 3};
col2 = {1, 2, 3};
col3 = {1, 2, 3};
myPlatform = New Window( "test",
tb = Table Box(
Number Col Box( "a", col1 ),
Number Col Box( "b", col2 ),
Number Col Box( "c", col3 ),
bb = Col Box( "Open Graph" )
)
);
bblist = {};
For( i = 1, i <= 3, i++,
bb_expr = Eval Insert( "\[bblist[i] = buttonbox("ok")]\" );
Eval( Parse( bb_expr ) );
bb << append( bblist[i] );
);
tb << Set Selectable Rows(1);
dt = tb << Make into Data Table( invisible );
rs = dt << Get Rows Where( :a > 1 );
tb << Set Selected Rows( rs );
tb << Set Selected Row Color( "red" );
rs = dt << Get Rows Where( :a == 1 );
tb << Set Selected Rows( rs );
tb << Set Selected Row Color( "green" );问题是,如果我删除最后 2 行,它会将最后 2 行着色为红色,但如果我运行最后 2 行,它会删除顶行的红色和绿色,而不是将红色保留为出色地
在运行最后两行之前:

运行最后两行后

有没有办法为表格框着色超过一种颜色? (我希望它有红色和绿色)
我也尝试过使用日记,但后来我不确定如何添加按钮。
谢谢!
大规模定制回复:表格框行的颜色您可以通过在打开的窗口中的按钮之一上使用“设置脚本”来轻松检查问题所在:

i 是参数,而它应该是数字。 您可以使用 Eval(Parse()) 方法来修复它:
For( i = 1, i <= 3, i++,
Insert Into(bblist, Eval(Parse("buttonbox(\!"test"||char(i)||"\!",newFunc("||char(i)||"))")));
);或 Eval(Eval Expr()):
For( i = 1, i <= 3, i++,
Eval(EvalExpr(Insert Into(bblist, buttonbox("test"||char(expr(i)),newFunc(expr(i))))));
);您希望设置脚本看起来像这样(至少在本例中):

做到这一点的“最佳”方法很可能高度依赖于应用程序。
回复:表格框行的颜色谢谢!这有很大帮助
我还有最后一个问题:
使用此代码,我尝试在函数中为每个按钮创建不同的值。
所以在这个例子中,如果我点击按钮 1,它应该打印 1,如果我点击 2,它应该打印 2,依此类推。
但由于某种原因,该值不会“粘住”,并且我单击的任何按钮都会显示 4。(4 是循环结束后 i 的数量)
Names Default To Here(1);
dt = New Table("Untitled",
Add Rows(3),
Compress File When Saved(1),
New Column("a",
Numeric,
"Continuous",
Format("Best", 12),
Set Values([1, 2, 3])
),
New Column("b",
Numeric,
"Continuous",
Format("Best", 12),
Set Values([2, 2, 3])
),
New Column("c",
Numeric,
"Continuous",
Format("Best", 12),
Set Values([2, 2, 3])
),
invisible
);
newFunc = function({i},
print(i);
);
dt << Select Where(:a > 1);
For(i = 1, i <= N Cols(dt), i++,
Column(dt, i) << Color Cells("Red");
);
dt << Clear Select;
dt << Select Where(:a == 1);
For(i = 1, i <= N Cols(dt), i++,
Column(dt, i) << Color Cells("Green");
);
dt << Clear Select;
rep = dt << get as report;
Close(dt, no save);
nw = New Window("Example",
hlb = h list box()
);
bblist = Expr(col box("Open Graph"));
For( i = 1, i <= 3, i++,
Insert Into(bblist, buttonbox("test"||char(i),newFunc(i)));
);
rep << append(bblist);
hlb << append(rep);
tb = (hlb << XPath("//TableBox"))[1];
tb << Set Scrollable(5,5);有没有办法来解决这个问题?
回复:表格框行的颜色不完全确定那里出了什么问题(可能是 Col Box() 不会将列表作为参数,因为它似乎需要逗号分隔的显示框)。 但这可能是一种方法:
bblist = Expr(col box("Open Graph"));
For( i = 1, i <= 3, i++,
Insert Into(bblist, buttonbox("test"||char(i)));
);
rep << append(bblist);
hlb << append(rep);回复:表格框行的颜色谢谢!这很有帮助!
但如果我想动态创建按钮怎么办
bblist = {};
For( i = 1, i <= 3, i++,
bb_expr = Eval Insert( "\[bblist[i] = buttonbox("test")]\" );
Eval( Parse( bb_expr ) );
bb << append( bblist[i] );
);当我尝试做的时候
rep << append(Col Box("Open Graph", bb));它不起作用
有什么建议吗?
回复:表格框行的颜色我有一个脚本,我想做一些类似的事情(最后我放弃了它,并为应用程序采用了不同的方法,因为它无缘无故地对我的口味来说有点太复杂了)。
我对其进行了一些修改,这将为您提供基本窗口:
Names Default To Here(1);
dt = New Table("Untitled",
Add Rows(3),
Compress File When Saved(1),
New Column("a",
Numeric,
"Continuous",
Format("Best", 12),
Set Values([1, 2, 3])
),
New Column("b",
Numeric,
"Continuous",
Format("Best", 12),
Set Values([2, 2, 3])
),
New Column("c",
Numeric,
"Continuous",
Format("Best", 12),
Set Values([2, 2, 3])
),
invisible
);
dt << Select Where(:a > 1);
For(i = 1, i <= N Cols(dt), i++,
Column(dt, i) << Color Cells("Red");
);
dt << Clear Select;
dt << Select Where(:a == 1);
For(i = 1, i <= N Cols(dt), i++,
Column(dt, i) << Color Cells("Green");
);
dt << Clear Select;
rep = dt << get as report;
Close(dt, no save);
nw = New Window("Example",
hlb = h list box()
);
rep << append(Col Box("Open Graph", Button Box("ok"),Button Box("ok"),Button Box("ok")));
hlb << append(rep);
tb = (hlb << XPath("//TableBox"))[1];
tb << Set Scrollable(5,5);想法是给数据表着色,将数据表作为报告获取,向该报告添加按钮,最后将其附加到新窗口(并调整大小)。
回复:表格框行的颜色即使你不能用表格框来做到这一点,还有其他方法吗?问题是我还需要以某种方式向其添加按钮