🎉Community Raffle - Win $25

An exclusive raffle opportunity for active members like you! Complete your profile, answer questions and get your first accepted badge to enter the raffle.
Join and Win

Run TCL script using button

User: "AlexanderP"
Altair Community Member
Updated by AlexanderP

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:
 

 0 0     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?

Find more posts tagged with

Sort by:
1 - 1 of 11
    User: "QuyNguyenDai"
    Altair Community Member
    Updated by QuyNguyenDai

    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'