Shortcut for IDLE on Mac OS X (LEOPARD)

View: New views
12 Messages — Rating Filter:   Alert me  

Shortcut for IDLE on Mac OS X (LEOPARD)

by Gregor Lingl-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

I'm relatively new to the Mac.
I have a Python 3.1.1. installation on my Macbook
and I'd like to have a shortcut on my desktop starting
IDLE with the -n switch, that is without subprocess

Under Windows I'd rightclick on the desktop, create a
new shortcut and then enter as the target:

C:\Python31\pythonw C:\Python31\Lib\idlelib\idle.pyw -n
Then I have to give it a name and it's ready. (Additionally
I have the option to change the icon)

Is there a similar and similarly simple way to do this
with Mac OS X? (Leopard)

I am able to start IDLE in this mode from a terminal,
but thats rather cumbersome

python3
/Library/Frameworks/Python.framework/Versions/3.1/lib/python3.1/idlelib/idle.py
-n

So Id' like to automate it. (I observed, that the IDLE entry in the
program folder
is not a simple shortcut, so I couldn't find a way to edit an alias of
it, in order
to add the -n option.)

Thanks in advance for some cool hints

Gregor
_______________________________________________
Pythonmac-SIG maillist  -  Pythonmac-SIG@...
http://mail.python.org/mailman/listinfo/pythonmac-sig

Re: Shortcut for IDLE on Mac OS X (LEOPARD)

by Ronald Oussoren :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


On 7 Oct, 2009, at 22:18, Gregor Lingl wrote:

> Hi,
>
> I'm relatively new to the Mac.
> I have a Python 3.1.1. installation on my Macbook
> and I'd like to have a shortcut on my desktop starting
> IDLE with the -n switch, that is without subprocess

Why do you want to do that?  Is there functionality in IDLE that works  
with the '-n' switch but not without it?

>
> Under Windows I'd rightclick on the desktop, create a
> new shortcut and then enter as the target:
>
> C:\Python31\pythonw C:\Python31\Lib\idlelib\idle.pyw -n
> Then I have to give it a name and it's ready. (Additionally
> I have the option to change the icon)
>
> Is there a similar and similarly simple way to do this
> with Mac OS X? (Leopard)
>
> I am able to start IDLE in this mode from a terminal,
> but thats rather cumbersome
>
> python3 /Library/Frameworks/Python.framework/Versions/3.1/lib/
> python3.1/idlelib/idle.py -n
You can store this command in a file and then give the file execute  
permissions, e.g.:

  $ cat > run-IDLE <<-EOF
  #!/bin/sh
  /Library/Frameworks/Python.frameworks/Versions/3.1/bin/python3 \
     /Library/Frameworks/Python.framework/Versions/3.1/lib/python3.1/
idlelib/idle.py -n
  EOF
  $ chmod 755 run-IDLE

Double-clicking should then start IDLE.

The result is not quite equivalent to IDLE.app in the "Python 3.1"  
folder, that is a real application bundle and contains some special  
code to ensures that IDLE behaves more like a Mac applications (in  
particular the key bindings).

Ronald



_______________________________________________
Pythonmac-SIG maillist  -  Pythonmac-SIG@...
http://mail.python.org/mailman/listinfo/pythonmac-sig

smime.p7s (4K) Download Attachment

Re: Shortcut for IDLE on Mac OS X (LEOPARD)

by Gregor Lingl-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message



Ronald Oussoren schrieb:

>
> On 7 Oct, 2009, at 22:18, Gregor Lingl wrote:
>
>> Hi,
>>
>> I'm relatively new to the Mac.
>> I have a Python 3.1.1. installation on my Macbook
>> and I'd like to have a shortcut on my desktop starting
>> IDLE with the -n switch, that is without subprocess
>
> Why do you want to do that?  Is there functionality in IDLE that works
> with the '-n' switch but not without it?
Yes, I want to do interactive turtle graphics. (In fact I've written a book,
"Python für Kids" and I was asked by a reader how to do it on a Mac.)

