[PythonCAD] Repo updates

Art Haas ahaas at airmail.net
Thu Feb 24 13:14:33 CET 2005


Hi.

I've sent to the repository my latest batch of changes. The biggest
changes deal with handling the text that can be entered in the entry box
at the bottom of the screen. I've added a simple 'exec' statement to
process the text, and the entry-event handlers of the various tools have
been adjusted slightly to use a more clever form of eval(). What all
these changes permit are a much higher degree of scriptability in the
program. For example, when you start the program the prompt at the bottom
of the screen reads

Enter command:

You can now enter the something like the following:

a = 10; b = 20; c = 30

The program will then store the variable 'a' with the value 10, 'b' with
20, and 'c' with 30. Now, if you are doing an operation where you can
enter a value in the entry box, you can use 'a', 'b', or 'c' as values
in the expression.

In addition to simple variable assignments, you can enter pretty much
any valid Python expression. If 'exec' has a problem parsing and
executing what you've typed an exception is raised and an error printed
out. What makes this neat is that you can type something like the
following in the entry box ...

execfile("/path/to/some/file.py")

... and the contents of the file will be executed. The file must be
valid Python code, naturally. Using the execfile() command you can type
all your code into a file and load it in one fell swoop as opposed to
entering it directly.

The ability to execute code on the fly like this means you want to be
careful about calling execfile() on unknown files. If you were running
an interactive Python session and did an execfile() you would have the
same potential for trouble if the file contains mischevious code.

I still think that the long term goal will be to utilize the 'parser'
module, but for now the addition of 'exec' and the enhanced eval() are
good first steps.

Another change now in the code is the replacement of 'gtk.TRUE' with
'True' and 'gtk.FALSE' with 'False'. The latest PyGTK release deprecates
the gtk constants, so I'm being proactive in replacing them now. Even
though I'm running an older (2.4) PyGTK release things appear to work
without problem.

As there has been relatively few changes to the code over the last
couple of weeks, there will not be a new release made this month. My
non-computer life is hectic now and will be for the next couple of
weeks. I suspect the next release will occur near the end of March.

Art
-- 
Man once surrendering his reason, has no remaining guard against absurdities
the most monstrous, and like a ship without rudder, is the sport of every wind.

-Thomas Jefferson to James Smith, 1822


More information about the PythonCAD mailing list