Search code examples
pythonwxpythondistutils

Distuils: Create script which does not "block" console when starting wx application


In my setup.py I have defined an entry point like this:

entry_points={
      'console_scripts' : [
            'cofo = cofo:gui_main'
      ]
},

Calling python setup.py develop generates the cofo script as expected. But gui_main starts a wxWindows application and I would like to "free" the console afterwards. How can I do that? If I use gui_scripts instead of console_scripts it does not make a difference.

Update:

With "free" the console, I mean that I would like to start the script from the command prompt (i.e. passing command line arguments to it), but would like to have the command prompt available after the gui has started. Something like this:

Last login: Mon Oct  8 15:34:28 on ttys002
localhost:~ domma$ cofo some arguments
... gui starts and after that ...
localhost:~ domma$ 

At the moment I don't get a waiting prompt, because the script is running and "blocking" the command line. My primary plattform is OS X, but I would be interested in a general solution.


Solution

  • With linux/unix (including Mac OS X) shells, you can run a command, and tell it to go to the background by suffixing it with "&". eg:

    $ cofo some arguments &
    

    Here is a page with some extra info on this: http://www.bsdguides.org/guides/netbsd/beginners/job_control/print

    I would recommend just manaully using that/educating your users to use that (if they are already using the a cli, then that is not alot extra to ask.) If you really want your command to go the the background by default, you can wrap your script with a small bash script that uses the above mentioned method.