>
>>
>> Under Windows I'd rightclick on the desktop, create a
>> new shortcut and then enter as the target:
>>
>> C:\Python31\pythonw C:\Python31\Lib\idlelib\idle.pyw -n
>> Then I have to give it a name and it's ready. (Additionally
>> I have the option to change the icon)
>>
>> Is there a similar and similarly simple way to do this
>> with Mac OS X? (Leopard)
>>
>> I am able to start IDLE in this mode from a terminal,
>> but thats rather cumbersome
>>
>> python3
>> /Library/Frameworks/Python.framework/Versions/3.1/lib/python3.1/idlelib/idle.py
>> -n
>
The solution you gave works fine for me. It retains those features of IDLE
I use. (At least as far as I could see on a quick inspection)

> You can store this command in a file and then give the file execute
> permissions, e.g.:
>
>  $ cat > run-IDLE <<-EOF
>  #!/bin/sh
>  /Library/Frameworks/Python.frameworks/Versions/3.1/bin/python3 \
>    
> /Library/Frameworks/Python.framework/Versions/3.1/lib/python3.1/idlelib/idle.py
> -n
>  EOF
>  $ chmod 755 run-IDLE
Of course I, and especially the Kids, would prefer to click an icon on
the desktop, or the
dock. But as a first solution I appreciate this one very much.

Thanks for the quick help!
Gregor

> Double-clicking should then start IDLE.
>
> The result is not quite equivalent to IDLE.app in the "Python 3.1"
> folder, that is a real application bundle and contains some special
> code to ensures that IDLE behaves more like a Mac applications (in
> particular the key bindings).
>
> Ronald
>
_______________________________________________
Pythonmac-SIG maillist  -  Pythonmac-SIG@...
http://mail.python.org/mailman/listinfo/pythonmac-sig

Parent Message unknown Re: Shortcut for IDLE on Mac OS X (LEOPARD)

by George Wright-4 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Gregor
Here's one way to do it. My example is for python2.5 not python3.::
Create a shell script that will do the job for you. I've called mine "startidle".
Make it executable:  chmod +x startidle
Test from Terminal that it works.
Open AppleScript Editor application and create a new script called "startIdle.scpt" with the following text::
------------------------------------------------------------------------------------------
-- A script to call and run the shell script "startIdle"
-- Both this script and the shell script should be in the "AppleScriptsFolder" within
-- the "mypythonstuff" folder in the home folder.
-- George Wright
-- 8th Oct 2009


set myIdle to POSIX path of file ((path to home folder as string) & ("mypythonstuff:" & "AppleScriptsFolder:" & "startidle"))
set g to (do shell script myIdle)

-- For discussion on calling shell scripts from AppleScript see my article

------------------------------------------------------------------------------------------

Click the Run button in AppleScript Editor  to test that works. Save as "startIdle.scpt"
Lastly after you are satisfied that it all works OK save  "startIdle" again as an application
"startIdle.app" and drag that or an alias of it (Command + L ) to the desktop.
Double click to start.

Hope that helps

George Wright

On 08/10/2009, at 7:18 AM, Gregor wrote:


Hi,

I'm relatively new to the Mac.
I have a Python 3.1.1. installation on my Macbook
and I'd like to have a shortcut on my desktop starting
IDLE with the -n switch, that is without subprocess

Under Windows I'd rightclick on the desktop, create a
new shortcut and then enter as the target:

C:\Python31\pythonw C:\Python31\Lib\idlelib\idle.pyw -n
Then I have to give it a name and it's ready. (Additionally
I have the option to change the icon)

Is there a similar and similarly simple way to do this
with Mac OS X? (Leopard)

I am able to start IDLE in this mode from a terminal,
but thats rather cumbersome

python3 /Library/Frameworks/Python.framework/Versions/3.1/lib/python3.1/idlelib/idle.py -n

So Id' like to automate it. (I observed, that the IDLE entry in the program folder
is not a simple shortcut, so I couldn't find a way to edit an alias of it, in order
to add the -n option.)

Thanks in advance for some cool hints

Gregor



