From: Kevin A. <al...@se...> - 2007-08-27 21:09:20
|
On Aug 27, 2007, at 12:26 PM, Root, Richard wrote: > Kevin, > > Seems like we fix one problem and immediately another arises! In =20 > the exercises in the book, I have to switch between Python Shell =20 > and codeEditor, cutting, pasting etc. When I dbl click on =20 > codeEditor.py, and run the script, the codeEditor code is =20 > apparently all that the Python shell can handle, because I can no =20 > longer use it for the exercises. In the book, the only info =20 > provided on running codeEditor is on page 3: > > > > =93Once it is installed on your system with PythonCard, on linux or =20= > unix based systems, you can just type codeEditor in a terminal =20 > shell window and it will start.=94 > > > > I have tried that, and its not so. So how can I have codeEditor =20 > running, and a =93live=94 Python Shell window also? Am I making any =20= > sense here? > > Thanks, > > Rich The codeEditor has a built-in shell. There are a number of different =20 ways that you could startup the codeEditor, but if they aren't giving =20= you specific instructions about how they want you to run it with =20 specific examples here are some things to try. Since you're on a Mac =20 you can run it from the Terminal by typing: python codeEditor.py This is assuming that the default python is 2.5.x. You can double-=20 check this by just typing: python at the Terminal prompt. You should see something like this: [machine:PythonCard/tools/codeEditor] bob% which python /Library/Frameworks/Python.framework/Versions/Current/bin/python [machine:PythonCard/tools/codeEditor] bob% python Python 2.5.1 (r251:54869, Apr 18 2007, 22:08:04) [GCC 4.0.1 (Apple Computer, Inc. build 5367)] on darwin Type "help", "copyright", "credits" or "license" for more information. Type Ctrl-D to quit the Python shell. So, assuming you have 2.5.x you =20= can just use "python" instead of pythonw to run GUI PythonCard =20 programs. Note the machine name, user name and directories will be =20 different on your setup. You can also provide a filename directly for =20= codeEditor to open up like this: python ~/python/PythonCard/tools/codeEditor/codeEditor.py somefile.py What I'm doing above is changing to a directory for a project I'm =20 working on and then providing a path to the codeEditor application so =20= Python can find it and a command-line filename argument for the file =20 I want to open, which in the example above is called somefile.py. If you have configured your Python Launcher correctly on the Mac, =20 which is located in your Applications->MacPython 2.5 directory then =20 you can also just double-click a Python file to run it. See the =20 instructions at: http://pythoncard.sourceforge.net/macosx_tiger_installation.html Basically, you want your interpreter set to /usr/local/bin/python Back in the Terminal you can see that this is a link to the 2.5.x Python ls -la /usr/local/bin/python lrwxr-xr-x 1 root wheel 68 Jul 23 13:35 /usr/local/bin/python -=20 > ../../../Library/Frameworks/Python.framework/Versions/2.5/bin/python I know it seems confusing, but all these links are the *nix way :) Anyway, what you'll want to do is make an alias of the PythonCard/=20 tools/codeEditor/codeEditor.py file a keep that on your desktop. Then =20= you can just double-click it to open it whenever you want. It keeps a =20= history of the last files you've been editing, so it should be easy =20 then to get back to what you were working on. Now finally, as far as the shell goes there is a Shell menu in the =20 codeEditor that you can toggle via the F5 key to hide/show it. This =20 is a full Python shell, so you can type in code there to try stuff =20 out. Note that the shell can be somewhat confusing for copying and =20 pasting on the Mac because it uses control instead of command (Ctrl-=20 C, Ctrl-V) for copy and paste and the codeEditor menu doesn't =20 actually deal correctly with shell selections so you need to rely on =20 the control keys. That is a bit of a Mac-specific bug and window =20 context, that hopefully one of these days we can workaround. Check =20 out the following page for more on the codeEditor shell: http://pythoncard.sourceforge.net/shell.html Note that you generally wouldn't run complete programs within the =20 shell, instead you would be editing them with the codeEditor and then =20= typing Command-R (run) or Command-Shift-R (run with interpreter). =20 Assuming you run the codeEditor from the Finder using Python Launcher =20= you'll probably want to keep the Console, which is in Applications-=20 >Utilities->Console open to see additional error messages that =20 otherwise would show up in the Terminal. I hope that answers your questions. ka= |