Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/activity.py
diff options
context:
space:
mode:
authorChris Ball <cjb@pullcord.laptop.org>2007-09-10 19:35:58 (GMT)
committer Chris Ball <cjb@pullcord.laptop.org>2007-09-10 19:35:58 (GMT)
commita650af79e3e67c4e470e425505d61e59b519a18b (patch)
tree0d9ca16c959b78246566ebaa973c151cf9520213 /activity.py
parente1c0a90e1b50754c5216436b4942f4ffbe24d8f7 (diff)
Add a "Stop!" button.
Diffstat (limited to 'activity.py')
-rw-r--r--activity.py21
1 files changed, 18 insertions, 3 deletions
diff --git a/activity.py b/activity.py
index 8505ab7..3d0fb16 100644
--- a/activity.py
+++ b/activity.py
@@ -27,6 +27,7 @@ import vte
import sys
import os
import gobject
+from signal import SIGTERM
from dbus import Interface
from dbus.service import method, signal
@@ -123,11 +124,22 @@ class PippyActivity(Activity):
codesw.add(self.text_view)
vbox.pack_start(codesw)
+ # An hbox for the buttons
+ buttonhbox = gtk.HBox()
+
# The "go" button
gobutton = gtk.Button(label="Run!")
gobutton.connect('clicked', self.gobutton_cb)
- gobutton.set_size_request(1000, 2)
- vbox.pack_start(gobutton)
+ gobutton.set_size_request(800, 2)
+ buttonhbox.pack_start(gobutton)
+
+ # The "stop" button
+ stopbutton = gtk.Button(label="Stop!")
+ stopbutton.connect('clicked', self.stopbutton_cb)
+ stopbutton.set_size_request(200, 2)
+ buttonhbox.pack_end(stopbutton)
+
+ vbox.pack_start(buttonhbox)
# An hbox to hold the vte window and its scrollbar.
outbox = gtk.HBox()
@@ -204,7 +216,10 @@ class PippyActivity(Activity):
file.write(line)
file.close()
- pid = self._vte.fork_command("/bin/sh", ["/bin/sh", "-c", "python /tmp/pippy.py; sleep 1"])
+ self._pid = self._vte.fork_command("/bin/sh", ["/bin/sh", "-c", "python /tmp/pippy.py; sleep 1"])
+
+ def stopbutton_cb(self, button):
+ os.kill(self._pid, SIGTERM)
def write_file(self, file_path):
self.metadata['mime_type'] = 'text/x-python'