diff options
author | pmoxhay <pmoxhay@earthlink.net> | 2009-06-15 17:24:11 (GMT) |
---|---|---|
committer | pmoxhay <pmoxhay@earthlink.net> | 2009-06-15 17:24:11 (GMT) |
commit | 6db275a259770f7931516f0809ae227fa3ac9b98 (patch) | |
tree | 8f8d273970516bae8c976fb474d43acfd430e911 | |
parent | ce71dbf928fecaed48075a9fc4ae5361b0fbe375 (diff) |
Can now get next problem by key press; fixed tab problem when arrow is showing.
-rw-r--r-- | compare3lesson.py | 48 | ||||
-rw-r--r-- | nextproblemobject.py | 16 | ||||
-rw-r--r-- | objectarea.py | 4 | ||||
-rw-r--r-- | signsdroptarget.py | 5 |
4 files changed, 58 insertions, 15 deletions
diff --git a/compare3lesson.py b/compare3lesson.py index f982bd2..3e878d9 100644 --- a/compare3lesson.py +++ b/compare3lesson.py @@ -29,8 +29,8 @@ from answerobject import AnswerObject from groupobject import GroupObject from instructionsobject import InstructionsObject from progressobject import ProgressObject +from threedobject import ThreeDObject from nextproblemobject import NextProblemObject - from lengthproblem import LengthProblem from amountproblem import AmountProblem from areaproblem import AreaProblem @@ -84,6 +84,8 @@ class Compare3Lesson(ObjectArea): self.n_greater_than_problems_correct = 0 self.n_less_than_problems_correct = 0 + self.nextarrow = None + self.pose_problem_stage1() #TODO- Put this code in the ShapeObjects themselves. @@ -395,27 +397,35 @@ class Compare3Lesson(ObjectArea): self.symboldrop.drop_targets = [self.symboldrop] self.symboldrop.answer = self.problem.find_answer() - + #self.select_object(self.drop_origin.ltsymbol) self.adjust_tab_order() - def finish_problem_stage3(self): + def finish_problem_stage3(self): + #print "Compare3Lesson: finish_problem_stage3 called" # This means the problem is done, so we don't check stage 3 twice. self.stage = 4 + + i = 0 + for o in self.objects: + if isinstance(o, ShapeObject) and o.selectable: + i += 1 + o.selectable = False + #print "Compare3Lesson:",i,"ShapeObjects were made not selectable" # Put it all in an answer box. self.symbolanswer = AnswerObject(Vector(400 + 350, 600 - 50), Vector(400, 200), '3.') self.symbolanswer.z = -100 self.add_object(self.symbolanswer) - + #print "Get rid of the drop origin..." self.drop_origin.remove_contents() self.drop_origin.background_visible = False self.remove_object(self.drop_origin) - + #print "...and the drop targets." self.remove_object(self.symboldrop) - + if self.answer == 'greater': text = 'greater than' elif self.answer == 'less': @@ -428,11 +438,8 @@ class Compare3Lesson(ObjectArea): else: quantity_name = self.problem_type - #self.instructions.text = 'The ' + self.problem_type + ' ' + self.letter1.symbol + ' is ' \ - # + text + ' the ' + self.problem_type + ' ' + self.letter2.symbol self.instructions.text = 'The ' + quantity_name + ' ' + self.letter1.symbol + ' is ' \ + text + ' the ' + quantity_name + ' ' + self.letter2.symbol - if (self.n_errors == 0 and self.n_equals_problems_correct > 0 \ and self.n_greater_than_problems_correct > 0 and self.n_less_than_problems_correct > 0): self.level += 1 @@ -447,8 +454,10 @@ class Compare3Lesson(ObjectArea): # print "n_equals_problems_correct =", self.n_equals_problems_correct # print "n_greater_than_problems_correct =", self.n_greater_than_problems_correct # print "n_less_than_problems_correct =", self.n_less_than_problems_correct - + self.pose_next_problem_arrow() + self.select_object(self.nextarrow) + self.adjust_tab_order() def increment_n_equals_problems_correct(self): if self.n_errors == 0: @@ -463,6 +472,7 @@ class Compare3Lesson(ObjectArea): self.n_less_than_problems_correct += 1 def pose_next_problem_arrow(self): + #print "Compare3Lesson: pose_next_problem_arrow called" # Put it all in an answer box. self.nextarrow = NextProblemObject() self.add_object(self.nextarrow) @@ -487,6 +497,13 @@ class Compare3Lesson(ObjectArea): o_new = [] + i_next_problem = 0 + for o in self.objects: + if isinstance(o, NextProblemObject) and o.selectable: + i_next_problem += 1 + o_new.append(o) + #print "Found ", i_shape ," NextProblemObject " + i_shape = 0 for o in self.objects: if isinstance(o, ShapeObject) and o.selectable: @@ -540,6 +557,9 @@ class Compare3Lesson(ObjectArea): if isinstance (o, ShapeObject): if o.selected: index_selected = i + elif isinstance (o, ThreeDObject): + if o.selected: + index_selected = i elif isinstance (o, LineSegmentObject): if o.selected: index_selected = i @@ -552,6 +572,9 @@ class Compare3Lesson(ObjectArea): elif isinstance (o, GroupObject): if o.selected: index_selected = i + elif isinstance (o, NextProblemObject): + if o.selected: + index_selected = i i += 1 # Rotate the list. @@ -592,6 +615,11 @@ class Compare3Lesson(ObjectArea): return 1 elif isinstance(o1, GroupObject) and isinstance(o2, ShapeObject): return -1 + + elif isinstance(o1, ShapeObject) and isinstance(o2, NextProblemObject): + return 1 + elif isinstance(o1, NextProblemObject) and isinstance(o2, ShapeObject): + return -1 elif isinstance(o1, ShapeObject) and isinstance(o2, ShapeObject): if o1.selected: diff --git a/nextproblemobject.py b/nextproblemobject.py index 6f0a722..f45b612 100644 --- a/nextproblemobject.py +++ b/nextproblemobject.py @@ -27,7 +27,7 @@ class NextProblemObject(Object): Object.__init__(self) self.draggable = False - self.selectable = False + self.selectable = True self.pressed = False @@ -54,3 +54,17 @@ class NextProblemObject(Object): self.container.finish_next_problem_arrow() return True + def on_key(self, event): + key_name = gtk.gdk.keyval_name(event.keyval) + + # Useful print for determining the names of keys. + #print "NextProblemObject got a key press:",key_name + + if key_name == 'Up' or key_name == 'KP_Up' \ + or key_name == 'Down' or key_name == 'KP_Down' \ + or key_name == 'Left' or key_name == 'KP_Left' \ + or key_name == 'Right' or key_name == 'KP_Right' \ + or key_name == 'BackSpace' or key_name == 'KP_Page_Down' \ + or key_name == 'space': + self.container.finish_next_problem_arrow() + return True diff --git a/objectarea.py b/objectarea.py index af3f556..1d38837 100644 --- a/objectarea.py +++ b/objectarea.py @@ -270,11 +270,11 @@ class ObjectArea(gtk.Layout): # Tab key selects the next object.
if key_name == 'Tab' or key_name == 'KP_Home':
- #print "key_name was: ", key_name
+ #print "ObjectArea: on_key: key_name was ", key_name
#print " There are: ", len(self.objects), "objects"
if len(self.objects):
- #print " The currently selected object is: ", self.selected_object
+ print " The currently selected object is: ", self.selected_object
if self.selected_object:
index = self.objects.index(self.selected_object)
while True:
diff --git a/signsdroptarget.py b/signsdroptarget.py index 6c2506e..de3fa15 100644 --- a/signsdroptarget.py +++ b/signsdroptarget.py @@ -135,8 +135,9 @@ class SignsDropTarget(DropTargetObject): self.hilite = False
self.queue_draw()
- if self.drop_origin:
- self.container.select_object(self.drop_origin.ltsymbol)
+ if self.drop_origin:
+ if self.container:
+ self.container.select_object(self.drop_origin.ltsymbol)
if not self.answer_correct() and self.all_drop_targets_full():
self.container.show_hint()
|