_______________________________________________
Pythonmac-SIG maillist  -  Pythonmac-SIG@...
http://mail.python.org/mailman/listinfo/pythonmac-sig

Re: Shortcut for IDLE on Mac OS X (LEOPARD)

by Michael Crawford-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Wed, Oct 7, 2009 at 3:05 PM, Gregor Lingl <gregor.lingl@...> wrote:
> Yes, I want to do interactive turtle graphics. (In fact I've written a book,
> "Python für Kids" and I was asked by a reader how to do it on a Mac.)

I'm very interested to hear more about your book.  Do you also have an
English translation?

For a while now I've had the idea of writing a Sugar activity for the
One Laptop Per Child project, that would teach kids how to code in
Python, without assuming that they know anything at all about
computers.

There are lots of coding tutorials, even lots of Python tutorials, but
almost all of them assume that one already knows some other language -
and that one is a grownup.

> Of course I, and especially the Kids, would prefer to click an icon on the
> desktop, or the
> dock. But as a first solution I appreciate this one very much.

I think you could write a simple AppleScript that would do the same
thing as that shell script.  AppleScript have icons that are more
harmonious with the Mac experience.

Alternatively you could write a very simple C program that you build
with Xcode as a Mac application (a ".app" application bundle).  It
would launch idle the way you want it and then quit.  It would look
just like any regular Mac OS X application and could even have a fancy
icon.

This program would use either the execve system call or the system
library function to actually do the launch.  Reaching the end of main
after doing so would cleanly quit the launcher.

See "man execve" and "man system".

The difference is that execve launches a program directly, whereas
system launches a shell that then executes the command line you feed
it.

Mike
--
Michael David Crawford
mdcrawford at gmail dot com

   GoingWare's Bag of Programming Tricks
      http://www.goingware.com/tips/
_______________________________________________
Pythonmac-SIG maillist  -  Pythonmac-SIG@...
http://mail.python.org/mailman/listinfo/pythonmac-sig

Re: Shortcut for IDLE on Mac OS X (LEOPARD)

by Ben Golding :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


On 08/10/2009, at 07:18, Gregor Lingl wrote:

> I am able to start IDLE in this mode from a terminal,
> but thats rather cumbersome
>
> python3 /Library/Frameworks/Python.framework/Versions/3.1/lib/
> python3.1/idlelib/idle.py -n

You should be able to put this in a double-clickable file by putting  
that string in a file called, say, IDLE.command and then making it  
executable.  Files ending in ".command" are recognised by Launch  
Services as shell scripts (I believe).  That is:

        cat >IDLE.command <<!
        python3 /Library/Frameworks/Python.framework/Versions/3.1/lib/
python3.1/idlelib/idle.py -n
        !
        chmod +x IDLE.command

If you double click that it should launch the app as expected.

        Ben.

_______________________________________________
Pythonmac-SIG maillist  -  Pythonmac-SIG@...
http://mail.python.org/mailman/listinfo/pythonmac-sig

smime.p7s (2K) Download Attachment

Re: Shortcut for IDLE on Mac OS X (LEOPARD)

by Christopher Barker :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Ben Golding wrote:
> You should be able to put this in a double-clickable file by putting
> that string in a file called, say, IDLE.command and then making it
> executable.  Files ending in ".command" are recognised by Launch
> Services as shell scripts (I believe).

Has no-one made a nifty utility to make a *.app bundle from a shell
script? That would seem like an obvious utility to want...

-Chris


--
Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R            (206) 526-6959   voice
7600 Sand Point Way NE   (206) 526-6329   fax
Seattle, WA  98115       (206) 526-6317   main reception

Chris.Barker@...
_______________________________________________
Pythonmac-SIG maillist  -  Pythonmac-SIG@...
http://mail.python.org/mailman/listinfo/pythonmac-sig

Re: Shortcut for IDLE on Mac OS X (LEOPARD)

by Christopher Barker :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Christopher Barker wrote:
> Has no-one made a nifty utility to make a *.app bundle from a shell
> script? That would seem like an obvious utility to want...

There is platypus:

http://www.sveinbjorn.org/platypus

