TCL GUI with simple procs
- Admin
- Feb 18, 2024
- 2 min read
When you run this code it creates a simple gui for some procs. When you click buttons it calls a procedure and does defined operation.

set win .window
catch (destroy $win}
toplevel $win -class TopClass -width 800 -height 1200 -padx 10 -pady 10
wm title $win "Geometry"
wm resizable $win 1 1
wm deiconify $win
pack [hwtk::notebook $win.nb] -fill both -expand true
$win.nb add [frame $win.nb.f1] -text "Geometry"
button $win.nb.f1.b1 -text "Delete Lines" -font {times 10 bold} -command delete_lines
place $win.nb.f1.b1 -x 20 -y 10 -width 200 -height 20
button $win.nb.f1.b2 -text "Delete Elements" -font {times 10 bold} -command delete_elems
place $win.nb.f1.b2 -x 20 -y 40 -width 200 -height 20
button $win.nb.f1.b3 -text "Delete Surfs" -font {times 10 bold} -command delete_surfs
place $win.nb.f1.b3 -x 20 -y 70 -width 200 -height 20
button $win.nb.f1.b4 -text "Delete Points" -font {times 10 bold} -command delete_points
place $win.nb.f1.b4 -x 20 -y 100 -width 200 -height 20
button $win.nb.f1.b5 -text "Delete Components" -font {times 10 bold} -command delete_comps
place $win.nb.f1.b5 -x 20 -y 130 -width 200 -height 20
button $win.nb.f1.b6 -text "Delete Nodes" -font {times 10 bold} -command delete_nodes
place $win.nb.f1.b6 -x 20 -y 160 -width 200 -height 20
button $win.nb.f1.b7 -text "Line From Nodes" -font {times 10 bold} -command line_from_nodes
place $win.nb.f1.b7 -x 20 -y 190 -width 200 -height 20
button $win.nb.f1.b8 -text "Triple Nodes on Line" -font {times 10 bold} -command triple_node_online
place $win.nb.f1.b8 -x 20 -y 220 -width 200 -height 20
button $win.nb.f1.b9 -text "Delete Empty Components" -font {times 10 bold} -command delete_empty
place $win.nb.f1.b9 -x 20 -y 250 -width 200 -height 20
button $win.nb.f1.b10 -text "Delete Unused Properties" -font {times 10 bold} -command unused_prop
place $win.nb.f1.b10 -x 20 -y 280 -width 200 -height 20
proc delete_lines {} {
*createmarkpanel lines 1
*deletemark lines 1
}
proc delete_elems {} {
*createmarkpanel elems 1
*deletemark elems 1
}
proc delete_surfs {} {
*createmarkpanel surfs 1
*deletemark surfs 1
}
proc delete_points {} {
*createmarkpanel points 1
*deletemark points 1
}
proc delete_comps {} {
*createmarkpanel components 1
*deletemark components 1
}
proc delete_nodes {} {
*createmarkpanel nodes 1
set node_list_Del [hm_getmark nodes 1]
*nodemarkcleartempmark 1
}
proc line_from_nodes {} {
*createmarkpanel nodes 1
set line_node [hm_getmark nodes 1]
list $line_node
*createlist nodes 1 [lindex $line_node 0] [lindex $line_node 1]
*linecreatefromnodes 1 2 0.0 0.0 0.0
}
proc triple_node_online {} {
*createmarkpanel lines 1
*nodecreateonlines lines 1 3 0 0
}
proc delete_empty {} {
*EntityPreviewEmpty comps 1
set emptylist [hm_getmark comps 1]
*deletemark components 1
*EntityPreviewEmpty property 1
}
proc unused_prop {} {
*EntityPreviewUnused props 1
*deletemark props 1
}

Comments