2016-02-23 42 views

回答

1

enter image description here

实例化一个新帧中,使用格把这个帧中的所述细胞。然后你可以实例化两个单选按钮并将它们排列在框架中。

package requite Tk 

ttk::label .c11 -text "Cell 1 1" 
ttk::label .c12 -text "Cell 1 2" 
ttk::label .c13 -text "Cell 1 3" 
grid .c11 -row 0 -column 0 
grid .c12 -row 0 -column 1 
grid .c13 -row 0 -column 2 

ttk::label .c21  -text "Cell 2 1" 
ttk::frame .frame 
ttk::label .c23  -text "Cell 2 3" 
grid .c21 -row 1 -column 0 
grid .frame -row 1 -column 1 
grid .c23 -row 1 -column 2 

    ttk::radiobutton .frame.rb1 -text "Rb1" 
    ttk::radiobutton .frame.rb2 -text "Rb2" 
    grid .frame.rb1 -row 0 -column 0 
    grid .frame.rb2 -row 0 -column 1 

ttk::label .c31 -text "Cell 3 1" 
ttk::label .c32 -text "Cell 3 2" 
ttk::label .c33 -text "Cell 3 3" 
grid .c31 -row 2 -column 0 
grid .c32 -row 2 -column 1 
grid .c33 -row 2 -column 2 
0

这是NoonanRosenblum的答案,不是我的;我只想对此提出两点看法,但我无法将它们纳入评论。

  1. grid的位置不必像NoonanRosenblum的例子那样冗长。
  2. 单选按钮窗口小部件需要将不同的值分配为按设计工作。如果他们没有分配,这两个按钮将作为一个反应。

ttk::label .c11 -text "Cell 1 1" 
ttk::label .c12 -text "Cell 1 2" 
ttk::label .c13 -text "Cell 1 3" 
grid .c11 .c12 .c13 

ttk::label .c21 -text "Cell 2 1" 
ttk::frame .frame 
ttk::label .c23 -text "Cell 2 3" 
grid .c21 .frame .c23 

ttk::radiobutton .frame.rb1 -text Rb1 -value 1 
ttk::radiobutton .frame.rb2 -text Rb2 -value 2 
grid .frame.rb1 .frame.rb2 

ttk::label .c31 -text "Cell 3 1" 
ttk::label .c32 -text "Cell 3 2" 
ttk::label .c33 -text "Cell 3 3" 
grid .c31 .c32 .c33 
相关问题