Tkd小部件找不到行和列选项
我正在尝试使用Tkd小部件找不到行和列选项,d,tk,D,Tk,我正在尝试使用tkd包和以下代码创建一个简单的GUI应用程序: // modified from: https://github.com/nomad-software/tkd import tkd.tkdapplication; class Application : TkdApplication { auto labellist = ["First", "Second", "Third", "Fourth", "Fifth", "Sixth"
tkd
包和以下代码创建一个简单的GUI应用程序:
// modified from: https://github.com/nomad-software/tkd
import tkd.tkdapplication;
class Application : TkdApplication {
auto labellist = ["First", "Second", "Third", "Fourth", "Fifth", "Sixth", ];
override protected void initInterface() {
int ncol =0;
auto frame = new Frame(2, ReliefStyle.groove);
frame.pack(10);
foreach(lab; labellist){
auto label = new Label(frame, lab);
label.grid(row=nrow, column=0);
auto entry = new Entry(frame);
entry.grid(row=nrow, column=1);
nrow += 1;
}
auto exitButton = new Button(frame, "Exit").setCommand(&this.exitCommand).pack(10);
}
private void exitCommand(CommandArgs args) {
this.exit();
}
}
void main(string[] args){
auto app = new Application();
app.run();
}
但是,它给出了以下错误:
$ dub run
Performing "debug" build using /usr/bin/dmd for x86_64.
x11 1.0.21: target for configuration "tcltk-import" is up to date.
tcltk 8.6.5: target for configuration "library" is up to date.
tkd 1.1.12: target for configuration "library" is up to date.
tkdgui ~master: building configuration "application"...
source/app.d(15,15): Error: undefined identifier row
source/app.d(15,25): Error: undefined identifier column
source/app.d(17,15): Error: undefined identifier row
source/app.d(17,25): Error: undefined identifier column
source/app.d(18,4): Error: undefined identifier nrow
/usr/bin/dmd failed with exit code 1.
还提到了有关网格的详细信息。行和列是要输入的有效选项
问题在哪里以及如何解决。代码中有两个问题。以下是第一点:
label.grid(row=nrow, column=0);
^^^^ ^^^^^^^
D不支持您正在尝试使用的命名参数。相反,您需要使用位置参数:
label.grid(0, nrow);
FWIW,有一些建议将命名参数添加到D中,但到目前为止,还没有一个建议使用该语言
第二个问题是nrow
没有在任何地方定义。根据ncol
的存在以及它在任何地方都没有使用的事实判断,似乎您将代码从处理列更改为处理行,并且没有将ncol
的名称更改为nrow