[PythonCAD] in the interest of not multiplying entities
Russ Nelson
nelson at crynwr.com
Tue Jun 6 04:11:20 CEST 2006
I'm noticing that code in gtkmenus.py which looks like this:
#------------------------------------------------------------
def select_all_circles_cb(menuitem, gtkimage):
_active_layer = gtkimage.getActiveLayer()
for _circle in _active_layer.getLayerEntities("circle"):
gtkimage.selectObject(_circle)
and is later used like this:
_act.connect('activate', select_all_circles_cb, gtkimage)
could actually look like this:
#------------------------------------------------------------
def select_all_entities_cb(menuitem, gn):
gtkimage, name = gn
_active_layer = gtkimage.getActiveLayer()
for _point in _active_layer.getLayerEntities(name):
gtkimage.selectObject(_point)
and be called like this:
_act.connect('activate', select_all_entities_cb, (gtkimage,"circle"))
Of course, that changce, once made, begs to be integrated with the
patch I sent earlier, so that there's one structure that looks like
this:
select_all_menu = [
('SelectAllPoints', 'point', '_Points'),
('SelectAllSegments','segment', '_Segments'),
('SelectAllCircles','circle', '_Circles'),
('SelectAllArcs','arc', '_Arcs'),
('SelectAllLeaders','leader', '_Leaders'),
('SelectAllPolylines','polyline', '_Polylines'),
('SelectAllChamfers','chamfer', '_Cha_mfers'),
('SelectAllFillets','fillet', '_Fillets'),
(None,None,None),
('SelectAllHCLines','hcline', '_HCLines'),
.... ]
and a loop like this:
for gtkimage, objname, menuitem in select_all_menu:
if gtkimage is None:
_item = gtk.SeparatorMenuItem()
_item.show()
_menu.append(_item)
else:
_act = gtk.Action(gtkimage, menuitem, None, None)
_act.connect('activate', select_all_thingies_cb, (gtkimage,objname))
_act.set_accel_group(_accel)
actiongroup.add_action(_act)
_menu.append(_act.create_menu_item())
Happy to bang out a patch if it's to your liking.
--
--my blog is at http://blog.russnelson.com | When immigration is
Crynwr sells support for free software | PGPok | outlawed, only criminals
521 Pleasant Valley Rd. | +1 315-323-1241 | will immigrate. Illegal
Potsdam, NY 13676-3213 | Sheepdog | immigration causes crime.
More information about the PythonCAD
mailing list