Home Download Buy Blog Forum Support

kill: true not killing Python with GUI windows

kill: true not killing Python with GUI windows

Postby zsero on Tue Nov 20, 2012 1:06 am

I have a very simple problem. I am trying to use Sublime Text 2 for Python development and I'm writing a program where it calls a matplotlib GUI window.

Something as simple as:

Code: Select all
import matplotlib.pyplot as plt
import time

plt.ion()
plt.axis( [0, 1, 0, 1] )
plt.axes().set_aspect( 'equal' )
plt.show()

time.sleep( 1000 )


My problem is that I cannot kill this window. I've changed my keybinding to allow kill: true,
{ "keys": ["ctrl+shift+c"], "command": "exec", "args": {"kill": true} },


and it kind of kills the process, but python.exe stays running and the GUI window stays open. It seems the only way to kill the running process it from Task Manager.

Can you help me how to fix it? I'd like to have something similar to Shift + F2 in PyScripter, what could just kill these Python scripts.
zsero
 
Posts: 3
Joined: Sat Oct 13, 2012 4:13 am

Re: kill: true not killing Python with GUI windows

Postby bizoo on Tue Nov 20, 2012 7:46 am

What's your sublime-build file ?
Do you use the "shell" argument ?
bizoo
 
Posts: 879
Joined: Wed Dec 08, 2010 6:53 am
Location: Switzerland

Re: kill: true not killing Python with GUI windows

Postby zsero on Tue Nov 20, 2012 2:51 pm

bizoo wrote:What's your sublime-build file ?
Do you use the "shell" argument ?


The default one:

{
"cmd": ["python", "-u", "$file"],
"file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)",
"selector": "source.python",
"shell": "true"
}
zsero
 
Posts: 3
Joined: Sat Oct 13, 2012 4:13 am

Re: kill: true not killing Python with GUI windows

Postby bizoo on Tue Nov 20, 2012 4:34 pm

OK, so I suppose kill actually terminate the cmd.exe process, and not the python.exe process.
Try to create a new build file with:
Code: Select all
{
"cmd": ["c:\python27\python.exe", "-u", "$file"],
"file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)",
"selector": "source.python"
}

and replace cmd with the correct python path.

Not tested at all...
bizoo
 
Posts: 879
Joined: Wed Dec 08, 2010 6:53 am
Location: Switzerland


Return to General Discussion

Who is online

Users browsing this forum: Google [Bot] and 23 guests