Jump to content

Recommended Posts

Hello all
How I can run .tcl script using a button?
I searched a lot of information, but can't found

I have a procedure:

proc add_button {title command} {
  global frame count
  button $frame.$count -text $title -command $command -font "arial 10"
  pack   $frame.$count -side top -pady 1 -padx 1 -fill x
  incr count

Then I call it:

add_frame  "TCL"
add_button "test open file"     {*readfile "C:/temp/11.tcl"}
add_button "test open file 2"       {*readfile "C:/temp/clip.hm"}

But opening a .hm file works good, but .tcl does not work and I have an error:

    while executing
"*readfile "C:/temp/11.tcl""
    invoked from within
".buttons.frame15.18 invoke"
    ("uplevel" body line 1)
    invoked from within
"uplevel #0 [list $w invoke]"
    (procedure "tk::ButtonUp" line 24)
    invoked from within
"tk::ButtonUp .buttons.frame15.18"
    (command bound to event)

Can everyone explain me how correct this error or how can I run a .tcl file using buttons?

Share this post

Link to post
Share on other sites

Maybe try "userpage.mac" ? Here's from my userpage.mac

*createbutton(5,"NASTRAN",   5, 0, 5, GREEN,"Export to Nastran",EvalTcl,"HM2Nastran.tcl")
*createbutton(5,"SAMCEF",    5, 5, 5, GREEN,"Export to Samcef ",EvalTcl,"HM2Samcef.tcl")

All my scripts found in the directory defined in environment variable "TCL_INCLUDE"

Share this post

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

You are posting as a guest. If you have an account, please sign in.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...