[PythonCAD] New menu-creation code in the repo

Art Haas ahaas at airmail.net
Wed Apr 27 19:33:20 CEST 2005


Hi.

The UI building in PythonCAD has stepped bravely out of the dark ages
and is now in, well, the less-dark ages. I've been working on replacing
the code that builds the menu structure, and the first batch of work is
now complete.

When the GTK+ developers released the 2.4 version, they added the
UIManager code as the means for building the interface to a program.
This feature is built on the new (at the time) Action and ActionGroup
classes, and these classes are what PythonCAD now utilizes in building
menus. The GTK+ and PyGTK documentation gives numerous examples of how
to use these classes, and I think I've cobbled together enough of an
understanding to use them and determine that the approach these classes
provide to building and handling the interface elements is very slick.

The menus in PythonCAD are now much more attuned to the state of the
drawing. For example, many of the menu choices for editing or modifying
entities can only be chosen when, strangely enough, the active layer
contains entities! Also, the menu choices that select all the entities
of a certain type are now enabled only if entities of that type are
found. Lastly, a few more menu items have been added that had been
overlooked have been added. For instance, the selection of all polyline
entities is now accesible from the menu. One area to be improved in
upcoming releases deals with menu choices that perform operations on
selected entities. The new code will activate these menus when some
object or objects have been selected, but currently there is not any
good means of determining the types of these objects, so menu items
for editing operations that cannot be done are still active. The problem
to solve deals with providing routines to access what objects are
selected, and so expect to see this ability and more menu item control
in a future release.

All the new Action and ActionGroup class stuff is available in GTK+
from the 2.4 release, and the PyGTK 2.4 release as well. Now, for people
still using older GTK+ and PyGTK releases, I've written replacement
classes that provide the basic functionality of the Action and
ActionGroup classes. This code is in the new 'gtkactions.py' file, and
is meant to provide similar if slightly limited functionality as the true
GTK+ classes but enough to build the menus, and my limited testing
demonstrated it worked well enough. However, the testing is on my
machine using the GTK+ 2.6.4 release and the 2.6.1 PyGTK version (both
from Debian unstable), so it is likely that I've missed something. As I
don't know how many people run PythonCAD on machines using GTK+ and
PyGTK releases prior to 2.4, both of which are quite old, I'm not sure
if lurking bugs will be found because the code may not be run on these
older versions.

I'm probably going to make a release tomorrow as I am pleased with the
behavior of the new menu code, and the new drawing code has been working
out well, too. Plus, a few bug fixes have been applied here and there.

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