Python Forum
Opening and closing Mac applications and files
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Opening and closing Mac applications and files
#2
If you want to launch an app and wait for the user to exit, you could use /usr/bin/open and subprocess.run. If you want to continue the program after launching, could use subprocess.Popen.

>>> import subprocess
>>> subprocess.run(["/usr/bin/open", "-a", "calendar"])  # waits until calendar exit
CompletedProcess(args=['/usr/bin/open', '-a', 'calendar'], returncode=0)
>>> subprocess.Popen(["/usr/bin/open", "-a", "calendar"]) # returns immediately
<subprocess.Popen object at 0x1065e3048> 
I'm not sure if there's a more direct interface that avoids /usr/bin/open.
Reply


Messages In This Thread
RE: Opening and closing Mac applications and files - by bowlofred - Sep-04-2020, 07:30 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Phyton Opening files on windows C: pc EddieG 3 1,006 Mar-29-2023, 03:19 PM
Last Post: buran
  opening files and output of parsing leodavinci1990 4 2,574 Oct-12-2020, 06:52 AM
Last Post: bowlofred
  Closing Files - CSV Reader/Writer lummers 2 2,634 May-28-2020, 06:36 AM
Last Post: Knight18
  Internationalization of applications ? JohnnyCoffee 1 1,764 Apr-17-2020, 09:39 PM
Last Post: Larz60+
  How To Find an Opening and Closing String, Copying Open/Close/Contents to New File davidshq 1 2,058 Mar-03-2020, 04:47 AM
Last Post: davidshq
  PYHTON not opening files profficial 11 13,668 Feb-15-2020, 09:06 AM
Last Post: bharathendra
  Automating Windows GUI applications metro17 4 12,370 Feb-10-2020, 09:46 AM
Last Post: metro17
  Handling Thick client applications using Python PraveenSubramaniyan 1 3,267 Jul-22-2019, 01:08 PM
Last Post: DeaD_EyE
  opening a file from a windows desktop folder- error opening file Charan007 1 3,004 Dec-06-2018, 11:50 AM
Last Post: buran

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020