{"id":1403,"date":"2022-02-10T20:34:05","date_gmt":"2022-02-11T04:34:05","guid":{"rendered":"https:\/\/gantovnik.com\/bio-tips\/?p=1403"},"modified":"2024-01-14T15:17:57","modified_gmt":"2024-01-14T23:17:57","slug":"210-parametric-curve-in-3d-2-2-2-2-2-2-2-2-2-2-2-2-2-3-2-2-2-2-2-2-2-2-2","status":"publish","type":"post","link":"https:\/\/gantovnik.com\/bio-tips\/2022\/02\/210-parametric-curve-in-3d-2-2-2-2-2-2-2-2-2-2-2-2-2-3-2-2-2-2-2-2-2-2-2\/","title":{"rendered":"#268 A progress indicator using tcl\/tk"},"content":{"rendered":"<p><img data-recalc-dims=\"1\" decoding=\"async\" src=\"https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2022\/02\/ex268.png?resize=202%2C52&#038;ssl=1\" alt=\"\" width=\"202\" height=\"52\" class=\"alignnone size-full wp-image-1404\" srcset=\"https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2022\/02\/ex268.png?w=202&amp;ssl=1 202w, https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2022\/02\/ex268.png?resize=150%2C39&amp;ssl=1 150w\" sizes=\"(max-width: 202px) 100vw, 202px\" \/><\/p>\n<p>#268 A progress indicator using tcl\/tk.<\/p>\n<pre class=\"brush: python; title: ; notranslate\" title=\"\">\r\n# Create a simple progress gauge set, initially set to 0%\r\nproc gaugeCreate {win {color &quot;gray&quot;} } {\r\n    frame $win\r\n    canvas $win.display \\\r\n        -borderwidth 0 \\\r\n        -background white \\\r\n        -highlightthickness 0 \\\r\n        -width 200 \\\r\n        -height 20\r\n\r\n   pack $win.display -expand yes\r\n   $win.display create rectangle 0 0 0 20 \\\r\n        -outline &quot;&quot; \\\r\n        -fill $color  \\\r\n        -tags bar\r\n   $win.display create text 100 10 \\\r\n        -anchor c \\\r\n        -font {-size 14} \\\r\n        -text &quot;0%&quot; \\\r\n        -tags value \r\n   return $win\r\n}\r\n\r\n# Given a gauge, set it to a certain percentage\r\nproc gaugeValue {win val} {\r\nputs &quot;$win $val&quot;\r\nupdate\r\n    if {$val &lt; 0 || $val &gt; 100} {\r\n        error &quot;bad value \\&quot;$val\\&quot;: should be 0-100&quot;\r\n    }\r\n    set msg &#x5B;format &quot;%3.0f%%&quot; $val]\r\n    $win.display itemconfigure value -text $msg\r\n\r\n    set w &#x5B;expr 0.01 * $val * &#x5B;winfo width $win.display]]\r\n    set h &#x5B;winfo height $win.display]\r\n    $win.display coords bar 0 0 $w $h\r\n}\r\n\r\n# Lets test it. \r\n# This routine calls itself every 100ms until 100% is reached\r\nproc gaugeIncrement {win value} {\r\n    if {$value &lt;= 100} {\r\n        gaugeValue $win $value\r\n        after 100 &quot;gaugeIncrement $win &#x5B;incr value]&quot;\r\n    }\r\n}\r\n\r\npack &#x5B;gaugeCreate .gauge]\r\ngaugeIncrement .gauge 1\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>#268 A progress indicator using tcl\/tk. # Create a simple progress gauge set, initially set to 0% proc gaugeCreate {win {color &quot;gray&quot;} } { frame $win canvas $win.display \\ -borderwidth 0 \\ -background white \\ -highlightthickness 0 \\ -width 200 \\ -height 20 pack $win.display -expand yes $win.display create rectangle 0 0 0 20 \\ [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"nf_dc_page":"","_et_pb_use_builder":"","_et_pb_old_content":"","_et_gb_content_width":"","_lmt_disableupdate":"yes","_lmt_disable":"","jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[27],"tags":[],"class_list":["post-1403","post","type-post","status-publish","format-standard","hentry","category-tcl"],"modified_by":"gantovnik","jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p8bH0k-mD","jetpack_likes_enabled":true,"jetpack-related-posts":[{"id":781,"url":"https:\/\/gantovnik.com\/bio-tips\/2020\/11\/134-global-variable-in-tcl\/","url_meta":{"origin":1403,"position":0},"title":"#134 Global variable in tcl","author":"gantovnik","date":"2020-11-12","format":false,"excerpt":"#134 Global variable in tcl [code language=\"python\"] set f \"This is a global variable\"; #This procedure cannot access the global variable f. proc testproc1 { } { catch {puts $f} val; puts $val; } #This procedure can access the global variable f using the global command. proc testproc2 { }\u2026","rel":"","context":"In &quot;HyperMesh&quot;","block_context":{"text":"HyperMesh","link":"https:\/\/gantovnik.com\/bio-tips\/category\/hypermesh\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":1047,"url":"https:\/\/gantovnik.com\/bio-tips\/2021\/11\/187-feet-to-meter-converter-using-python-tcl-tk\/","url_meta":{"origin":1403,"position":1},"title":"#187 Feet to meter converter using python tcl\/tk","author":"gantovnik","date":"2021-11-07","format":false,"excerpt":"[code language=\"python\"] package require Tk wm title . \"Feet to Meters\" grid [ttk::frame .c -padding \"3 3 12 12\"] -column 0 -row 0 -sticky nwes grid columnconfigure . 0 -weight 1; grid rowconfigure . 0 -weight 1 grid [ttk::entry .c.feet -width 7 -textvariable feet] -column 2 -row 1 -sticky we\u2026","rel":"","context":"In &quot;tcl&quot;","block_context":{"text":"tcl","link":"https:\/\/gantovnik.com\/bio-tips\/category\/tcl\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2021\/11\/ex187.png?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":1400,"url":"https:\/\/gantovnik.com\/bio-tips\/2022\/02\/210-parametric-curve-in-3d-2-2-2-2-2-2-2-2-2-2-2-2-2-3-2-2-2-2-2-2-2-2\/","url_meta":{"origin":1403,"position":2},"title":"#267 tk_getOpenFile in tcl\/tk","author":"gantovnik","date":"2022-02-10","format":false,"excerpt":"#267 tk_getOpenFile in tcl\/tk. [code language=\"python\"] set types { {\"All Source Files\" {.tcl} } {\"Image Files\" {.txt} } {\"All files\" *} } proc doIt {label} { global types set file [tk_getOpenFile -filetypes $types -parent .] $label configure -text $file } label .l -text \"No File\" button .b -text \"Select a\u2026","rel":"","context":"In &quot;tcl&quot;","block_context":{"text":"tcl","link":"https:\/\/gantovnik.com\/bio-tips\/category\/tcl\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2022\/02\/ex267.png?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":1351,"url":"https:\/\/gantovnik.com\/bio-tips\/2022\/01\/133-create-vectors-and-planes-using-tcl-in-hypermesh-2-2-2-2-2-2-2-2-2-2-2-2-2-2-2-2-2-2-2-2-2-2-2-2-2-2-2-2-2\/","url_meta":{"origin":1403,"position":3},"title":"#255 Returning multiple values from a procedure in tcl","author":"gantovnik","date":"2022-01-05","format":false,"excerpt":"The return command passes one value to the caller. There is often a need to return multiple values. In such cases, we can return a list. Example: [code language=\"python\"] proc RandomNumbers {} { set r1 [expr round(100*rand())] set r2 [expr round(100*rand())] return [list $r1 $r2] } puts [RandomNumbers] [\/code] Result:\u2026","rel":"","context":"In &quot;tcl&quot;","block_context":{"text":"tcl","link":"https:\/\/gantovnik.com\/bio-tips\/category\/tcl\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":783,"url":"https:\/\/gantovnik.com\/bio-tips\/2020\/11\/135-global-namespace-in-tcl\/","url_meta":{"origin":1403,"position":4},"title":"#135 Global namespace in tcl","author":"gantovnik","date":"2020-11-12","format":false,"excerpt":"#135 Global namespace in tcl It is possible to reference global variables inside procedures using global namespace indicator: [code language=\"python\"] set ::element_list \"1 2 3 4 5\"; proc ::element_info {} { puts $::element_list; set ::node_list \"10 20 30 40\"; puts $::node_list; } element_info; 1 2 3 4 5 10 20\u2026","rel":"","context":"In &quot;HyperMesh&quot;","block_context":{"text":"HyperMesh","link":"https:\/\/gantovnik.com\/bio-tips\/category\/hypermesh\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":532,"url":"https:\/\/gantovnik.com\/bio-tips\/2020\/05\/hwat-example\/","url_meta":{"origin":1403,"position":5},"title":"HWAT Example","author":"gantovnik","date":"2020-05-06","format":false,"excerpt":"There are 7 categories of HWAT functions, of which one is specific to Tk and the other 6 are for general Tcl usage. These categories are: 1) Core Function: Primarily helper functions and are not used directly in most cases. They are usually called from within other functions. 2) I\/O\u2026","rel":"","context":"In &quot;tcl&quot;","block_context":{"text":"tcl","link":"https:\/\/gantovnik.com\/bio-tips\/category\/tcl\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]}],"_links":{"self":[{"href":"https:\/\/gantovnik.com\/bio-tips\/wp-json\/wp\/v2\/posts\/1403","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/gantovnik.com\/bio-tips\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/gantovnik.com\/bio-tips\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/gantovnik.com\/bio-tips\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/gantovnik.com\/bio-tips\/wp-json\/wp\/v2\/comments?post=1403"}],"version-history":[{"count":1,"href":"https:\/\/gantovnik.com\/bio-tips\/wp-json\/wp\/v2\/posts\/1403\/revisions"}],"predecessor-version":[{"id":2073,"href":"https:\/\/gantovnik.com\/bio-tips\/wp-json\/wp\/v2\/posts\/1403\/revisions\/2073"}],"wp:attachment":[{"href":"https:\/\/gantovnik.com\/bio-tips\/wp-json\/wp\/v2\/media?parent=1403"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/gantovnik.com\/bio-tips\/wp-json\/wp\/v2\/categories?post=1403"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/gantovnik.com\/bio-tips\/wp-json\/wp\/v2\/tags?post=1403"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}