7
7
lets you run a simple game yourself, with questions and
8
8
answers provided by you.
9
9
10
+ NOTE: very much a work in progress!
11
+
10
12
This code is in the public domain
11
13
12
14
13
15
14
16
"""
15
17
16
-
17
18
import wx
18
19
20
+
19
21
class Question (object ):
20
22
"""
21
23
A class to hold each question, and data about it.
@@ -182,7 +184,6 @@ def Draw(self, dc):
182
184
# dc.DrawLine(x0, y0 + d*i, x0 + d*3, y0 + d*i)
183
185
# dc.DrawLine(x0 + d*i, y0, x0 + d*i, y0 + d*3)
184
186
185
-
186
187
def OnPaint (self , event ):
187
188
dc = wx .BufferedPaintDC (self , self .buffer )
188
189
@@ -191,7 +192,7 @@ def OnLeftDown(self, e):
191
192
grid = self .grid
192
193
x , y = e .GetPositionTuple ()
193
194
i = x / grid .box_w
194
- j = y / grid .box_h
195
+ j = y / grid .box_h - 1 # compensate for header
195
196
if i >= 0 and i < grid .num_cat and j >= 0 and j < grid .num_ques :
196
197
self .game .questions [i ][j ].answered = not self .game .questions [i ][j ].answered
197
198
self .DrawNow ()
@@ -378,92 +379,69 @@ def wrap_to_width(self):
378
379
# self.BoxHeight = BoxHeight
379
380
# self.CalcBoundingBox()
380
381
382
+ # def draw(self, DC):
383
+ # for word in question:
384
+ # pass
381
385
382
- def draw (self , DC ):
383
- for word in question :
384
- pass
385
-
386
-
387
- # class TestFrame(wx.Frame):
388
- # def __init__(self, *args, **kwargs):
389
- # wx.Frame.__init__(self, *args, **kwargs)
390
-
391
- # self.Bind(wx.EVT_PAINT, self.OnPaint)
392
- # #self.header = Header("This is a pretty long question that will need to wrap")
393
-
394
- # #header.wrap_to_width
395
- # #print header.question_lines
396
-
397
- # def OnPaint(self, evt):
398
- # dc = wx.PaintDC(self)
399
- # #if self.header is not None:
400
- # # self.header.draw(dc)
401
-
402
-
403
- # if __name__ == '__main__':
404
- # A = wx.App()
405
- # F = TestFrame(None, title="test frame")
406
- # F.Show()
407
- # A.MainLoop()
408
386
409
387
if __name__ == '__main__' :
410
388
411
389
catagories = [None for i in range (6 )]
412
- questions = [ [None for i in range (5 )] for j in range (6 ) ]
413
- ## test data:
390
+ questions = [[None for i in range (5 )] for j in range (6 )]
391
+
392
+ # test data:
414
393
415
394
catagories [0 ] = "Household Pets"
416
- questions [0 ][0 ] = Question ("slobbery" ,"what is a dog?" , 100 )
417
- questions [0 ][1 ] = Question ("cute an fuzzy" ,"what is a cat?" , 200 )
418
- questions [0 ][2 ] = Question ("long and slithery" ,"what is a snake?" , 300 )
419
- questions [0 ][3 ] = Question ("sometimes lives in a sewer" ,"what is a rat?" , 400 )
420
- questions [0 ][4 ] = Question ("a reptile often mistaken for an amphibian" ,"what is a turtle?" , 500 )
395
+ questions [0 ][0 ] = Question ("slobbery" , "what is a dog?" , 100 )
396
+ questions [0 ][1 ] = Question ("cute and fuzzy" , "what is a cat?" , 200 )
397
+ questions [0 ][2 ] = Question ("long and slithery" , "what is a snake?" , 300 )
398
+ questions [0 ][3 ] = Question ("sometimes lives in a sewer" , "what is a rat?" , 400 )
399
+ questions [0 ][4 ] = Question ("a reptile often mistaken for an amphibian" ,
400
+ "what is a turtle?" , 500 )
421
401
422
- ## test data:
423
402
catagories [1 ] = "Household Pets"
424
- questions [1 ][0 ] = Question ("slobbery" ,"what is a dog?" , 100 )
425
- questions [1 ][1 ] = Question ("cute an fuzzy" ,"what is a cat?" , 200 )
426
- questions [1 ][2 ] = Question ("long and slithery" ,"what is a snake?" , 300 )
427
- questions [1 ][3 ] = Question ("sometimes lives in a sewer" ,"what is a rat?" , 400 )
428
- questions [1 ][4 ] = Question ("a reptile often mistaken for an amphibian" ,"what is a turtle?" , 500 )
403
+ questions [1 ][0 ] = Question ("slobbery" , "what is a dog?" , 100 )
404
+ questions [1 ][1 ] = Question ("cute an fuzzy" , "what is a cat?" , 200 )
405
+ questions [1 ][2 ] = Question ("long and slithery" , "what is a snake?" , 300 )
406
+ questions [1 ][3 ] = Question ("sometimes lives in a sewer" , "what is a rat?" , 400 )
407
+ questions [1 ][4 ] = Question ("a reptile often mistaken for an amphibian" ,
408
+ "what is a turtle?" , 500 )
429
409
430
- ## test data:
431
410
catagories [2 ] = "Household Pets"
432
- questions [2 ][0 ] = Question ("slobbery" ,"what is a dog?" , 100 )
433
- questions [2 ][1 ] = Question ("cute an fuzzy" ,"what is a cat?" , 200 )
434
- questions [2 ][2 ] = Question ("long and slithery" ,"what is a snake?" , 300 )
435
- questions [2 ][3 ] = Question ("sometimes lives in a sewer" ,"what is a rat?" , 400 )
436
- questions [2 ][4 ] = Question ("a reptile often mistaken for an amphibian" ,"what is a turtle?" , 500 )
411
+ questions [2 ][0 ] = Question ("slobbery" , "what is a dog?" , 100 )
412
+ questions [2 ][1 ] = Question ("cute an fuzzy" , "what is a cat?" , 200 )
413
+ questions [2 ][2 ] = Question ("long and slithery" , "what is a snake?" , 300 )
414
+ questions [2 ][3 ] = Question ("sometimes lives in a sewer" , "what is a rat?" , 400 )
415
+ questions [2 ][4 ] = Question ("a reptile often mistaken for an amphibian" ,
416
+ "what is a turtle?" , 500 )
437
417
438
- ## test data:
439
418
catagories [3 ] = "Household Pets"
440
- questions [3 ][0 ] = Question ("slobbery" ,"what is a dog?" , 100 )
441
- questions [3 ][1 ] = Question ("cute an fuzzy" ,"what is a cat?" , 200 )
442
- questions [3 ][2 ] = Question ("long and slithery" ,"what is a snake?" , 300 )
443
- questions [3 ][3 ] = Question ("sometimes lives in a sewer" ,"what is a rat?" , 400 )
444
- questions [3 ][4 ] = Question ("a reptile often mistaken for an amphibian" ,"what is a turtle?" , 500 )
445
- ## test data:
419
+ questions [3 ][0 ] = Question ("slobbery" , "what is a dog?" , 100 )
420
+ questions [3 ][1 ] = Question ("cute an fuzzy" , "what is a cat?" , 200 )
421
+ questions [3 ][2 ] = Question ("long and slithery" , "what is a snake?" , 300 )
422
+ questions [3 ][3 ] = Question ("sometimes lives in a sewer" , "what is a rat?" , 400 )
423
+ questions [3 ][4 ] = Question ("a reptile often mistaken for an amphibian" ,
424
+ "what is a turtle?" , 500 )
446
425
catagories [4 ] = "Household Pets"
447
- questions [4 ][0 ] = Question ("slobbery" ,"what is a dog?" , 100 )
448
- questions [4 ][1 ] = Question ("cute an fuzzy" ,"what is a cat?" , 200 )
449
- questions [4 ][2 ] = Question ("long and slithery" ,"what is a snake?" , 300 )
450
- questions [4 ][3 ] = Question ("sometimes lives in a sewer" ,"what is a rat?" , 400 )
451
- questions [4 ][4 ] = Question ("a reptile often mistaken for an amphibian" ,"what is a turtle?" , 500 )
426
+ questions [4 ][0 ] = Question ("slobbery" , "what is a dog?" , 100 )
427
+ questions [4 ][1 ] = Question ("cute an fuzzy" , "what is a cat?" , 200 )
428
+ questions [4 ][2 ] = Question ("long and slithery" , "what is a snake?" , 300 )
429
+ questions [4 ][3 ] = Question ("sometimes lives in a sewer" , "what is a rat?" , 400 )
430
+ questions [4 ][4 ] = Question ("a reptile often mistaken for an amphibian" ,
431
+ "what is a turtle?" , 500 )
452
432
453
- ## test data:
454
433
catagories [5 ] = "Household Pets"
455
- questions [5 ][0 ] = Question ("slobbery" ,"what is a dog?" , 100 )
456
- questions [5 ][1 ] = Question ("cute an fuzzy" ,"what is a cat?" , 200 )
457
- questions [5 ][2 ] = Question ("long and slithery" ,"what is a snake?" , 300 )
458
- questions [5 ][3 ] = Question ("sometimes lives in a sewer" ,"what is a rat?" , 400 )
459
- questions [5 ][4 ] = Question ("a reptile often mistaken for an amphibian" ,"what is a turtle?" , 500 )
460
-
461
-
462
- #set a few as answered
434
+ questions [5 ][0 ] = Question ("slobbery" , "what is a dog?" , 100 )
435
+ questions [5 ][1 ] = Question ("cute an fuzzy" , "what is a cat?" , 200 )
436
+ questions [5 ][2 ] = Question ("long and slithery" , "what is a snake?" , 300 )
437
+ questions [5 ][3 ] = Question ("sometimes lives in a sewer" , "what is a rat?" , 400 )
438
+ questions [5 ][4 ] = Question ("a reptile often mistaken for an amphibian" ,
439
+ "what is a turtle?" , 500 )
440
+
441
+ # set a few as answered
463
442
questions [3 ][3 ].answered = True
464
443
questions [2 ][4 ].answered = True
465
444
466
-
467
445
app = wx .App (0 )
468
446
game = Game (catagories , questions )
469
447
frame = MainFrame (None , game )
0 commit comments