Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/user-interface/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
User interface 将Tk网格小部件集成到笔记本布局中_User Interface_Tcl_Prototype_Tk - Fatal编程技术网

User interface 将Tk网格小部件集成到笔记本布局中

User interface 将Tk网格小部件集成到笔记本布局中,user-interface,tcl,prototype,tk,User Interface,Tcl,Prototype,Tk,我想快速创建一个GUI原型,并认为Tk可以简单易学。但是,我未能将示例网格视图(框架)集成到笔记本小部件的一个选项卡中。pack命令将网格放在笔记本的顶部,我无法找到正确的选项。还是我的方法错了 代码如下: ttk::frame .c ttk::frame .c.f -borderwidth 5 -relief sunken -width 200 -height 100 ttk::label .c.namelbl -text Name ttk::entry .c.name ttk::checkb

我想快速创建一个GUI原型,并认为Tk可以简单易学。但是,我未能将示例网格视图(框架)集成到笔记本小部件的一个选项卡中。
pack
命令将网格放在笔记本的顶部,我无法找到正确的选项。还是我的方法错了

代码如下:

ttk::frame .c
ttk::frame .c.f -borderwidth 5 -relief sunken -width 200 -height 100
ttk::label .c.namelbl -text Name
ttk::entry .c.name
ttk::checkbutton .c.one -text One -variable one -onvalue 1; set one 1
ttk::checkbutton .c.two -text Two -variable two -onvalue 1; set two 0
ttk::checkbutton .c.three -text Three -variable three -onvalue 1; set three 1
ttk::button .c.ok -text Okay
ttk::button .c.cancel -text Cancel

grid .c -column 0 -row 0
grid .c.f -column 0 -row 0 -columnspan 3 -rowspan 2
grid .c.namelbl -column 3 -row 0 -columnspan 2
grid .c.name -column 3 -row 1 -columnspan 2
grid .c.one -column 0 -row 3
grid .c.two -column 1 -row 3
grid .c.three -column 2 -row 3
grid .c.ok -column 3 -row 3
grid .c.cancel -column 4 -row 3

# Notebook --> shall contain above grid in third tab
ttk::notebook .n  -width 600 -height 200
ttk::frame .n.f1; 
ttk::frame .n.f2; 
.n add .n.f1 -text "FirstTab"
.n add .n.f2 -text "SecondTab"
.n add .c -text "GridContent"
pack [label .n.f1.f1 -background red -foreground white -text "First"]
pack [label .n.f2.f2 -background red -foreground white -text "Second"]
pack .c 
pack .n 
ttk::notebook::enableTraversal .n

ttk::notebook
的内容小部件的堆叠顺序必须高于笔记本才能正常工作,并且必须由笔记本本身管理,而不是由
pack
grid
管理(尽管它们的内容可以按任何方式管理);笔记本电脑是一种特殊的几何管理器,也是一种小部件。(Tk还有其他几个小部件也可以做到这一点。)

要修复堆叠顺序,请在
.n
小部件之后创建
.c
小部件,或在创建
.n
之后创建
raise.c
。请注意,父窗口小部件的子部件(除了少数情况下的
顶级
s和
菜单
s)始终位于父部件的顶部,并且始终由其父部件绑定/剪裁

要解决管理问题,只需不
pack.c
;把它加到笔记本上就足够了。您可以根据需要对
.c
的内容进行打包或网格化


有了这两个小补丁,您的UI似乎可以正常工作

ttk::frame .c
ttk::frame .c.f -borderwidth 5 -relief sunken -width 200 -height 100
ttk::label .c.namelbl -text Name
ttk::entry .c.name
ttk::checkbutton .c.one -text One -variable one -onvalue 1; set one 1
ttk::checkbutton .c.two -text Two -variable two -onvalue 1; set two 0
ttk::checkbutton .c.three -text Three -variable three -onvalue 1; set three 1
ttk::button .c.ok -text Okay
ttk::button .c.cancel -text Cancel

grid .c -column 0 -row 0
grid .c.f -column 0 -row 0 -columnspan 3 -rowspan 2
grid .c.namelbl -column 3 -row 0 -columnspan 2
grid .c.name -column 3 -row 1 -columnspan 2
grid .c.one -column 0 -row 3
grid .c.two -column 1 -row 3
grid .c.three -column 2 -row 3
grid .c.ok -column 3 -row 3
grid .c.cancel -column 4 -row 3

# Notebook --> shall contain above grid in third tab
ttk::notebook .n  -width 600 -height 200
ttk::frame .n.f1; 
ttk::frame .n.f2; 
.n add .n.f1 -text "FirstTab"
.n add .n.f2 -text "SecondTab"
.n add .c -text "GridContent"
raise .c;   # <<<< YES! YOU DO WANT THIS! <<<< YES! <<<< YES! <<<< YES! <<<<
pack [label .n.f1.f1 -background red -foreground white -text "First"]
pack [label .n.f2.f2 -background red -foreground white -text "Second"]
# pack .c;  # <<<< NO! YOU DO NOT WANT THIS! <<<< NO! <<<< NO! <<<< NO! <<<<
pack .n 
ttk::notebook::enableTraversal .n
ttk::frame.c
ttk::frame.c.f-边框宽度5-浮雕凹陷-宽度200-高度100
ttk::label.c.namelbl-文本名称
ttk::entry.c.name
ttk::checkbutton.c.one-text-one-variable-one-onvalue 1;设定一个1
ttk::checkbutton.c.two-text-two-variable-two-onvalue 1;设置两个0
ttk::checkbutton.c.three-text-three-variable-three-onvalue 1;设定三个1
ttk::button.c.ok-文本ok
ttk::button.c.cancel-文本取消
grid.c-第0列-第0行
grid.c.f-第0列-第0行-第3列-第2行
grid.c.namelbl-第3列-第0行-第2列
grid.c.name-第3列-第1行-第2列
网格c.1-第0列-第3行
网格c.2-第1列-第3行
网格c.三-第2列-第3行
网格c.ok-第3列-第3行
网格c.取消-第4列-第3行
#笔记本-->应在第三个选项卡中包含上述网格
ttk::notebook.n-宽600-高200
ttk::frame.n.f1;
ttk::frame.n.f2;
.n添加.n.f1-文本“FirstTab”
.n添加.n.f2-文本“第二个选项卡”
.n add.c-文本“GridContent”
提高.c#