Training, Open Source computer languages
PerlPHPPythonMySQLApache / TomcatTclRubyJavaC and C++LinuxCSS 
Search for:
Home Accessibility Courses Diary The Mouth Forum Resources Site Map About Us Contact
For 2021 - online Python 3 training - see ((here)).

Our plans were to retire in summer 2020 and see the world, but Coronavirus has lead us into a lot of lockdown programming in Python 3 and PHP 7.
We can now offer tailored online training - small groups, real tutors - works really well for groups of 4 to 14 delegates. Anywhere in the world; course language English.

Please ask about private 'maintenance' training for Python 2, Tcl, Perl, PHP, Lua, etc. me in this program

Posted by michelle_miss (michelle_miss), 24 January 2005
hello everyone....can anyone help me in prorammin Tcl/Tk...?this is a new language for me to program....and iam findin it difficult to do the above program in TCL/ me...

PROGRAM QUESTION: Design a program capable of digitizing circles.  The system should start with a single window containing a grid of 20x20 points.All points should start out grey.  The user can then click to place the center of a circle, and then drag to set it's radius, similar to various graphics programs.  The circle should be drawn on the screen.When the user releases the mouse button, the program should highlight the points (make them blue) that correspond to the edge of the circle, in a way such that the points could be connected to reconstruct the circle.Then, two additional circles should be created corresponding to the largest and smallest radius of the highlighted points.

Posted by admin (Graham Ellis), 24 January 2005
I really don't think that I would be helping you very much if I provided anything approaching a complete answer - see, points 3 in the first section and five in the third.

As a starter, try generating and displaying a widget (have you been able to work out what type?) to give you the grey background ...

Posted by michelle_miss (michelle_miss), 25 January 2005
hello Mr.admin,
iam new to this group...anywayz....i clearly understood the posting rules...
regarding the program...
i created the grid with 20x20 points with grey color....
i generated a circle in two by giving manual points and the other by automatically dragging the point as giving the following codes......

bind .c <ButtonPress-1> {oval_create %W %x %y}
bind .c <B1-Motion> {oval_move %W %x %y}
bind .c <ButtonRelease-1> {oval_end %W %x %y}
proc oval_create {win x y} {
    global oval
    set oval(x0) $x
    set oval(y0) $y
    set oval(id) [$win create oval $x $y $x $y]

proc oval_move {win x y} {
    global oval
$win coords $oval(id) $oval(x0) $oval(y0) $x $y

proc oval_end {win x y} {
    global oval
    oval_move $win $x $y
    $win itemconfigure $oval(id) -fill "" -tags circle

But i couldnt able to get the overlapping the grids which touches the circle indexes...and also generating a circle above and below the original i hope now u can help me in solving the problem....
thanks and regards

Posted by admin (Graham Ellis), 25 January 2005
The code sample you've provided looks good.   I think the following stage for generating the extra circles would be to use some expr calculations based on the existing centre and circumference points, then draw the extra ovals.

By background, I'm a graphics programmer but I'm not finding it easy to understand the specification exactly - I suspect that it's been translated from another language and it may have lost something in the translation; wish I could be more help.

Oh - have you come across the -outline option which may help with the border?

Posted by michelle_miss (michelle_miss), 25 January 2005
Dear Mr.Admin,
Thanks for ur reply.....i didnt get anyother information except what i have provided to you in the above program......i have 2 mail questions... to highlight the points in the grid in blue color to which the circle edges overlapps

2.How to get the index values for circle i have created using the mouse...coz if i know this value i can jus increment and decrement this values to get two circles above and below the main circle as mention in the problem.....

Anywayz...thankz for your help...

Posted by neo (The Architect), 26 January 2005
Just Off topic: Is it advisable to do graphics and related high processing stuff using a scripting language?

Posted by admin (Graham Ellis), 30 January 2005
Very often, if you generate graphics using built in libraries from a scripting language, it's very efficient.   The scripting language is really not doing a great deal of the work iteself and so isn't an efficiency problem; the graphics work is done by the library - usually written in C, and usually something that the library author has spent a great deal of time and expersise writing to run reliably and efficiently.   Examples of libraries that I include in this category are:
* Tk from Tcl
* The Imagexxx routines in PHP
* Qt, Wx and Tkinter in Python

However - please do NOT try to use a scripting language to generate low level graphics directly using and and or operations in the scripting language and a frame buffer set up in a scripting language variable. That would run slower than a snail!

This page is a thread posted to the opentalk forum at and archived here for reference. To jump to the archive index please follow this link.

You can Add a comment or ranking to this page

© WELL HOUSE CONSULTANTS LTD., 2022: Well House Manor • 48 Spa Road • Melksham, Wiltshire • United Kingdom • SN12 7NY
PH: 01144 1225 708225 • FAX: 01144 1225 793803 • EMAIL: • WEB: • SKYPE: wellho