Kaydet (Commit) e20864d6 authored tarafından Guido van Rossum's avatar Guido van Rossum

* kill.py: Don't use the exec Tcl command.

üst 2dcf529b
#!/usr/local/bin/tkpython #!/usr/local/bin/tkpython
# Tkinter interface to Linux `ps' command. # Tkinter interface to Linux `kill' command.
from Tkinter import * from Tkinter import *
from string import splitfields from string import splitfields
from string import split from string import split
import commands
import posix
class BarButton(Menubutton): class BarButton(Menubutton):
_CNF = {Pack: {'side': 'left'}}
def __init__(self, master=None, cnf={}): def __init__(self, master=None, cnf={}):
Menubutton.__init__(self, master) Menubutton.__init__(self, master, (self._CNF, cnf))
self.pack({'side': 'left'})
self.config(cnf)
self.menu = Menu(self, {'name': 'menu'}) self.menu = Menu(self, {'name': 'menu'})
self['menu'] = self.menu self['menu'] = self.menu
...@@ -26,11 +27,11 @@ class Kill(Frame): ...@@ -26,11 +27,11 @@ class Kill(Frame):
def kill(self, selected): def kill(self, selected):
c = self.format_list[self.format.get()][2] c = self.format_list[self.format.get()][2]
pid = split(selected)[c] pid = split(selected)[c]
self.tk.call('exec', 'kill', '-9', pid) posix.system('kill' + ' -9 ' + pid)
self.do_update() self.do_update()
def do_update(self): def do_update(self):
name, option, column = self.format_list[self.format.get()] name, option, column = self.format_list[self.format.get()]
s = self.tk.call('exec', 'ps', '-w', option) s = commands.getoutput('ps -w ' + option)
list = splitfields(s, '\n') list = splitfields(s, '\n')
self.header.set(list[0]) self.header.set(list[0])
del list[0] del list[0]
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment