Easy way to launch Python scripts with the mouse in OS-X

后端 未结 2 1277
野趣味
野趣味 2020-12-06 02:28

I\'d like to write cross platform Python scripts that are GUI frontends for command line programs. The problem is I know a few Mac users who think that using the terminal w

相关标签:
2条回答
  • 2020-12-06 02:44

    You might want to look at Platypus. It's a freeware app for generating apps which wrap scripts.

    Another way to do something like that is using Automator or even AppleScript Editor. Either can produce an application which just runs a script.

    Update:

    For Automator: Launch Automator, select the Application template, type "script" in the search field, double-click Run Shell Script, switch the shell pop-up menu to /usr/bin/python, type/paste your Python script into the text field. Or, leave the pop-menu on /bin/bash and just write an invocation of an external script in the text field. Save as an application.

    You can also view help from its Help menu.

    For AppleScript, launch AppleScript Editor, type the following as the script:

    do shell script "/usr/bin/true"
    

    Replace /usr/bin/true with the path to whatever script you like. Save as an application.

    Again, there's help in the Help menu.

    0 讨论(0)
  • 2020-12-06 02:56

    py2app does this with aplomb. You make your Python script, use whatever dependencies you need (wx, Tkinter, etc.) and py2app makes you a standalone app bundle that will run in any modern OS X environment. It bundles Python too, so you can use any Python you want (not just the system default).

    The downside is that the generated apps might be large, up to 50MB if you have a lot of dependencies (though that is somewhat of an extreme).

    0 讨论(0)
提交回复
热议问题