Page 1 of 1
Creating a rectangle in TCL
Posted: Tue Dec 23, 2014 12:30 am
by eduardrocas
Hello,
I would like to know which is the easiest way to create a rectangle, of specific dimensions and position, using Tcl/Tk. In GiD's graphical user interface there's the possibility of drawing a rectangle, so I'm wondering if it already exists such a function available for Tcl/Tk.
Thanks,
Eduard
Re: Creating a rectangle in TCL
Posted: Mon Dec 29, 2014 1:50 pm
by escolano
You can use for example GiD_Process to invoke the GiD tool to create a rectangle, e.g.
Code: Select all
proc MyCreateRectangle { x y width height } {
GiD_Process Mescape Geometry Create Object Rectangle $x,$y,0 [expr $x+$width],[expr $y+$height],0 escape
}
Or you can create the four points, the four lines, and a the surface explicitly, using GiD_Process commands
or without use the GiD process loop, using the GiD-Tcl procedure GiD_Geometry (see GiD Help on customization to know its syntax)
Re: Creating a rectangle in TCL
Posted: Mon Dec 29, 2014 7:26 pm
by eduardrocas
Great. Thanks!
Re: Creating a rectangle in TCL
Posted: Thu Mar 26, 2015 7:11 am
by SatuSalo
The canvas widget is Tk's workhorse for 2D graphical display, and can handle both bitmap and vector graphics. It was inspired by Joel Bartlett's ezd program, which provides structured graphics in a Scheme environment. A canvas is one of the most powerful concepts in Tk. It acts as a drawing plane for lines, rectangles, ovals, polygons, text, arcs (e.g. pieslices) as well as container widget to group other widgets, and it provides the ability to group elements together for creation, deletion, moving, etc.
Re: Creating a rectangle in TCL
Posted: Thu Mar 26, 2015 10:38 am
by amelendo
Both answer are correct depending on what you want to achieve. I think that escolano one is what eduardrocas was searching.
For creating a geometry rectangle inside GiD follow escolano answer.
For creating a rectangle on the interface of GiD, for example inside a window, follow SatuSalo answer.
Thanks both for your answers.