[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.python

Getting started with OS X Leopard

jt

3/15/2008 6:05:00 PM

One thing I really liked about Ubuntu was that Nautilus allowed you to
add scripts to a directory which could be accessed via the RMB. It was a
very simple thing to do.

I've recently switched to Leopard, and I'm trying to do the same thing.
I'm fairly experienced with Python, but new to OS X. I have installed
FinderPop, which lets me add scripts and make them accessible via
Contextual Menus, but it is not as easy as the Nautilus way.

The sorts of things I want to do are:
* copy the directory of Finder to the clipboard
* add a new file to Finder's directory.
* find out the size of a directory
* open a file with Aquamacs, regardless of file type,

My head's swimming, though. Anyone got any really good pointers and
sample scripts that will help me work out how to achieve the sorts of
things I'm trying to do?
17 Answers

hengist podd

3/15/2008 6:48:00 PM

0

On 15 Mar, 18:05, Mark Carter <m...@privacy.net> wrote:
> The sorts of things I want to do are:
> * copy the directory of Finder to the clipboard
> * add a new file to Finder's directory.
> * find out the size of a directory
> * open a file with Aquamacs, regardless of file type,

If you want to control desktop applications directly, that generally
means using Apple event IPC. The most popular language for application
scripting is traditionally AppleScript, but Apple event bridges exist
for other languages as well. The best of these is appscript; see my
sig for links. Some Finder scripting examples:


#!/usr/bin/python

from appscript import *
from osax import *

finder = app('Finder')
standardadditions = ScriptingAddition()

folderref = finder.Finder_windows[1].target

# set clipboard to path to front window's folder
path = folderref.get(resulttype=k.alias).path
standardadditions.set_the_clipboard_to(path)

# make new empty file in front window's folder
finder.make(new=k.file, at=folderref.get())

# get size of front window's folder
# (note: this may return k.missing_value when first run
# as Finder is sluggish at calculating folder sizes)
print folderref.size.get()

# open selected items in TextEdit
selecteditems = finder.selection.get()
finder.open(selecteditems,
using=app.application_files.ID('com.apple.textedit'))



HTH

has
--
Control AppleScriptable applications from Python, Ruby and ObjC:
http://appscript.sourc...


jt

3/15/2008 7:31:00 PM

0

has wrote:
> On 15 Mar, 18:05, Mark Carter <m...@privacy.net> wrote:
>> The sorts of things I want to do are:
>> * copy the directory of Finder to the clipboard
>> * add a new file to Finder's directory.
>> * find out the size of a directory
>> * open a file with Aquamacs, regardless of file type,
>
> If you want to control desktop applications directly, that generally
> means using Apple event IPC. The most popular language for application
> scripting is traditionally AppleScript, but Apple event bridges exist
> for other languages as well. The best of these is appscript; see my
> sig for links. Some Finder scripting examples:
>
>
> #!/usr/bin/python
>
....
> Control AppleScriptable applications from Python, Ruby and ObjC:
> http://appscript.sourc...


Aah! Many thanks. I see that I had to do
easy_install appscript
and ensure I use /usr/bin/python
I'm off to play with it now. Exciting stuff.

I installed the Python from MacPorts. That's not quite what I wanted,
because they only have a version for Python 2.4. *Sigh*. MacPorts seems
to be getting new ports all the time. The problem is, there also seems
to be an aweful lot of ports gathering bitrot.

Am I the only one to form the opinion that OS X can sometimes appear to
be a bit of a mish-mash?

I tried XCode the other day. Seemed a bit complicated, if you ask me.
I've tried to like Lisp, too. In the end, Python just rocks. I started
out with Glade a short while ago, and I'm impressed how relatively easy
it is to create GUIs and add handlers in Python.


Arnaud Delobelle

3/15/2008 7:41:00 PM

0

On Mar 15, 7:31 pm, Mark Carter <m...@privacy.net> wrote:
> has wrote:
> > On 15 Mar, 18:05, Mark Carter <m...@privacy.net> wrote:
> >> The sorts of things I want to do are:
> >> * copy the directory of Finder to the clipboard
> >> * add a new file to Finder's directory.
> >> * find out the size of a directory
> >> * open a file with Aquamacs, regardless of file type,
>
> > If you want to control desktop applications directly, that generally
> > means using Apple event IPC. The most popular language for application
> > scripting is traditionally AppleScript, but Apple event bridges exist
> > for other languages as well. The best of these is appscript; see my
> > sig for links. Some Finder scripting examples:
>
> > #!/usr/bin/python
>
> ...
> > Control AppleScriptable applications from Python, Ruby and ObjC:
> >http://appscript.sourc...
>
> Aah! Many thanks. I see that I had to do
> easy_install appscript
> and ensure I use /usr/bin/python
> I'm off to play with it now. Exciting stuff.
>
> I installed the Python from MacPorts. That's not quite what I wanted,
> because they only have a version for Python 2.4. *Sigh*. MacPorts seems
> to be getting new ports all the time. The problem is, there also seems
> to be an aweful lot of ports gathering bitrot.

Is there a particular reason you want python from MacPorts? OSX
Leopard comes with python 2.5, that's what I use on my mac.

--
Arnaud

jt

3/15/2008 8:06:00 PM

0

Arnaud Delobelle wrote:

> Is there a particular reason you want python from MacPorts? OSX
> Leopard comes with python 2.5, that's what I use on my mac.

I heard from somewhere that Apple's version was a bit wonky, and that I
would be better off with a "proper" build.

Kevin Walzer

3/15/2008 8:34:00 PM

0

Mark Carter wrote:
> Arnaud Delobelle wrote:
>
>> Is there a particular reason you want python from MacPorts? OSX
>> Leopard comes with python 2.5, that's what I use on my mac.
>
> I heard from somewhere that Apple's version was a bit wonky, and that I
> would be better off with a "proper" build.

Not sure where you heard that. Apple's Python is built according to Mac
guidelines (as a "framework"), but it works the same as on other platforms.

--
Kevin Walzer
Code by Kevin
http://www.codeb...

martin.laloux

3/15/2008 8:43:00 PM

0


if you are not satisfied with the native version, why not install the
official version directly from python site
http://www.python.org... (macpython) instead of using that of
macports. It moreover is provided with many utilities

There is a macpython list that you can consult at
http://www.nabble.com/Python---pythonmac-sig-...

jt

3/15/2008 9:35:00 PM

0

martin.laloux@gmail.com wrote:
> if you are not satisfied with the native version, why not install the
> official version directly from python site
> http://www.python.org... (macpython) instead of using that of
> macports. It moreover is provided with many utilities
>
> There is a macpython list that you can consult at
> http://www.nabble.com/Python---pythonmac-sig-...

Thanks.

Actually, I created my first python appscript (well, "stole" it from a
previous poster is more like it) - and it's pretty cool when I combine
it with FinderPop.

Ray O'Hara

11/28/2011 3:15:00 AM

0


"DGDevin" <DGDevin@invalid.invalid> wrote in message
news:_5qdneHfFIyJaU_TnZ2dnUVZ_sKdnZ2d@earthlink.com...
>
>
> "sweetbac" wrote in message news:jaup7j$g2v$1@dont-email.me...
>
>
>>> "BlindLemonDebbin" <DGDevin@invalid.invalid> moaned in message
>
>>> Kind of a sad article on the two kinds of blues clubs
>
>> I dint have to read it.
>> Blues is dead.
>
> I know a bunch of folks who make a living largely playing the blues, from
> where I stand it seems to be quite a lively corpse.
>
>> Young spades aren't playing it...aint listening to it...
>> and are not going to blues clubs.
>
> Do you talk like that in real life, is that where the evidence of multiple
> concussions comes from?
>
>> It's amazing that the last blues dude to break thru to
>> a wide audience was white ( SR Vaughan )...that'll
>> tell ya all you need to know....
>
> So when Buddy Guy gets a standing ovation from a *stadium* audience at the
> Crossroads festival, what's that, indifference?
>
>> I (barely) tolerate white
>> jazz musicians...a white MF'er playing the blues?
>
> It's like Paul Lynde announcing he doesn't like beer, he really shouldn't
> expect the information to have much impact in the wider world.
>
>> I had enough...went into the bathroom to return some rubbers
>> ( they were too small )...
>
> [Sigh]. Poor Dave, fell for the old fingers-cut-off-a-rubber-glove for
> five bucks a pop, poor sap.
>
>> tipped the old spade a jackson, and
>> cut out of the club shaking my head in disgust and sadness.
>
> Come on D-Kell, when was the last time you had twenty bucks that wasn't in
> the form of a sock full of sticky coins?
>

Blues is alive and well with older Whites.
Kids of all races are not hugely interested.


DGDevin

11/28/2011 4:00:00 AM

0



"Ray O'Hara" wrote in message news:jauub9$92d$1@dont-email.me...


> Blues is alive and well with older Whites.
> Kids of all races are not hugely interested.

Kids of all races are not hugely interested in a whole range of things,
doesn't mean those things are dead.

Ray O'Hara

11/28/2011 4:35:00 AM

0


"DGDevin" <DGDevin@invalid.invalid> wrote in message
news:g6adnQHRNrLAmk7TnZ2dnUVZ_vydnZ2d@earthlink.com...
>
>
> "Ray O'Hara" wrote in message news:jauub9$92d$1@dont-email.me...
>
>
>> Blues is alive and well with older Whites.
>> Kids of all races are not hugely interested.
>
> Kids of all races are not hugely interested in a whole range of things,
> doesn't mean those things are dead.
>

no, but when the older fans die off the now older no longer kids still won't
be fans of the Blues.
When I got out to a club to see the Blues kids are rare , usually younger
ones dragged by parents.
very few 20 somethings are there, the crowds run some 540s but mostly 50s
and 60 year olds.
tis sad.

but then, how big is your Glenn Miller and Benny Goodman collection.