[PythonCAD] Sample patch for selection highlighting

Art Haas ahaas at airmail.net
Tue Nov 15 17:39:40 CET 2005


On Tue, Nov 15, 2005 at 11:09:42AM -0500, Stuart Brorson wrote:
> Hi Art --
> 
> I just grabbed the latest out of SVN (ver 2041).  I like the way it
> works.  Very nice -- thank you! 

Glad to know it works for you and you like it.

> One minor buglet:  If I select an individual graphic element (e.g. a
> segment), selecting works fine.  If I do a region select, I don't get
> the "Click on the items you want to select" message after the region
> select.   That is,  I click on the first
> point in the region, then the prompt says "Click on another point to
> select the region".   Then when I click on teh second point to close
> the region select, the prompt still says "Click on another point to
> select the region".  
> 
> I attach a very minor patch below to fix this problem.
 
I've applied it. Thanks. I've also made some other changes that have
made their way to the public repo, so doing an 'svn update' will get
those adjustments as well.

> One issue with this is that the different prompt messages get set all
> over the place, which might lead to confusion.  However, it is part of
> the way the program is architected, in that different callbacks are
> invoked depending upon whether you've entered the first, second, or
> whatever click.  Not a big enough issue ot be a showstopper, IMO.
 
A long-term goal is to make things consistent, and setting the prompt
after some action will need tinkering.

> Finally, I am still interesting in hearing your thoughts about the
> layer window on the left.  In particular, how should it behave?  I
> really want to fix this issue with entering corrdinates into the entry
> box at the bottom of the top level window, and understanding how the
> layer window is supposed to behave will help me figure out how to fix
> it.

The layer display should allow you to use the arrow keys to select which
layer is active, as well as selecting the active layer by typing it.
Also, when using the arrow keys, pressing the 'shift' key allows you to
collapse or expand the displayed layer list. All these features came
"free" because the display is built using the gtk.TreeView and
gtk.TreeStore widgets.

To fix things so that all the functionality above remains while adding
the ability to type in a coordinate pair will probably involve adding a
keypress_event handler to the gtk.TreeView instance in the LayerDisplay
class (see gtkshell.py). The handler needs to do some sort of processing
on what the user types and either let the TreeView accept the keystroke
or bail out. If we bail out, then the 'window_general_event' handler in
the GTKImage class will be called, and we can add some code there to try
and parse what has been typed and turn it into coordinates. How we
accomplish these tasks I don't know right now. I'd suggest reading up on
the TreeView and TreeModel widgets for starters, and also try to find a
program that uses these widgets and has a 'keypress_event' handler that
we can examine.

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