Subject: Re: Sparky peak ornament and label selection
From: Thomas Goddard
Date: Jun 9, 2006

Next: 165


From: J. Bradley Dickerson john.dickerson@...
To: Thomas Goddard goddard@...
Date: Fri, 09 Jun 2006 09:58:11 -0500

HI Tom,

I think that I may have answered this question for me a few years ago
but I cant find your email reply.

I would like to be able to select the peak label along with the peak
ornament so that when I change the color of a group of peaks in a
spectra the label color also changes.


Thanks for your time,
Bradley


Hi Bradley,

Yes I wrote some Python code to put in your sparky_init.py file to
address this in March 2003. Unfortunately it has not been included in
the standard Sparky distribution. Here is the code to add shortcut lS
that selects all labels corresponding to selected peaks. Make sure not to
change the indentation as that is important in Python.

Tom

-------
Code for command lS follows:

# -----------------------------------------------------------------------------
# Put this in ~/Sparky/Python/sparky_init.py.
# This file is read and the initialize_session() function is called
# when Sparky starts.
#
def initialize_session(session):

def select_labels(s=session):
select_labels_of_selected_peaks(s)

session.add_command(lS, Select labels of selected peaks (lS),
select_labels)

# -----------------------------------------------------------------------------
# Select the labels of the currently selected peaks.
#
def select_labels_of_selected_peaks(session) :

peaks = session.selected_peaks()
#
# If you want to unselect everything except the labels you could uncomment
# the following line.
#
# session.unselect_all_ornaments()
for p in peaks:
if p.label != None:
p.label.selected = 1