Hi,
I am a newbee and wanted to learn tk widget. currently i have couples fruit items that associated with checkbuttons. i want to print out all fruit selected when click on "Run" button.
my codes below are not completed but Please help!
##############################################
proc frame_with_check_button { filelist loc } {
set left_frame [frame $loc.left_frame -bg black]
set filenames [label $left_frame.filenamesframe -bg black -fg darkorange -borderwidth 4 -anchor n -text " Fruit Selection " -font "arial 12 bold"]
pack $filenames
foreach name $filelist {
set but [ checkbutton $left_frame.$name -text $name -bg darkorange -anchor w ]
bind $but <1> { puts "click on [%W cget -text]"}
pack $but -fill x
}
return $left_frame
}
set testList {apple orange pear grape grapefruit banana watermelon mango pipeapple}
set topframe [frame .top -bg blue]
set topframeLabel [label .top.l -bg snow -fg red -anchor n -text "* TK GUI *" -font "arial 16 bold"]
set listbut [frame_with_check_button $testList $topframe]
set run [button .top.r -text " Run " -bg coral4 -fg darkorange -font "arial 18 bold" -command {puts "selected: "}]
set closeb [button .top.c -text "** Close **" -bg coral3 -fg darkorange -font "arial 18 bold" -command {destroy $topframe}]
pack $topframe $topframeLabel $listbut $run $closeb $listbut
I am a newbee and wanted to learn tk widget. currently i have couples fruit items that associated with checkbuttons. i want to print out all fruit selected when click on "Run" button.
my codes below are not completed but Please help!
##############################################
proc frame_with_check_button { filelist loc } {
set left_frame [frame $loc.left_frame -bg black]
set filenames [label $left_frame.filenamesframe -bg black -fg darkorange -borderwidth 4 -anchor n -text " Fruit Selection " -font "arial 12 bold"]
pack $filenames
foreach name $filelist {
set but [ checkbutton $left_frame.$name -text $name -bg darkorange -anchor w ]
bind $but <1> { puts "click on [%W cget -text]"}
pack $but -fill x
}
return $left_frame
}
set testList {apple orange pear grape grapefruit banana watermelon mango pipeapple}
set topframe [frame .top -bg blue]
set topframeLabel [label .top.l -bg snow -fg red -anchor n -text "* TK GUI *" -font "arial 16 bold"]
set listbut [frame_with_check_button $testList $topframe]
set run [button .top.r -text " Run " -bg coral4 -fg darkorange -font "arial 18 bold" -command {puts "selected: "}]
set closeb [button .top.c -text "** Close **" -bg coral3 -fg darkorange -font "arial 18 bold" -command {destroy $topframe}]
pack $topframe $topframeLabel $listbut $run $closeb $listbut