- if not dc:
- dc = wxClientDC(self)
- dc.SetFont(self.font)
- dc.Clear()
- (x,y) = self.GetSizeTuple()
- x1 = x-200; y1 = 20
- for letter in self.word:
- if self.guess.count(letter):
- dc.DrawText(letter, x1, y1)
- else:
- dc.DrawText('.', x1, y1)
- x1 = x1 + 10
- x1 = x-200
- dc.DrawText("tries %d misses %d" % (self.tries,self.misses),x1,50)
- guesses = ""
- for letter in self.guess:
- guesses = guesses + letter
- dc.DrawText("guessed:", x1, 70)
- dc.DrawText(guesses[:13], x1+80, 70)
- dc.DrawText(guesses[13:], x1+80, 90)
- dc.SetUserScale(x/1000., y/1000.)
- self.DrawVictim(dc)
+ if not dc:
+ dc = wxClientDC(self)
+ dc.SetFont(self.font)
+ dc.Clear()
+ (x,y) = self.GetSizeTuple()
+ x1 = x-200; y1 = 20
+ for letter in self.word:
+ if self.guess.count(letter):
+ dc.DrawText(letter, x1, y1)
+ else:
+ dc.DrawText('.', x1, y1)
+ x1 = x1 + 10
+ x1 = x-200
+ dc.DrawText("tries %d misses %d" % (self.tries,self.misses),x1,50)
+ guesses = ""
+ for letter in self.guess:
+ guesses = guesses + letter
+ dc.DrawText("guessed:", x1, 70)
+ dc.DrawText(guesses[:13], x1+80, 70)
+ dc.DrawText(guesses[13:], x1+80, 90)
+ dc.SetUserScale(x/1000., y/1000.)
+ self.DrawVictim(dc)
- dc.SetPen(wxPen(wxNamedColour('black'), 20))
- dc.DrawLines([(10, 980), (10,900), (700,900), (700,940), (720,940),
- (720,980), (900,980)])
- dc.DrawLines([(100,900), (100, 100), (300,100)])
- dc.DrawLine(100,200,200,100)
- if ( self.misses == 0 ): return
- dc.SetPen(wxPen(wxNamedColour('blue'), 10))
- dc.DrawLine(300,100,300,200)
- if ( self.misses == 1 ): return
- dc.DrawEllipse(250,200,100,100)
- if ( self.misses == 2 ): return
- dc.DrawLine(300,300,300,600)
- if ( self.misses == 3) : return
- dc.DrawLine(300,300,250,550)
- if ( self.misses == 4) : return
- dc.DrawLine(300,300,350,550)
- if ( self.misses == 5) : return
- dc.DrawLine(300,600,350,850)
- if ( self.misses == 6) : return
- dc.DrawLine(300,600,250,850)
+ dc.SetPen(wxPen(wxNamedColour('black'), 20))
+ dc.DrawLines([(10, 980), (10,900), (700,900), (700,940), (720,940),
+ (720,980), (900,980)])
+ dc.DrawLines([(100,900), (100, 100), (300,100)])
+ dc.DrawLine(100,200,200,100)
+ if ( self.misses == 0 ): return
+ dc.SetPen(wxPen(wxNamedColour('blue'), 10))
+ dc.DrawLine(300,100,300,200)
+ if ( self.misses == 1 ): return
+ dc.DrawEllipse(250,200,100,100)
+ if ( self.misses == 2 ): return
+ dc.DrawLine(300,300,300,600)
+ if ( self.misses == 3) : return
+ dc.DrawLine(300,300,250,550)
+ if ( self.misses == 4) : return
+ dc.DrawLine(300,300,350,550)
+ if ( self.misses == 5) : return
+ dc.DrawLine(300,600,350,850)
+ if ( self.misses == 6) : return
+ dc.DrawLine(300,600,250,850)
- wxDialog.__init__(self, parent, -1, "About Hangman", wxDefaultPosition, wxSize(350,450))
- self.wnd = HangmanDemo(wf, self, -1, wxPoint(1,1), wxSize(350,150))
- self.static = wxStaticText(self, -1, __doc__, wxPoint(1,160), wxSize(350, 250))
- self.button = wxButton(self, 2001, "OK", wxPoint(150,420), wxSize(50,-1))
- EVT_BUTTON(self, 2001, self.OnOK)
+ wxDialog.__init__(self, parent, -1, "About Hangman", wxDefaultPosition, wxSize(350,450))
+ self.wnd = HangmanDemo(wf, self, -1, wxPoint(1,1), wxSize(350,150))
+ self.static = wxStaticText(self, -1, __doc__, wxPoint(1,160), wxSize(350, 250))
+ self.button = wxButton(self, 2001, "OK", wxPoint(150,420), wxSize(50,-1))
+ EVT_BUTTON(self, 2001, self.OnOK)
- self.wf = wf
- wxFrame.__init__(self, NULL, -1, "hangman", wxDefaultPosition, wxSize(400,300))
- self.wnd = HangmanWnd(self, -1)
- menu = wxMenu()
- menu.Append(1001, "New")
- menu.Append(1002, "End")
- menu.AppendSeparator()
- menu.Append(1003, "Reset")
- menu.Append(1004, "Demo...")
- menu.AppendSeparator()
- menu.Append(1005, "Exit")
- menubar = wxMenuBar()
- menubar.Append(menu, "Game")
- menu = wxMenu()
- #menu.Append(1010, "Internal", "Use internal dictionary", TRUE)
- menu.Append(1011, "ASCII File...")
- urls = [ 'wxPython home', 'http://208.240.253.245/wxPython/main.html',
- 'slashdot.org', 'http://slashdot.org/',
- 'cnn.com', 'http://cnn.com',
- 'The New York Times', 'http://www.nytimes.com',
- 'De Volkskrant', 'http://www.volkskrant.nl/frameless/25000006.html',
- 'Gnu GPL', 'http://www.fsf.org/copyleft/gpl.html',
- 'Bijbel: Genesis', 'http://www.coas.com/bijbel/gn1.htm']
- urlmenu = wxMenu()
- for item in range(0,len(urls),2):
- urlmenu.Append(1020+item/2, urls[item], urls[item+1])
- urlmenu.Append(1080, 'Other...', 'Enter an URL')
- menu.AppendMenu(1012, 'URL', urlmenu, 'Use a webpage')
- menu.Append(1013, 'Dump', 'Write contents to stdout')
- menubar.Append(menu, "Dictionary")
- self.urls = urls
- self.urloffset = 1020
- menu = wxMenu()
- menu.Append(1090, "About...")
- menubar.Append(menu, "Help")
- self.SetMenuBar(menubar)
- self.CreateStatusBar(2)
- EVT_MENU(self, 1001, self.OnGameNew)
- EVT_MENU(self, 1002, self.OnGameEnd)
- EVT_MENU(self, 1003, self.OnGameReset)
- EVT_MENU(self, 1004, self.OnGameDemo)
- EVT_MENU(self, 1005, self.OnWindowClose)
- EVT_MENU(self, 1011, self.OnDictFile)
- EVT_MENU_RANGE(self, 1020, 1020+len(urls)/2, self.OnDictURL)
- EVT_MENU(self, 1080, self.OnDictURLSel)
- EVT_MENU(self, 1013, self.OnDictDump)
- EVT_MENU(self, 1090, self.OnHelpAbout)
- EVT_CHAR(self.wnd, self.OnChar)
- self.OnGameReset()
+ self.wf = wf
+ wxFrame.__init__(self, NULL, -1, "hangman", wxDefaultPosition, wxSize(400,300))
+ self.wnd = HangmanWnd(self, -1)
+ menu = wxMenu()
+ menu.Append(1001, "New")
+ menu.Append(1002, "End")
+ menu.AppendSeparator()
+ menu.Append(1003, "Reset")
+ menu.Append(1004, "Demo...")
+ menu.AppendSeparator()
+ menu.Append(1005, "Exit")
+ menubar = wxMenuBar()
+ menubar.Append(menu, "Game")
+ menu = wxMenu()
+ #menu.Append(1010, "Internal", "Use internal dictionary", TRUE)
+ menu.Append(1011, "ASCII File...")
+ urls = [ 'wxPython home', 'http://208.240.253.245/wxPython/main.html',
+ 'slashdot.org', 'http://slashdot.org/',
+ 'cnn.com', 'http://cnn.com',
+ 'The New York Times', 'http://www.nytimes.com',
+ 'De Volkskrant', 'http://www.volkskrant.nl/frameless/25000006.html',
+ 'Gnu GPL', 'http://www.fsf.org/copyleft/gpl.html',
+ 'Bijbel: Genesis', 'http://www.coas.com/bijbel/gn1.htm']
+ urlmenu = wxMenu()
+ for item in range(0,len(urls),2):
+ urlmenu.Append(1020+item/2, urls[item], urls[item+1])
+ urlmenu.Append(1080, 'Other...', 'Enter an URL')
+ menu.AppendMenu(1012, 'URL', urlmenu, 'Use a webpage')
+ menu.Append(1013, 'Dump', 'Write contents to stdout')
+ menubar.Append(menu, "Dictionary")
+ self.urls = urls
+ self.urloffset = 1020
+ menu = wxMenu()
+ menu.Append(1090, "About...")
+ menubar.Append(menu, "Help")
+ self.SetMenuBar(menubar)
+ self.CreateStatusBar(2)
+ EVT_MENU(self, 1001, self.OnGameNew)
+ EVT_MENU(self, 1002, self.OnGameEnd)
+ EVT_MENU(self, 1003, self.OnGameReset)
+ EVT_MENU(self, 1004, self.OnGameDemo)
+ EVT_MENU(self, 1005, self.OnWindowClose)
+ EVT_MENU(self, 1011, self.OnDictFile)
+ EVT_MENU_RANGE(self, 1020, 1020+len(urls)/2, self.OnDictURL)
+ EVT_MENU(self, 1080, self.OnDictURLSel)
+ EVT_MENU(self, 1013, self.OnDictDump)
+ EVT_MENU(self, 1090, self.OnHelpAbout)
+ EVT_CHAR(self.wnd, self.OnChar)
+ self.OnGameReset()