<div class="gmail_quote">On 15 July 2010 17:21, Jim Byrnes <span dir="ltr">&lt;<a href="mailto:jf_byrnes@comcast.net">jf_byrnes@comcast.net</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">

<div><div></div><div class="h5">Adam Bark wrote:<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
On 14 July 2010 17:41, Jim Byrnes&lt;<a href="mailto:jf_byrnes@comcast.net" target="_blank">jf_byrnes@comcast.net</a>&gt;  wrote:<br>
<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
Adam Bark wrote:<br>
<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
On 14 July 2010 02:53, Jim Byrnes&lt;<a href="mailto:jf_byrnes@comcast.net" target="_blank">jf_byrnes@comcast.net</a>&gt;   wrote:<br>
<br>
  Adam Bark wrote:<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<br>
&lt;snipped some old stuff&gt;<br>
<br>
<br>
  If I use the terminal to start the program it has no problem using the<br>
<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
  file.  There are multiple files in multiple directories so I was<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;"><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">

<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
looking<br>
for<br>
a way to just double click them and have them run.  If it turns out<br>
that<br>
I<br>
must make changes to or for each of the files it will be easier to<br>
just<br>
keep<br>
using the terminal.  I&#39;ve only been using Ubuntu for a few months so<br>
I<br>
was<br>
surprised that the program could not see a file that is in the same<br>
directory.<br>
<br>
Regards,  Jim<br>
<br>
<br>
<br>
</blockquote>
The problem is ubuntu doesn&#39;t run the script from the directory it&#39;s<br>
in<br>
so<br>
it&#39;s looking for wxPython.jpg somewhere else.<br>
<br>
<br>
  OK, I mistakenly thought that double-clicking on file in Nautilus<br>
would<br>
<br>
</blockquote>
take care of the path info.<br>
<br>
In my reply above I also mentioned that I tried by dropping it on a<br>
Launcher on the top panel and that the command the launcher uses is<br>
usr/bin/python2.6.  Is there a way that the command can be changed so<br>
that<br>
it will look in the same directory the python script is in for any file<br>
it<br>
needs?<br>
<br>
Thanks,  Jim<br>
<br>
<br>
</blockquote>
<br>
Not sure if you got my previous email but you could try writing the bash<br>
script I posted (with the $1 line to get the path) and setting that as<br>
your<br>
launcher, I think it should work.<br>
<br>
Let me know if you didn&#39;t get it or it doesn&#39;t work.<br>
<br>
HTH,<br>
Adam.<br>
<br>
<br>
  I got it, got sidetracked and then forgot to look at it again.  Thanks<br>
</blockquote>
for<br>
reminding me.  Your idea works, but with one little downside.  The<br>
directories I am working with are chapters in a book.  So as I move from<br>
chapter to chapter I will need to change the bash script, but this seems<br>
to<br>
be less typing than using the terminal.<br>
<br>
<br>
Thanks,  Jim<br>
<br>
<br>
</blockquote>
Ok cool, glad it works. It might be possible to get the path so you don&#39;t<br>
have to set it each time, try this:<br>
<br>
#!/bin/bash<br>
IFS=&quot;/&quot;<br>
path=($1)<br>
cd $(path[0:#path[*]])<br>
python $1<br>
<br>
<br>
# Warning, I&#39;m not exactly a competent bash programmer so this may not<br>
work<br>
:-p<br>
<br>
Let me know if you need a hand to fix it,<br>
<br>
HTH,<br>
Adam.<br>
<br>
<br>
</blockquote>
I tried the new bash code but when I dropped a file on the launcher it just<br>
flashed an gave no output.  So I tried running the bash script<br>
(name=runpython) in a terminal and got this error:<br>
<br>
/home/jfb/runpython: line 4: path[0:#path[*]]: command not found<br>
Python 2.6.5 (r265:79063, Apr 16 2010, 13:57:41)<br>
[GCC 4.4.3] on linux2<br>
Type &quot;help&quot;, &quot;copyright&quot;, &quot;credits&quot; or &quot;license&quot; for more information.<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;"><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">

<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<br>
</blockquote></blockquote></blockquote>
<br>
I know even less about bash than you do, so I don&#39;t where to start to debug<br>
this.<br>
<br>
<br>
Thanks,  Jim<br>
<br>
Ok then, this time it&#39;s tested and not just improvised, here we go:<br>
</blockquote>
<br>
#!/bin/bash<br>
<br>
script=$1 # Full path for calling the script later<br>
orig_IFS=$IFS # This is to reset IFS so that &quot;script&quot; is correct (otherwise<br>
has spaces instead of /)<br>
IFS=&quot;/&quot;<br>
path=( $1 )<br>
IFS=$orig_IFS<br>
last_ind=${#path[@]} # Works out the length of path<br>
let &quot;last_ind -= 1&quot; # Sets last_ind to index of script name<br>
len_path=${path[@]:0:last_ind} # Gets the path without the script name<br>
let &quot;len_path=${#len_path[0]} + 1&quot; # This gives the length of the script<br>
string upto just before the last /<br>
cd ${script[@]:0:len_path} # cds to the path<br>
python script<br>
<br>
<br>
As pretty much my first non-trivial bash script it&#39;s probably horrible but<br>
it seems to work.<br>
<br>
HTH,<br>
Adam.<br>
<br>
</blockquote>
<br></div></div>
There must be something different in our setups because it did not work for me.  If I run it from a terminal I get:<br>
<br>
jfb@jfb-ubuntu64:~$ /home/jfb/runpython_test bitmap_button.py<br>
/home/jfb/runpython_test: line 12: cd: b: No such file or directory<br>
python: can&#39;t open file &#39;script&#39;: [Errno 2] No such file or directory<br>
jfb@jfb-ubuntu64:~$<br>
<br>
Thanks  Jim<br>
<br>
</blockquote></div><br>Oh cock, I missed a $ sign it should be &quot;python $script&quot;. Seems to complain about the path as well though, not sure about that one, I&#39;ll get back to you later.<br><br>Adam.<br>