Creative way to run any Applescript in Python

Posted on
Wed Jul 12, 2017 10:25 am
jay (support) offline
Site Admin
User avatar
Posts: 18200
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Creative way to run any Applescript in Python

FlyingDiver wrote:
The only thing my script might need is some code to remove leading zeros from hours or dates. But I really doubt having the zeros there would change the TTS results.


The format() method can create the time/date string without leading 0's:

Code: Select all
indigo.variable.updateValue(pennwood_date, '{dt:%A}, {dt:%B} {dt.day}'.format(dt=now))
indigo.variable.updateValue(pennwood_time, '{dt.hour}:{dt.minute} {dt:%p}'.format(dt=now))


That should generate the time and day without leading 0's.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Wed Jul 12, 2017 2:59 pm
wideglidejrp offline
User avatar
Posts: 555
Joined: Jan 15, 2012
Location: Danbury, CT

Re: Creative way to run any Applescript in Python

Is there a simple way to try code snippets like this without having to create a new action group embedded script?

John R Patrick
Author of
Home Attitude

Posted on
Wed Jul 12, 2017 3:00 pm
FlyingDiver offline
User avatar
Posts: 7189
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: Creative way to run any Applescript in Python

wideglidejrp wrote:
Is there a simple way to try code snippets like this without having to create a new action group embedded script?


Python scripting shell. At the very bottom of the Plugins menu. Or just create a testing action group and edit the code in there and hit the run button without closing the dialog.

joe (aka FlyingDiver)
my plugins: http://forums.indigodomo.com/viewforum.php?f=177

Posted on
Wed Jul 12, 2017 3:12 pm
wideglidejrp offline
User avatar
Posts: 555
Joined: Jan 15, 2012
Location: Danbury, CT

Re: Creative way to run any Applescript in Python

I misspoke about creating, not what I meant. Updating the values is what I meant. Looks Joe's script plus Jay's snippets solve my issue. Thanks very much.

John R Patrick
Author of
Home Attitude

Posted on
Wed Jul 12, 2017 3:38 pm
jay (support) offline
Site Admin
User avatar
Posts: 18200
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Creative way to run any Applescript in Python

wideglidejrp wrote:
Is there a simple way to try code snippets like this without having to create a new action group embedded script?


The documentation is your friend...

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Wed Jul 12, 2017 3:51 pm
DaveL17 offline
User avatar
Posts: 6744
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: Creative way to run any Applescript in Python

wideglidejrp wrote:
Is there a simple way to try code snippets like this without having to create a new action group embedded script?

In addition to Joe's suggestion, I actually prefer the Indigo embedded scripting window for constructing small bits of code. In my opinion, it's easier to click the compile button to test against the Indigo server and fix errors. I have a deactivated schedule called "Scratchpad" which I use for throw away work. It's also nice to be able to save something and go back to it later.

But the best part is that there's more than one way to do things. To each their own!

I came here to drink milk and kick ass....and I've just finished my milk.

[My Plugins] - [My Forums]

Posted on
Wed Jul 12, 2017 4:39 pm
wideglidejrp offline
User avatar
Posts: 555
Joined: Jan 15, 2012
Location: Danbury, CT

Re: Creative way to run any Applescript in Python

Agree on scratchpads. I use a scratchpad notebook in Evernote for many throw away things. For Indigo, I use a test python action group. I also find TextExpander extremely productive. I right click to get the ID and...

if I type iag, TextExpander types indigo.actionGroup.execute(whatever is in the clipboard, in this case the ID) #
if I type isl I get indigo.server.log(whatever is in the clipboard) #
Etc.

Saves a lot of keystrokes. You can also have TE type something and then place the cursor wherever you want it for input.

John R Patrick
Author of
Home Attitude

Who is online

Users browsing this forum: No registered users and 4 guests