Skip to content

Commit 908650e

Browse files
minor fix to Jeopardy
1 parent b64f133 commit 908650e

File tree

1 file changed

+9
-11
lines changed

1 file changed

+9
-11
lines changed

Jeopardy.py

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def __init__(self, catagories, questions):
3434
self.questions = questions
3535
self.num_cat = len(catagories)
3636
self.num_ques = len(questions[0])
37-
37+
3838
def all_answered(self):
3939
"""
4040
returns True if all the questions are answered
@@ -55,7 +55,7 @@ def __init__(self, w, h, num_catagories=6, num_questions=5):
5555
self.box_h = h / (num_questions + 1)
5656
self.num_cat = num_catagories
5757
self.num_ques = num_questions
58-
58+
5959
self.font_size = min( int(self.box_w / 2), int(self.box_h / 2) )
6060

6161
##figure out the text offset
@@ -115,7 +115,7 @@ def Draw(self, dc):
115115
# draw the background:
116116
dc.SetBackground(wx.Brush(self.GetBackgroundColour()))
117117
dc.Clear()
118-
dc.SetBrush(wx.Brush(wx.Color(128,128,255)))
118+
dc.SetBrush(wx.Brush(wx.Colour(128,128,255)))
119119
dc.SetPen(wx.TRANSPARENT_PEN)
120120
dc.DrawRectangle(0, 0, w * grid.num_cat, h * grid.num_ques)
121121

@@ -181,8 +181,7 @@ def Draw(self, dc):
181181
# for i in range(4):
182182
# dc.DrawLine(x0, y0 + d*i, x0 + d*3, y0 + d*i)
183183
# dc.DrawLine(x0 + d*i, y0, x0 + d*i, y0 + d*3)
184-
185-
184+
186185
def OnPaint(self, event):
187186
dc = wx.BufferedPaintDC(self, self.buffer)
188187

@@ -191,7 +190,7 @@ def OnLeftDown(self, e):
191190
grid = self.grid
192191
x, y = e.GetPositionTuple()
193192
i = x / grid.box_w
194-
j = y / grid.box_h
193+
j = y / grid.box_h - 1 # compensate for header
195194
if i >= 0 and i < grid.num_cat and j >= 0 and j < grid.num_ques:
196195
self.game.questions[i][j].answered = not self.game.questions[i][j].answered
197196
self.DrawNow()
@@ -401,19 +400,18 @@ def OnPaint(self, evt):
401400

402401

403402
if __name__ == '__main__':
404-
A = wx.App()
405-
F = TestFrame(None, title="test frame")
406-
A.mainloop()
403+
# A = wx.App()
404+
# F = TestFrame(None, title="test frame")
405+
# A.MainLoop()
407406

408-
if False:
409407

410408
catagories = [None for i in range(6)]
411409
questions = [ [None for i in range(5)] for j in range(6) ]
412410
## test data:
413411

414412
catagories[0] = "Household Pets"
415413
questions[0][0] = Question("slobbery","what is a dog?", 100)
416-
questions[0][1] = Question("cute an fuzzy","what is a cat?", 200)
414+
questions[0][1] = Question("cute and fuzzy","what is a cat?", 200)
417415
questions[0][2] = Question("long and slithery","what is a snake?", 300)
418416
questions[0][3] = Question("sometimes lives in a sewer","what is a rat?", 400)
419417
questions[0][4] = Question("a reptile often mistaken for an amphibian","what is a turtle?", 500)

0 commit comments

Comments
 (0)