Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Stone <michael@laptop.org>2010-08-17 03:06:22 (GMT)
committer Michael Stone <michael@laptop.org>2010-08-17 03:12:06 (GMT)
commit0ab5853582eb0118d55fb3feac04fd96ad24265a (patch)
tree5eded80f42ccc6a44eff5d0f17d9427e26629972
parent2306bfec6129c0c9bf406e4ea1b4a0e180568c24 (diff)
Support multi-line problems.
gtk.TextView knows how to render ASCII newlines. Monospaced fonts make it easy to make pretty problems via fixed-width format specifiers.
-rw-r--r--arithmetic.py6
-rw-r--r--puzzles/00_addition.py2
2 files changed, 4 insertions, 4 deletions
diff --git a/arithmetic.py b/arithmetic.py
index 24f2ded..6100f73 100644
--- a/arithmetic.py
+++ b/arithmetic.py
@@ -163,8 +163,8 @@ class ArithmeticActivity(groupthink.sugar_tools.GroupActivity):
self.cloud.puzzles.register_listener(self.new_puzzles_cb)
# Text entry box for question
- self.questionentry = gtk.Entry(max=50)
- self.questionentry.modify_font(pango.FontDescription("Sans 14"))
+ self.questionentry = gtk.TextView()
+ self.questionentry.modify_font(pango.FontDescription("Mono 14"))
self.questionentry.set_property("editable", False)
# Text entry box for answer
@@ -335,7 +335,7 @@ class ArithmeticActivity(groupthink.sugar_tools.GroupActivity):
def start_question(self):
self.starttime = time.time()
self.generate_new_question()
- self.questionentry.set_text(self.question)
+ self.questionentry.get_buffer().set_text(self.question)
self.answergiven = False
self.answerentry.set_text("")
self.decisionentry.set_text("")
diff --git a/puzzles/00_addition.py b/puzzles/00_addition.py
index 71140a2..0a65e43 100644
--- a/puzzles/00_addition.py
+++ b/puzzles/00_addition.py
@@ -4,6 +4,6 @@ name = "Addition"
def get_problem(self, difficulty):
x = self.generate_number(difficulty)
y = self.generate_number(difficulty)
- question = "%s + %s" % (x, y)
+ question = " %2d\n+ %2d" % (x, y)
answer = x + y
return question, answer