imp
imp

Reputation: 2087

How to call external application with arguments in python on mac osx

I am using mac osx 10.9 and python 2.7 From one main app code, I want to call another application dailogbox.app present in /Applications location. dailogbox.app requires two arguments title and message as arguments. So, how to call from main app code this dailogbox.app with these two arguments to pass.

dailogbox.py code is :

import sys
import easygui
msg=(sys.argv)[1]
title=(sys.argv)[2]
easygui.msgbox(msg,title)

Upvotes: 2

Views: 1222

Answers (1)

chepner
chepner

Reputation: 531035

Assuming dialogbox.app is a normal OS X application, you can use the open command to run it.

import subprocess
msg=sys.argv[1]
title=sys.argv[2]
subprocess.call(["open", "dialogbox.app", "--args", msg, title])

Upvotes: 3

Related Questions