perhaps overkill, but it looks like it will work.

Though in this case, it seems re-building the IDLE bundle the way you
want may be better.

-Chris



--
Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R            (206) 526-6959   voice
7600 Sand Point Way NE   (206) 526-6329   fax
Seattle, WA  98115       (206) 526-6317   main reception

Chris.Barker@...
_______________________________________________
Pythonmac-SIG maillist  -  Pythonmac-SIG@...
http://mail.python.org/mailman/listinfo/pythonmac-sig

Re: Shortcut for IDLE on Mac OS X (LEOPARD)

by Ronald Oussoren :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


On 8 Oct, 2009, at 0:05, Gregor Lingl wrote:

>
>
> Ronald Oussoren schrieb:
>>
>> On 7 Oct, 2009, at 22:18, Gregor Lingl wrote:
>>
>>> Hi,
>>>
>>> I'm relatively new to the Mac.
>>> I have a Python 3.1.1. installation on my Macbook
>>> and I'd like to have a shortcut on my desktop starting
>>> IDLE with the -n switch, that is without subprocess
>>
>> Why do you want to do that?  Is there functionality in IDLE that  
>> works with the '-n' switch but not without it?
> Yes, I want to do interactive turtle graphics. (In fact I've written  
> a book,
> "Python für Kids" and I was asked by a reader how to do it on a Mac.)
Could you file an issue about this in the python tracker? It should be  
possible to add a setting to IDLE's preferences that selects whether  
or not you want the '-n' flag.

It is definitely possible to create a simple .app bundle that runs as-
if you specified the '-n' flag, I'll see if I can make some time to  
build that.

Ronald

_______________________________________________
Pythonmac-SIG maillist  -  Pythonmac-SIG@...
http://mail.python.org/mailman/listinfo/pythonmac-sig

smime.p7s (4K) Download Attachment

Re: Shortcut for IDLE on Mac OS X (LEOPARD)

by davelist :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


On Oct 7, 2009, at 7:35 PM, Christopher Barker wrote:

> Ben Golding wrote:
>> You should be able to put this in a double-clickable file by  
>> putting that string in a file called, say, IDLE.command and then  
>> making it executable.  Files ending in ".command" are recognised by  
>> Launch Services as shell scripts (I believe).
>
> Has no-one made a nifty utility to make a *.app bundle from a shell  
> script? That would seem like an obvious utility to want...
>
> -Chris

You can do that with Automator by choosing the Application template,  
choosing the shell-script action, and then saving it.

Dave

_______________________________________________
Pythonmac-SIG maillist  -  Pythonmac-SIG@...
http://mail.python.org/mailman/listinfo/pythonmac-sig

Re: Shortcut for IDLE on Mac OS X (LEOPARD)

by Gregor Lingl-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message



Thanks for all those replies. I'll try them out and investigate them
next weekend.
Subsequently I'll give you some more feedback.

For those of you using Python 2.6 or 3.x and interested in Python's new
turtle module:

There is a turtle subdirectory in the Demo folder of your Python
installation.
There you can find a script called turtleDemo.py that lets you view and
run demos
from a set of approx.15 demo scripts.

morever you can find a set of 50+ demos here:

http://python-turtle-demo.googlecode.com

Regards,
Gregor
>
_______________________________________________
Pythonmac-SIG maillist  -  Pythonmac-SIG@...
http://mail.python.org/mailman/listinfo/pythonmac-sig

Re: Shortcut for IDLE on Mac OS X (LEOPARD)

by Ned Deily :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

In article <4ACE4FE3.6050904@...>,
 Gregor Lingl <gregor.lingl@...> wrote:
> There is a turtle subdirectory in the Demo folder of your Python
> installation.
> There you can find a script called turtleDemo.py that lets you view and
> run demos
> from a set of approx.15 demo scripts.

I love those demos.  I use them all the time to test Python!

--
 Ned Deily,
 nad@...

_______________________________________________
Pythonmac-SIG maillist  -  Pythonmac-SIG@...
http://mail.python.org/mailman/listinfo/pythonmac-sig