Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/lessonscreen.py
diff options
context:
space:
mode:
authorWade Brainerd <wadetb@gmail.com>2008-11-21 18:01:52 (GMT)
committer Wade Brainerd <wadetb@gmail.com>2008-11-21 18:01:52 (GMT)
commitfc297655b7b84c058985200d4f712e49dba9ac29 (patch)
tree0fc31cc7b5ee047826c2386d410d7d3ebf35e5d9 /lessonscreen.py
parentde9ee0339ee37a8ada6ff7dfbbebe103bb493026 (diff)
Fix bug with old lessons still hearing keypresses.
Change timer to 1 second. Use Unicode in word wrap regex.
Diffstat (limited to 'lessonscreen.py')
-rw-r--r--lessonscreen.py22
1 files changed, 14 insertions, 8 deletions
diff --git a/lessonscreen.py b/lessonscreen.py
index e1871ce..b09f925 100644
--- a/lessonscreen.py
+++ b/lessonscreen.py
@@ -113,21 +113,26 @@ class LessonScreen(gtk.VBox):
self.keyboard = keyboard.Keyboard(self.activity)
self.keyboard.set_layout(keyboard.DEFAULT_LAYOUT)
- self.activity.add_events(gtk.gdk.KEY_PRESS_MASK)
- self.key_press_cb_id = self.activity.connect('key-press-event', self.key_press_cb)
-
self.pack_start(hbox, False, False, 10)
self.pack_start(frame, True, True)
self.pack_start(self.keyboard, True)
+ # Connect keyboard grabbing and releasing callbacks.
+ self.connect('realize', self.realize_cb)
+ self.connect('unrealize', self.unrealize_cb)
+
self.show_all()
self.begin_lesson()
-
- gobject.timeout_add(250, self.timer_cb)
- def __del__(self):
- print "Disconnecting keypress callback."
+ # Initialize stats update timer.
+ gobject.timeout_add(1000, self.timer_cb)
+
+ def realize_cb(self, widget):
+ self.activity.add_events(gtk.gdk.KEY_PRESS_MASK)
+ self.key_press_cb_id = self.activity.connect('key-press-event', self.key_press_cb)
+
+ def unrealize_cb(self, widget):
self.activity.disconnect(self.key_press_cb_id)
def update_stats(self):
@@ -168,7 +173,8 @@ class LessonScreen(gtk.VBox):
self.advance_step()
def wrap_line(self, line):
- words = re.split('(\W+)', line)
+ r = re.compile('(\W+)', re.UNICODE)
+ words = r.split(line)
new_lines = []
cur_line = ''