Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Opening a TCL program from within another TCL program in ANSYS Tcl-Tk

267 views
Skip to first unread message

Jose

unread,
Apr 25, 2012, 2:38:03 PM4/25/12
to
Hi everyone,

I have been pulling my hair with this one for a couple of days and
still have not found a fix. I'm working within ANSYS Tcl-Tk
implementation.

I created a Tcl-Tk script that generates a simple window with three
buttons. Each button opens another window which is created in a
separate Tcl file. The second window have a lot of text entries,
variables, procedures, etc. I can open the second Tcl file by itself
and everything works as supposed, but when I open it using the button
in the first window, it opens but any procedure called by the widgets
on the second window are not found...

Here's the deal... Since I'm working within the ANSYS implementation
of Tcl-Tk, I'm actually using an ANSYS command to open the second
window. The command I use is:

###
ans_sendcommand ~eui,'source O:/mad_projects_2/ANSYS/Macros/
IBR_CAS.tcl'
###

It actually sends a command back to ANSYS telling it to execute a Tcl
command... I know this is not pretty but its the only way i was able
to make it at least show the window.

##############################
#Main Tcl (excerpt):
##############################
namespace eval Tools {
proc IBRCambpell {} {
#source O:/mad_projects_2/ANSYS/Macros/IBR_CAS.tcl
ans_sendcommand ~eui,'source O:/mad_projects_2/ANSYS/Macros/
IBR_CAS.tcl'
}

proc viewManager {} {
ans_sendcommand ~eui,'source O:/mad_projects_2/ANSYS/Macros/
ViewManager.tcl'
}

proc powerAnnotation {} {
ans_sendcommand ~eui,'source O:/mad_projects_2/ANSYS/Macros/
PowerAnnotation.tcl'
}
}

namespace eval MADTools {
proc BuildGui {} {
destroy .dlgMADTools
set parent [toplevel .dlgMADTools -class Ansys]
#Sets its title
wm title $parent "MAD TCL-TK Tools by Jose Miranda"
image create photo .dlgMADTools.ibr_Campbell_Image -format GIF -file
"O:/mad_projects_2/ANSYS/Macros/Images_for_TCL_TK/default.gif"
button .dlgMADTools.ibrCampbell_Button -
image .dlgMADTools.ibr_Campbell_Image -text "IBR Campbell Analysis
Submitter" -compound top -command "Tools::IBRCambpell" -background
$bgColor
grid .dlgMADTools.ibrCampbell_Button -in .dlgMADTools.midFrame -row 2 -
column 1 -columnspan 1 -sticky ew

#Disable window resizing
wm resizable .dlgMADTools 0 0
}

BuildGui
}


###########################
#Second Tcl file (Excerpt of IBR_CAS.tcl):
###########################

namespace eval CAS {
proc proc1 {} {
...
...
}
proc proc2 {} {
...
...
}

destroy .dlgCAS

set parent [toplevel .dlgCAS -class Ansys]
#Sets its title
wm title $parent "IBR Campbell Analysis Submitter v1.0 By Carlos
Fernandez (IAS)"

button .dlgCAS.browse3DDatabase_Button -text "Browse" -command
"CAS::BrowseDB 3DDatabase" -background $bgColor

grid .dlgCAS.browse3DDatabase_Button -in .dlgCAS.topFrame -row 3 -
column 3 -columnspan 1
}

harsh...@gmail.com

unread,
Jul 7, 2017, 2:44:05 AM7/7/17
to
Can to tell me the procedure for how to run a tcl tk in ansys through command option

Arjen Markus

unread,
Jul 11, 2017, 10:39:56 AM7/11/17
to
I do not know ANSYS Tcl/Tk but from your description I would guess that in this way you run the window in another interpreter or even a separate process. In both cases things may seem to be lost, in the first case there is a solution, in the second, you would need inter-process communication. Not impossible but a few orders of magnitude more difficult.

Is there a particular reason for this version of Tcl/Tk? Could you try with an "ordinary" one? There may be other issues that would surface in such an environment and at the very least more people would know such an environment.

Regards,

Arjen
0 new messages