@@ -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
@@ -70,34 +70,34 @@ def __init__(self, w, h, num_catagories=6, num_questions=5):
7070 self .text_off_x = ( self .box_w - w ) / 2
7171 self .text_off_y = ( self .box_h - h ) / 2
7272
73- class GridWindow (wx .Window ):
74- def __init__ (self , parent , game ):
73+ class GridWindow (wx .Window ):
74+ def __init__ (self , parent , game ):
7575 wx .Window .__init__ (self , parent )
7676 self .SetBackgroundColour ("White" )
7777
7878 self .game = game
7979
8080 ## a few initalzers
8181 self .Selected = None
82-
82+
8383 self .Bind (wx .EVT_PAINT , self .OnPaint )
8484 self .Bind (wx .EVT_SIZE , self .OnSize )
8585 self .Bind (wx .EVT_LEFT_DOWN , self .OnLeftDown )
8686 self .Bind (wx .EVT_MOTION , self .OnMotion )
8787
8888 self .OnSize ()
89-
89+
9090 def InitBuffer (self ):
91- w , h = self .GetClientSize ()
91+ w , h = self .GetClientSize ()
9292 self .buffer = wx .EmptyBitmap (w , h )
9393 self .DrawNow ()
94-
94+
9595 def OnSize (self , event = None ):
9696 size = self .GetClientSize ()
9797 if size [0 ] > 0 and size [1 ] > 1 :
9898 self .grid = GridGeom (* size )
9999 self .InitBuffer ()
100-
100+
101101 def DrawNow (self ):
102102 dc = wx .MemoryDC ()
103103 dc .SelectObject (self .buffer )
@@ -106,7 +106,7 @@ def DrawNow(self):
106106 self .Update ()
107107# dc = wx.BufferedDC(wx.ClientDC(self), self.buffer)
108108# self.Draw(dc)
109-
109+
110110 def Draw (self , dc ):
111111 # Make grid local:
112112 grid = self .grid
@@ -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
@@ -124,14 +124,14 @@ def Draw(self, dc):
124124 wx .FONTFAMILY_SWISS ,
125125 wx .FONTSTYLE_NORMAL ,
126126 wx .FONTWEIGHT_BOLD ))
127-
127+
128128 for i , cat in enumerate (self .game .catagories ):
129129 dc .SetBrush ( wx .Brush ("Blue" , wx .SOLID ) )
130130 dc .SetPen ( wx .Pen ("White" , width = 4 ) )
131131 dc .DrawRectangle (i * w + 3 , h + 3 , w - 6 , h - 6 )
132132 dc .DrawText (cat , i * w + grid .text_off_x , h + grid .text_off_y )
133133
134-
134+
135135 #draw cells
136136 dc .SetFont (wx .FontFromPixelSize ((grid .font_size , grid .font_size ),
137137 wx .FONTFAMILY_SWISS ,
@@ -155,7 +155,7 @@ def Draw(self, dc):
155155 # # draw the selected cells:
156156 # dc.SetBrush(wx.Brush("Red", wx.SOLID))
157157 # dc.DrawRectangle(x0 + d*self.Selected[1], y0 + d*self.Selected[0], d, d)
158-
158+
159159 # # draw the white lines:
160160 # dc.SetPen(wx.Pen("White", 2, wx.SOLID) )
161161 # for i in range(10):
@@ -181,8 +181,8 @@ 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+
185+
186186 def OnPaint (self , event ):
187187 dc = wx .BufferedPaintDC (self , self .buffer )
188188
@@ -229,20 +229,20 @@ def OnMotion(self, evt):
229229 # i = 0
230230 # if i < 0:
231231 # i = 8
232-
232+
233233 # self.Selected = (i,j)
234234 # self.DrawNow()
235-
235+
236236 # def SetValue(self, value):
237237 # self.Puzzle.Grid[self.Selected] = value
238-
238+
239239class MainFrame (wx .Frame ):
240240 def __init__ (self , parent , game ):
241241 wx .Frame .__init__ (self , parent , title = "Jeopardy" , size = (600 , 500 ))
242242 self .game = game
243243 self .grid = GridWindow (self , game )
244244 #self.ToolBar()
245-
245+
246246# def ToolBar(self):
247247# statusBar = self.CreateStatusBar()
248248# menuBar = wx.MenuBar()
@@ -269,11 +269,11 @@ class to handle drawing of question header
269269 FaceName = ''
270270
271271 def __init__ (self , text ):
272-
272+
273273 self .width = 100
274274 self .font_size = 12
275275 self .text = text
276-
276+
277277 self .wrap_to_width ()
278278 self .PadSize = 2
279279
@@ -378,34 +378,35 @@ def wrap_to_width(self):
378378# self.BoxHeight = BoxHeight
379379# self.CalcBoundingBox()
380380
381-
381+
382382 def draw (self , DC ):
383383 for word in question :
384384 pass
385-
386385
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")
393386
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-
387+ # class TestFrame(wx.Frame):
388+ # def __init__(self, *args, **kwargs):
389+ # wx.Frame.__init__(self, *args, **kwargs)
402390
403- if __name__ == '__main__' :
404- A = wx .App ()
405- F = TestFrame (None , title = "test frame" )
406- A .mainloop ()
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)
407401
408- if False :
402+
403+ # if __name__ == '__main__':
404+ # A = wx.App()
405+ # F = TestFrame(None, title="test frame")
406+ # F.Show()
407+ # A.MainLoop()
408+
409+ if __name__ == '__main__' :
409410
410411 catagories = [None for i in range (6 )]
411412 questions = [ [None for i in range (5 )] for j in range (6 ) ]
0 commit comments