code from book: WxPython In Action

I just downloaded the examples from the book. I get errors because the CR/LF
at the end of the #! line ends
with 0X0D and has to be manually deleted by using a hex editor. Is there
another method to eliminate this step in
order to get the code to execute? I think this is something simple but I
have forgotten it or not sure of the procedure.
Thanks.

···

--
View this message in context: http://wxpython-users.1045709.n5.nabble.com/code-from-book-WxPython-In-Action-tp5724304.html
Sent from the wxPython-users mailing list archive at Nabble.com.

I see I posted this similar error in the past, sorry about that. I will try
to find out about a utility 'dos2unix' which I am not sure what it is but
will look for it. I also read (the older post) that there is a plugin for
gedit. I will see if I can get that working.
I also like using Winge IDE for python and will see if there is a similar
fix in that IDE to account for the EOL for the Hash Bang line.

···

--
View this message in context: http://wxpython-users.1045709.n5.nabble.com/code-from-book-WxPython-In-Action-tp5724304p5724305.html
Sent from the wxPython-users mailing list archive at Nabble.com.

OK, found the dos2unix and installed. It tested fine - thank you.
QUESTION. Is there a GUI implementation to execute dos2unix?

···

--
View this message in context: http://wxpython-users.1045709.n5.nabble.com/code-from-book-WxPython-In-Action-tp5724304p5724306.html
Sent from the wxPython-users mailing list archive at Nabble.com.

eightbits wrote:

OK, found the dos2unix and installed. It tested fine - thank you.
QUESTION. Is there a GUI implementation to execute dos2unix?

Why? It's not a GUI-type operation. You just write a script to apply
it to all the files once, and then you're done.

···

--
Tim Roberts, timr@probo.com
Providenza & Boekelheide, Inc.

Hello Tim, I found that I have to edit the py script file (they are from the
book download) using gedit and then
save as and specify unix EOL and saving the same file. This of course works
fine but a bit awkward
I really don't think I know how to generate a script that would modify ,
say, all of the files (*.py) in a folder.
But, I have to edit the files anyhow as none of them have the hash bang line
in the script(s). So, I am thinking I might as well
just edit the file and then save it with the unix end of line format (?).

I have download the sample files for both the "WxPython In Action" and the
"WxPython 2.8 Application Development Cookbook" text books. These are the
books I am using to get up to speed in using WxPython. This is only a hobby
for me and I am not that proficient in OOP. I have been able to generate a
couple of WxPython app's to run on my Desktop for my own use.
But, I would be interested in using a script as you mentioned if you can
share an example. I am thinking you might be referring to a BASH script and
using the dos2unix utility? Once again, thanks for your suggestion(s)
BTW, I am using Linux(Ubuntu14.10) and not Windows.

···

--
View this message in context: http://wxpython-users.1045709.n5.nabble.com/code-from-book-WxPython-In-Action-tp5724304p5724308.html
Sent from the wxPython-users mailing list archive at Nabble.com.

Hello Tim, I found that I have to edit the py script file (they are from the
book download) using gedit and then
save as and specify unix EOL and saving the same file. This of course works
fine but a bit awkward
I really don't think I know how to generate a script that would modify ,
say, all of the files (*.py) in a folder.

This would be a perfect way for you to increase your knowledge of Python. It’s just the kind of thing that a quick Python script can handle.

But, I have to edit the files anyhow as none of them have the hash bang line
in the script(s). So, I am thinking I might as well
just edit the file and then save it with the unix end of line format (?).

OK, but remember that you only need a hash-bang line in files that you intend to run from the command line by name. Python files that are only imported into other files don’t need it.

Further, the hash-bang is only needed as a shortcut. If you have a main program called “gui-program.py”, there are two ways to start it. One is to turn it into a Linux executable, and for that you need a hash-band:
    chmod +x gui-program.py
    ./gui-program.py
The other is to run Python by hand; for that, you don’t need a hash-bang line:
    python gui-program.py

But, I would be interested in using a script as you mentioned if you can
share an example. I am thinking you might be referring to a BASH script and
using the dos2unix utility? Once again, thanks for your suggestion(s)
BTW, I am using Linux(Ubuntu14.10) and not Windows.

Obviously, because the hash-bang is strictly a Unix thing.

Yes, you could do a simple bash command:
    for i in *.py
    do
        mv $i $i.bak
        dos2unix <$i.bak >$i
    done

···

On Jun 6, 2015, at 8:18 PM, eightbits <jlala2010@gmail.com> wrote:

Tim Roberts, timr@probo.com
Providenza & Boekelheide, Inc.

I would recommend getting a CLI script working for converting the Python scripts then if you still would like a GUI write it yourself. This will not only be an excellent learning experience but also provide you with a GUI tailored to you.

···

On Friday, June 5, 2015 at 8:54:44 PM UTC-4, EightBits wrote:

I just downloaded the examples from the book. I get errors because the CR/LF

at the end of the #! line ends

with 0X0D and has to be manually deleted by using a hex editor. Is there

another method to eliminate this step in

order to get the code to execute? I think this is something simple but I

have forgotten it or not sure of the procedure.

Thanks.

View this message in context: http://wxpython-users.1045709.n5.nabble.com/code-from-book-WxPython-In-Action-tp5724304.html

Sent from the wxPython-users mailing list archive at Nabble.com.

Tim, thanks for the suggested script. I will experiment with that. In using
the hash/bang first line, I saved the py file to the desktop and added an
ICON which I can click on. If I don't have that hash/bang line I do not see
the form or anything else. If I do insure that the first line is there ,
then it is as expected. And, of course I do have to change the file so that
it is executable. I just use the Desktop GUI to make the file executable. I
am thinking that perhaps I could generate a script (python ?) that could
open each file, or a single file, check that the first line does have the
hash/bang line and insert it if not.

Once again, thanks for the example script and comments,

···

--
View this message in context: http://wxpython-users.1045709.n5.nabble.com/code-from-book-WxPython-In-Action-tp5724304p5724317.html
Sent from the wxPython-users mailing list archive at Nabble.com.