Thanks for the information.
As for the customized module, here is what I tried:
1. create my.py in $SPARKYHOME/ Python:
def test(session) :
print load my.py
2. create spark_init.py in the same folder as:
def initialize_session( session):
print hello
import my
pass
3. open python shell in sparky, I did see hello, but when I type
test or my.test, I got similar error message:
test
Traceback (most recent call last):
File /usr/local/ src/sparky/ platforms/ linux-2.6. 9/sparky- install/python/ sparky/pythonshe ll.py,
line 150, in execute_command
File stdin, line 1, in ?
NameError: name test is not defined
my.test
Traceback (most recent call last):
File /usr/local/ src/sparky/ platforms/ linux-2.6. 9/sparky- install/python/ sparky/pythonshe ll.py,
line 150, in execute_command
File stdin, line 1, in ?
NameError: name my is not defined
what did I do wrong?
--- In nmr_sparky@yahoogro ups.com ,
Tom Goddard goddard@... wrote:
Sparky does not add $SPARKYHOME/ Python to the Python path so
it isnt
going to find your my.py file. You could insert the path in the
Python
sys.path variable. But probably more useful to you is that Sparky
will
import the file
$SPARKYHOME/ Python/sparky_ init.py
when it starts and run the routine named initialize_session( ).
So if in
the sparky_init. py file you put
def initialize_session( session):
print hello world
Then you will see hello world in the Sparky Python shell (menu
Extensions / Python Shell, shortcut py). The session argument is
the
Sparky session object and is described in the README file
included
with Sparky
sparky/python/ README
or on Mac
Sparky.app/Contents /Resources/ python/README
Ive attached that file for your amusement.
As for modifications to peak table mouse behavior you are looking
in the
right place in peaktable.py, and the bind routine is setting the
mouse
binding which currently calls goto_assignment_ cb() which
calls
clicked_assignment( ) to find the spectrum you clicked on.
With some
Python knowledge and studying the above code it is not hard to
modify it
as you desire.
Tom
I just got hold of sparky and loved it immediately! While
playing with
it, I met a situation I think one can probably improve the
efficiency
dramatically. In the Peak Table window, we can double-left- click
or
single-middle- click at the left side of a peak in
particular spectrum
to center the spectrum with that peak. If there are more than
one
spectrum, one need to click individual peaks to center them
in
different spectra window. Im wondering whether one can set a
different mouse event to center all the peaks in their
spectrum,
respectively, for example, set single-middle- click or
single-right- click for this purpose. I believe people
would benefit a
lot from this small modification.
I tried to understand the peaktable.py but it is quite
complicated for
a python newbie. By the way, how exactly I can add my own
python
script in sparky? Here is what I tried:
1. create a file my.py with following lines
def hello ():
print (hello the world)
2. save this file in /home/Sparky/ Python and my
SPARKYHOME is
/home/Sparky
3. open sparky and python shell, type import my and get
error message:
Traceback (most recent call last):
File
/usr/local/ src/sparky/ platforms/ linux-2.6. 9/sparky- install/python/ sparky/pythonshe ll.py,
line 150, in execute_command
File stdin, line 1, in ?
ImportError: No module named my
Thanks in advance