You can subscribe to this list here.
2004 |
Jan
|
Feb
|
Mar
|
Apr
(45) |
May
(185) |
Jun
|
Jul
(36) |
Aug
(205) |
Sep
(98) |
Oct
(107) |
Nov
(6) |
Dec
(3) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2005 |
Jan
(1) |
Feb
(2) |
Mar
(19) |
Apr
(26) |
May
(18) |
Jun
|
Jul
(12) |
Aug
(16) |
Sep
(22) |
Oct
(7) |
Nov
(11) |
Dec
(74) |
2006 |
Jan
(14) |
Feb
(1) |
Mar
(3) |
Apr
(3) |
May
(14) |
Jun
(5) |
Jul
(20) |
Aug
(10) |
Sep
(1) |
Oct
|
Nov
(4) |
Dec
(1) |
2007 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
(3) |
Jul
(14) |
Aug
|
Sep
|
Oct
(6) |
Nov
(1) |
Dec
|
From: Rowland S. <mon...@us...> - 2004-05-02 16:31:44
|
Update of /cvsroot/pythoncard/PythonCard In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13034 Modified Files: event.py Log Message: Added Handler.execute() method. This will be used when we move to Component inheriting from Scriptable, and puts the responsibility for executing a handler on the Scriptable object, as opposed to EventDispatch getting the handler from the Scriptable and then calling it. This method currently is being used in experimental code that we will eventually switch over to. Index: event.py =================================================================== RCS file: /cvsroot/pythoncard/PythonCard/event.py,v retrieving revision 1.61 retrieving revision 1.62 diff -C2 -d -r1.61 -r1.62 *** event.py 1 May 2004 18:47:50 -0000 1.61 --- event.py 2 May 2004 16:31:33 -0000 1.62 *************** *** 10,13 **** --- 10,14 ---- import wx + class Handler: """ *************** *** 48,53 **** --- 49,69 ---- def getFunction( self ) : + """ + RDS - 2004-05-02 + Once we've switched to the new component.Scriptable + design, remove this method and all references to it. + """ return self._function + def execute( self, target, event ) : + """ + RDS - 2004-05-02 + Added to support new Scriptable design in + component.Scriptable. Ask the Handler to + execute itself instead of getting it's + function and calling it. + """ + self._function( target, event ) + def __repr__( self ) : return str( self.__dict__ ) *************** *** 83,86 **** --- 99,103 ---- return self._oldValue + class ChangeListener : """ |
From: Kevin A. <ka...@us...> - 2004-05-02 02:40:51
|
Update of /cvsroot/pythoncard/PythonCard/samples/reversi In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24236/samples/reversi Added Files: .cvsignore readme.txt reversi.py reversi.rsrc.py Log Message: added reversi (Othello) sample --- NEW FILE: reversi.rsrc.py --- { 'stack':{ 'type':'Stack', 'name':'Reversi', 'backgrounds': [ { 'type':'Background', 'name':'bgReversi', 'title':'Reversi Game', 'size':( 350, 350 ), 'statusBar':True, 'menubar': { 'type':'MenuBar', 'menus': [ { 'type':'Menu', 'name':'menuFile', 'label':'&File', 'items': [ { 'type':'MenuItem', 'name':'menuFileNewGame', 'label':'&New Game\tCtrl+N' }, { 'type':'MenuItem', 'name':'menuFileExit', 'label':'E&xit\tAlt+X', 'command':'exit' } ] }, { 'type':'Menu', 'name':'mnuStrategy', 'label':'&Strategy', 'items': [ { 'type':'MenuItem', 'name':'menuStrategyFlipMostPieces', 'label':'Flip Most Pieces', 'checkable':1, 'checked':1 }, { 'type':'MenuItem', 'name':'menuStrategyRandom', 'label':'Random', 'checkable':1, 'checked':0}, ] } ] }, 'components': [ { 'type':'BitmapCanvas', 'name':'bufOff', 'position':(0, 30), 'size':(300, 300), 'backgroundColor':'green', }, ] } ] } } --- NEW FILE: .cvsignore --- .cvsignore *.pyc *.log .DS_Store --- NEW FILE: readme.txt --- A simplistic implementation of the board game Reversi, better known as Othello. --- NEW FILE: reversi.py --- #!/usr/bin/python """ Simplistic implementation of the board game reversi, better known as Othello. The algorithm for determining legal moves is not particularly efficient since no attempt is made to cache legal moves. """ """ __version__ = "$Revision: 1.1 $" __date__ = "$Date: 2004/05/02 02:40:43 $" """ from PythonCard import dialog, model from random import randint import time EMPTY = None BLACK = True WHITE = False BOARDWIDTH = BOARDHEIGHT = 8 DIRECTIONS = ((-1, -1), (0, -1), (1, -1), (-1, 0), (1, 0), (-1, 1), (0, 1), (1, 1)) BOARDCOLOR = 'dark green' CELLWIDTH = CELLHEIGHT = 37 class GameBoard: def __init__(self): self.initializeBoard() def initializeBoard(self): self.board = {} # the board references are column, row # to simplify x, y translation for column in range(BOARDWIDTH): for row in range(BOARDHEIGHT): self.board[(column, row)] = EMPTY self.board[(3, 3)] = WHITE self.board[(4, 4)] = WHITE self.board[(3, 4)] = BLACK self.board[(4, 3)] = BLACK # black always goes first self.nextMove = BLACK self.buildLegalMoves(self.nextMove) self.gameOver = False def opponentColor(self, color): if color == BLACK: return WHITE else: return BLACK def legalMove(self, column, row, color): """returns the number of pieces flipped if the move is legal otherwise it returns 0""" totalFlipped = 0 if self.board[(column, row)] == EMPTY: opponent = self.opponentColor(color) # to be a legal move # the position must be empty # the position must be adjacent to an opponent # color piece # searching in the direction of the opposing # color piece there must be a position matching # the starting position color # the edges of the board don't count board = self.board for dx, dy in DIRECTIONS: flipped = 0 x = column + dx y = row + dy if board.get((x, y), EMPTY) == opponent: # now check to see if we run into our # own color so we have something to flip # if we run into an empty space or off the board # then it isn't a legal move while board.get((x, y), EMPTY) == opponent: x += dx y += dy flipped += 1 if board.get((x, y), EMPTY) == color: totalFlipped += flipped return totalFlipped def buildLegalMoves(self, color): """build a dictionary of legal moves with the (column, row) as the key and the number of pieces flipped as the value""" self.legalMoves = {} for column, row in self.board.keys(): flipped = self.legalMove(column, row, color) if flipped: self.legalMoves[(column, row)] = flipped def legalMovesAvailable(self, color): self.buildLegalMoves(color) # look at all empty positions on the board to determine # whether any legal moves exist if self.legalMoves == {}: return False else: return True def makeMove(self, column, row, color): self.board[(column, row)] = color # now flip all the pieces opponent = self.opponentColor(color) # to be a legal move # the position must be empty # the position must be adjacent to an opponent # color piece # searching in the direction of the opposing # color piece there must be a position matching # the starting position color # the edges of the board don't count board = self.board for dx, dy in DIRECTIONS: x = column + dx y = row + dy if board.get((x, y), EMPTY) == opponent: flip = [] # now check to see if we run into our # own color so we have something to flip # if we run into an empty space or off the board # then it isn't a legal move while board.get((x, y), EMPTY) == opponent: # add pieces to flip flip.append((x, y)) x += dx y += dy if board.get((x, y), EMPTY) == color: for position in flip: board[position] = color break # change who has the next move # if there are no legal moves left for the opponent # then we check whether there are any legal moves # left for the current player # if neither has a legal move then the game is over if self.legalMovesAvailable(opponent): self.nextMove = opponent elif self.legalMovesAvailable(color): self.nextMove = color else: self.gameOver = True # computer is currently stupid and just # randomly picks from the available legal moves # if you lose then you're Mr. Gumby <wink> # what it should do instead is be able to use # various strategies such as flip the most pieces # favor certain positions like the edges but avoid the # the spots next to the corners (weighted positions) # okay, I added the flip the most pieces strategy # but it is still pretty dumb def doRandomComputerMove(self, color): legalMoves = self.legalMoves.keys() column, row = legalMoves[randint(0, len(legalMoves) - 1)] self.makeMove(column, row, color) def doFlipMostPiecesComputerMove(self, color): flipped = 0 for position in self.legalMoves.keys(): #print " ", position, self.legalMoves[position] if self.legalMoves[position] > flipped: best = position flipped = self.legalMoves[best] #print "picked:", best, self.legalMoves[best], "\n" self.makeMove(best[0], best[1], color) def getScore(self): """return a tuple containing the number of empty, black, and white squares""" score = {BLACK:0, WHITE:0, EMPTY:0} for value in self.board.values(): score[value] += 1 return score class Reversi(model.Background): def on_initialize(self, event): self.boardModel = GameBoard() self.components.bufOff.size = (BOARDWIDTH * CELLWIDTH + 1, BOARDHEIGHT * CELLHEIGHT + 1) self.singleItemExpandingSizerLayout() self.drawBoard() self.updateStatus() self.player = BLACK self.computer = WHITE self.lastHover = None if self.computer == BLACK: self.boardModel.doComputerMove(BLACK) def computerMove(self): if self.menuBar.getChecked('menuStrategyFlipMostPieces'): self.boardModel.doFlipMostPiecesComputerMove(self.computer) else: self.boardModel.doRandomComputerMove(self.computer) # sleep for a second to make it appear # the computer thought long and hard on her choice :) time.sleep(1) self.drawBoard() self.updateStatus() def newGame(self): self.boardModel.initializeBoard() self.drawBoard() self.updateStatus() if self.computer == BLACK: self.computerMove() def drawCell(self, x, y, state): view = self.components.bufOff if state in [BLACK, WHITE]: if state == BLACK: color = 'black' else: color = 'white' view.setFillColor(color) center = (x * CELLWIDTH + CELLWIDTH / 2 + 1, y * CELLHEIGHT + CELLHEIGHT / 2 + 1) view.drawCircle(center, round((CELLWIDTH / 2.0) - 3)) else: view.setFillColor(BOARDCOLOR) view.foregroundColor = BOARDCOLOR view.drawRectangle((x * CELLWIDTH + 1, y * CELLHEIGHT + 1), (CELLWIDTH - 2, CELLHEIGHT - 2)) view.foregroundColor = 'black' def drawBoard(self): view = self.components.bufOff view.autoRefresh = False view.backgroundColor = BOARDCOLOR view.clear() # draw the right and bottom edge borders view.drawLine((0, BOARDHEIGHT * CELLHEIGHT), (BOARDWIDTH * CELLWIDTH, BOARDHEIGHT * CELLHEIGHT)) view.drawLine((BOARDWIDTH * CELLWIDTH, 0), (BOARDWIDTH * CELLWIDTH, BOARDHEIGHT * CELLHEIGHT)) for x in range(BOARDWIDTH): view.drawLine((x * CELLWIDTH, 0), (x * CELLWIDTH, BOARDHEIGHT * CELLHEIGHT)) for y in range(BOARDHEIGHT): view.drawLine((0, y * CELLHEIGHT), (BOARDWIDTH * CELLWIDTH, y * CELLHEIGHT)) state = self.boardModel.board[(x, y)] self.drawCell(x, y, state) view.autoRefresh = True view.refresh() def updateStatus(self): if self.boardModel.gameOver: score = self.boardModel.getScore() playerScore = score[self.player] computerScore = score[self.computer] scoreString = "Black: %d White: %d" % (score[BLACK], score[WHITE]) if playerScore > computerScore: message = "Player won!" elif playerScore < computerScore: message = "Computer won!" else: message = "Tie Game" status = message + " - " + scoreString else: if self.boardModel.nextMove == BLACK: status = "Black's move" else: status = "White's move" self.statusBar.text = status def on_bufOff_mouseMove(self, event): x, y = event.position x = x / CELLWIDTH y = y / CELLHEIGHT #if self.boardModel.legalMove(x, y, self.boardModel.nextMove): if (x, y) != self.lastHover: # erase lastHover if needed if self.lastHover and self.boardModel.board[self.lastHover] is None: self.drawCell(self.lastHover[0], self.lastHover[1], EMPTY) # if the move is legal, show it if self.boardModel.legalMoves.get((x, y), None): self.drawCell(x, y, self.player) # don't track positions outside the valid range if (x >= 0 and x < BOARDWIDTH) and (y >= 0 and y < BOARDHEIGHT): self.lastHover = (x, y) def on_bufOff_mouseUp(self, event): x, y = event.position # this is a simplistic translation # when users click on the lines # separating cells they may get a cell # they didn't expect x = x / CELLWIDTH y = y / CELLHEIGHT if self.boardModel.legalMove(x, y, self.boardModel.nextMove): self.boardModel.makeMove(x, y, self.boardModel.nextMove) self.drawBoard() self.updateStatus() if not self.boardModel.gameOver: if self.boardModel.nextMove == self.computer: self.computerMove() event.skip() def on_menuFileNewGame_select(self, event): self.newGame() if __name__ == '__main__': app = model.Application(Reversi) app.MainLoop() |
From: Kevin A. <ka...@us...> - 2004-05-02 02:40:51
|
Update of /cvsroot/pythoncard/PythonCard/docs In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24236/docs Modified Files: changelog.txt Log Message: added reversi (Othello) sample Index: changelog.txt =================================================================== RCS file: /cvsroot/pythoncard/PythonCard/docs/changelog.txt,v retrieving revision 1.279 retrieving revision 1.280 diff -C2 -d -r1.279 -r1.280 *** changelog.txt 1 May 2004 17:05:29 -0000 1.279 --- changelog.txt 2 May 2004 02:40:43 -0000 1.280 *************** *** 3,6 **** --- 3,7 ---- Release 0.8 2004-05-?? + added reversi (Othello) sample made spirographInteractive its own sample added restore (inverse of minimize) background window event |
From: Kevin A. <ka...@us...> - 2004-05-02 02:40:51
|
Update of /cvsroot/pythoncard/PythonCard/samples In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24236/samples Modified Files: samples.rsrc.py Log Message: added reversi (Othello) sample Index: samples.rsrc.py =================================================================== RCS file: /cvsroot/pythoncard/PythonCard/samples/samples.rsrc.py,v retrieving revision 1.55 retrieving revision 1.56 diff -C2 -d -r1.55 -r1.56 *** samples.rsrc.py 1 May 2004 17:05:30 -0000 1.55 --- samples.rsrc.py 2 May 2004 02:40:43 -0000 1.56 *************** *** 60,64 **** 'hopalong', 'jabberChat', 'life', 'minimal', 'minimalList', 'minimalTree', \ 'moderator', 'montyhall', 'multicolumnexample', 'noresource', \ ! 'pictureViewer', 'proof', 'pysshed', 'radioclient', 'redemo', 'rpn', \ 'samples', 'saveClipboardBitmap', 'searchexplorer', \ 'simpleBrowser', 'simpleIEBrowser', 'slideshow', 'sounds', 'SourceForgeTracker', \ --- 60,64 ---- 'hopalong', 'jabberChat', 'life', 'minimal', 'minimalList', 'minimalTree', \ 'moderator', 'montyhall', 'multicolumnexample', 'noresource', \ ! 'pictureViewer', 'proof', 'pysshed', 'radioclient', 'redemo', 'reversi', 'rpn', \ 'samples', 'saveClipboardBitmap', 'searchexplorer', \ 'simpleBrowser', 'simpleIEBrowser', 'slideshow', 'sounds', 'SourceForgeTracker', \ |
From: Kevin A. <ka...@us...> - 2004-05-02 02:39:01
|
Update of /cvsroot/pythoncard/PythonCard/samples/reversi In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23994/reversi Log Message: Directory /cvsroot/pythoncard/PythonCard/samples/reversi added to the repository |
From: Kevin A. <ka...@us...> - 2004-05-01 19:10:42
|
Update of /cvsroot/pythoncard/PythonCard In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8860 Modified Files: fixdc.py Log Message: updated to the latest version Index: fixdc.py =================================================================== RCS file: /cvsroot/pythoncard/PythonCard/fixdc.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** fixdc.py 1 May 2004 16:26:00 -0000 1.1 --- fixdc.py 1 May 2004 19:10:30 -0000 1.2 *************** *** 1,39 **** """ This module will do surgery on the wx.DC class in wxPython 2.5.1.5 to ! make it act like the wx.DC class in later versions will. In a ! nutshell, the old 2.4.x style of method names, where the 'normal' name ! takes separate parameters for x, y, width and height will be restored, ! and the new methods that take wx.Point and/or wx.Size (which can also ! be converted from 2-element sequences) will be given new non-default ! method names. The new names are: ! * FloodFillPoint ! * GetPixelPoint ! * DrawLinePoint * CrossHairPoint * DrawArcPoint * DrawCheckMarkRect * DrawEllipticArcPointSize * DrawPointPoint * DrawRectanglePointSize * DrawRoundedRectanglePointSize - * DrawCirclePoint - * DrawEllipsePointSize - * DrawIconPoint - * DrawBitmapPoint * DrawTextPoint ! * DrawRotatedTextPoint ! * BlitPointSize ! WARNING: If you import this module the the wx.DC class will be changed ! for the entire application, so if you use code from the ! wx.lib package or 3rd party modules that have already been ! converted to the doomed 2.5.1.5 implementaion of the DC Draw ! methods then that code will break. This is an all-or-nothing ! fix, (just like the next version of wxPython will be,) so you ! *will* need to do something to resolve this situation if you ! run into it. The best thing to do of course is to correct ! the library module to work with the corrected DC semantics and ! then send me a patch. --Robin --- 1,65 ---- """ This module will do surgery on the wx.DC class in wxPython 2.5.1.5 to ! make it act like the wx.DC class in later versions will. To use this ! module simply import it in one of your program's modules before you ! use any DC's. It does its work upon import and then is done. ! So what does it do? In a nutshell, the old 2.4.x style of method ! names, where the 'normal' name takes separate parameters for x, y, ! width and height will be restored, and the new methods that take ! wx.Point and/or wx.Size (which can also be converted from 2-element ! sequences) will be given new non-default method names. The 2.5.1.5 ! 'XY' style names will be removed. The new names for the 'Point/Size' ! methods are: ! ! * BlitPointSize * CrossHairPoint * DrawArcPoint + * DrawBitmapPoint * DrawCheckMarkRect + * DrawCirclePoint + * DrawEllipsePointSize * DrawEllipticArcPointSize + * DrawIconPoint + * DrawLinePoint * DrawPointPoint * DrawRectanglePointSize + * DrawRotatedTextPoint * DrawRoundedRectanglePointSize * DrawTextPoint ! * FloodFillPoint ! * GetPixelPoint ! * SetClippingRegionPointSize ! Please note that only the names that you access the methods by will be ! changed. The names used in docstrings as well as the names used to ! call the extenaion functions and the names used when raising ! exceptions will still use the old names. (Of course once a new ! version of wxPython has been built with this new style then this will ! no longer apply. The new names will be the real names.) For ! example:: ! ! Traceback (most recent call last): ! File "/usr/lib/python2.3/site-packages/wx/lib/buttons.py", line 272, in OnPaint ! self.DrawBezel(dc, x1, y1, x2, y2) ! File "/usr/lib/python2.3/site-packages/wx/lib/buttons.py", line 220, in DrawBezel ! dc.DrawLine((x1+i, y1), (x1+i, y2-i)) ! File "/usr/lib/python2.3/site-packages/wx/gdi.py", line 2293, in DrawLine ! return _gdi.DC_DrawLineXY(*args, **kwargs) ! TypeError: DC_DrawLineXY() takes exactly 5 arguments (3 given) ! ! ! WARNING: If you import this module then the wx.DC class will be ! changed for the entire application, so if you use code from ! the wx.lib package (or 3rd party modules that have already ! been converted to the doomed 2.5.1.5 implementaion of the DC ! Draw methods) then that code will break as shown above. This ! is an all-or-nothing fix, (just like the next version of ! wxPython will be,) so you *will* need to do something to ! resolve this situation if you run into it. The best thing to ! do of course is to correct the library module to work with ! the corrected DC semantics and then send me a patch, although ! it probably won't be too long before the library modules are ! updated in CVS so you could get a copy of them there. --Robin *************** *** 43,65 **** _names = [ ! ("FloodFillXY", "FloodFill", "FloodFillPoint"), ! ("GetPixelXY", "GetPixel", "GetPixelPoint"), ! ("DrawLineXY", "DrawLine", "DrawLinePoint"), ("CrossHairXY", "CrossHair", "CrossHairPoint"), ("DrawArcXY", "DrawArc", "DrawArcPoint"), ("DrawCheckMarkXY", "DrawCheckMark", "DrawCheckMarkRect"), ("DrawEllipticArcXY", "DrawEllipticArc", "DrawEllipticArcPointSize"), ("DrawPointXY", "DrawPoint", "DrawPointPoint"), ("DrawRectangleXY", "DrawRectangle", "DrawRectanglePointSize"), ("DrawRoundedRectangleXY", "DrawRoundedRectangle", "DrawRoundedRectanglePointSize"), - ("DrawCircleXY", "DrawCircle", "DrawCirclePoint"), - ("DrawEllipseXY", "DrawEllipse", "DrawEllipsePointSize"), - ("DrawIconXY", "DrawIcon", "DrawIconPoint"), - ("DrawBitmapXY", "DrawBitmap", "DrawBitmapPoint"), ("DrawTextXY", "DrawText", "DrawTextPoint"), ! ("DrawRotatedTextXY", "DrawRotatedText", "DrawRotatedTextPoint"), ! ("BlitXY", "Blit", "BlitPointSize"), ] if wx.VERSION[:4] == (2,5,1,5): cls = wx.DC --- 69,114 ---- _names = [ ! ("BlitXY", "Blit", "BlitPointSize"), ("CrossHairXY", "CrossHair", "CrossHairPoint"), ("DrawArcXY", "DrawArc", "DrawArcPoint"), + ("DrawBitmapXY", "DrawBitmap", "DrawBitmapPoint"), ("DrawCheckMarkXY", "DrawCheckMark", "DrawCheckMarkRect"), + ("DrawCircleXY", "DrawCircle", "DrawCirclePoint"), + ("DrawEllipseXY", "DrawEllipse", "DrawEllipsePointSize"), ("DrawEllipticArcXY", "DrawEllipticArc", "DrawEllipticArcPointSize"), + ("DrawIconXY", "DrawIcon", "DrawIconPoint"), + ("DrawLineXY", "DrawLine", "DrawLinePoint"), ("DrawPointXY", "DrawPoint", "DrawPointPoint"), ("DrawRectangleXY", "DrawRectangle", "DrawRectanglePointSize"), + ("DrawRotatedTextXY", "DrawRotatedText", "DrawRotatedTextPoint"), ("DrawRoundedRectangleXY", "DrawRoundedRectangle", "DrawRoundedRectanglePointSize"), ("DrawTextXY", "DrawText", "DrawTextPoint"), ! ("FloodFillXY", "FloodFill", "FloodFillPoint"), ! ("GetPixelXY", "GetPixel", "GetPixelPoint"), ! ("SetClippingRegionXY", "SetClippingRegion", "SetClippingRegionPointSize"), ] + + # this is a bit of handy code from the Python Cookbook + def _renamefunction(function, name): + """ + This function returns a function identical to the given one, but + with the given name. + """ + from types import FunctionType, CodeType + + c = function.func_code + if c.co_name != name: + # rename the code object. + c = CodeType(c.co_argcount, c.co_nlocals, c.co_stacksize, + c.co_flags, c.co_code, c.co_consts, + c.co_names, c.co_varnames, c.co_filename, + name, c.co_firstlineno, c.co_lnotab) + if function.func_defaults != None: + return FunctionType(c, function.func_globals, name, + function.func_defaults) + return FunctionType(c, function.func_globals, name) + + if wx.VERSION[:4] == (2,5,1,5): cls = wx.DC *************** *** 67,72 **** m_old = getattr(cls, old) m_norm = getattr(cls, norm) ! setattr(cls, new, m_norm) ! setattr(cls, norm, m_old) delattr(cls, old) --- 116,121 ---- m_old = getattr(cls, old) m_norm = getattr(cls, norm) ! setattr(cls, new, _renamefunction(m_norm, new)) ! setattr(cls, norm, _renamefunction(m_old, norm)) delattr(cls, old) *************** *** 75,77 **** - --- 124,125 ---- |
From: Rowland S. <mon...@us...> - 2004-05-01 18:47:59
|
Update of /cvsroot/pythoncard/PythonCard/components In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4329/components Modified Files: codeeditor.py button.py calendar.py list.py combobox.py choice.py tree.py slider.py multicolumnlist.py radiogroup.py spinner.py textfield.py checkbox.py iehtmlwindow.py Log Message: Made the event.EventSource interface public and changed all references to EventSource methods. Index: spinner.py =================================================================== RCS file: /cvsroot/pythoncard/PythonCard/components/spinner.py,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** spinner.py 21 Apr 2004 03:45:00 -0000 1.14 --- spinner.py 1 May 2004 18:47:48 -0000 1.15 *************** *** 147,151 **** if evt is not None : ! self._component._notifyEventListeners(evt) #if not evt.getUsed(): # aWxEvent.Skip() --- 147,151 ---- if evt is not None : ! self._component.notifyEventListeners(evt) #if not evt.getUsed(): # aWxEvent.Skip() Index: slider.py =================================================================== RCS file: /cvsroot/pythoncard/PythonCard/components/slider.py,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** slider.py 21 Apr 2004 03:45:00 -0000 1.16 --- slider.py 1 May 2004 18:47:48 -0000 1.17 *************** *** 123,127 **** if evt is not None : ! self._component._notifyEventListeners( evt ) --- 123,127 ---- if evt is not None : ! self._component.notifyEventListeners( evt ) Index: checkbox.py =================================================================== RCS file: /cvsroot/pythoncard/PythonCard/components/checkbox.py,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** checkbox.py 21 Apr 2004 03:45:00 -0000 1.16 --- checkbox.py 1 May 2004 18:47:49 -0000 1.17 *************** *** 73,77 **** if evt is not None : ! self._component._notifyEventListeners( evt ) --- 73,77 ---- if evt is not None : ! self._component.notifyEventListeners( evt ) Index: button.py =================================================================== RCS file: /cvsroot/pythoncard/PythonCard/components/button.py,v retrieving revision 1.27 retrieving revision 1.28 diff -C2 -d -r1.27 -r1.28 *** button.py 1 May 2004 18:11:24 -0000 1.27 --- button.py 1 May 2004 18:47:48 -0000 1.28 *************** *** 365,369 **** if evt is not None: ! component._notifyEventListeners(evt) --- 365,369 ---- if evt is not None: ! component.notifyEventListeners(evt) Index: iehtmlwindow.py =================================================================== RCS file: /cvsroot/pythoncard/PythonCard/components/iehtmlwindow.py,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** iehtmlwindow.py 21 Apr 2004 16:34:31 -0000 1.13 --- iehtmlwindow.py 1 May 2004 18:47:49 -0000 1.14 *************** *** 109,113 **** if evt is not None: ! component._notifyEventListeners(evt) --- 109,113 ---- if evt is not None: ! component.notifyEventListeners(evt) Index: tree.py =================================================================== RCS file: /cvsroot/pythoncard/PythonCard/components/tree.py,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** tree.py 21 Apr 2004 03:45:01 -0000 1.12 --- tree.py 1 May 2004 18:47:48 -0000 1.13 *************** *** 102,106 **** if evt is not None : ! self._component._notifyEventListeners(evt) --- 102,106 ---- if evt is not None : ! self._component.notifyEventListeners(evt) Index: textfield.py =================================================================== RCS file: /cvsroot/pythoncard/PythonCard/components/textfield.py,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -d -r1.25 -r1.26 *** textfield.py 1 May 2004 18:11:25 -0000 1.25 --- textfield.py 1 May 2004 18:47:48 -0000 1.26 *************** *** 596,600 **** # event = self._createEvent( TextEnterEvent, aWxEvent ) # this should be associated with losing focus, not textEnter ! #self._component._notifyEventListeners( CloseField( self._component ) ) if aWxEvent.GetEventType() == wx.wxEVT_KEY_DOWN : --- 596,600 ---- # event = self._createEvent( TextEnterEvent, aWxEvent ) # this should be associated with losing focus, not textEnter ! #self._component.notifyEventListeners( CloseField( self._component ) ) if aWxEvent.GetEventType() == wx.wxEVT_KEY_DOWN : *************** *** 615,619 **** if evt is not None : #print '_dispatch evt is not None' ! self._component._notifyEventListeners( evt ) #print "after notify" --- 615,619 ---- if evt is not None : #print '_dispatch evt is not None' ! self._component.notifyEventListeners( evt ) #print "after notify" Index: codeeditor.py =================================================================== RCS file: /cvsroot/pythoncard/PythonCard/components/codeeditor.py,v retrieving revision 1.33 retrieving revision 1.34 diff -C2 -d -r1.33 -r1.34 *** codeeditor.py 25 Apr 2004 15:23:44 -0000 1.33 --- codeeditor.py 1 May 2004 18:47:48 -0000 1.34 *************** *** 416,420 **** # event = self._createEvent( TextEnterEvent, aWxEvent ) # this should be associated with losing focus, not textEnter ! #self._component._notifyEventListeners( CloseField( self._component ) ) if aWxEvent.GetEventType() == wx.wxEVT_KEY_DOWN : --- 416,420 ---- # event = self._createEvent( TextEnterEvent, aWxEvent ) # this should be associated with losing focus, not textEnter ! #self._component.notifyEventListeners( CloseField( self._component ) ) if aWxEvent.GetEventType() == wx.wxEVT_KEY_DOWN : *************** *** 435,439 **** if evt is not None : #print '_dispatch evt is not None' ! self._component._notifyEventListeners( evt ) #print "after notify" --- 435,439 ---- if evt is not None : #print '_dispatch evt is not None' ! self._component.notifyEventListeners( evt ) #print "after notify" Index: radiogroup.py =================================================================== RCS file: /cvsroot/pythoncard/PythonCard/components/radiogroup.py,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -d -r1.22 -r1.23 *** radiogroup.py 24 Apr 2004 05:34:15 -0000 1.22 --- radiogroup.py 1 May 2004 18:47:48 -0000 1.23 *************** *** 118,122 **** if evt is not None : ! self._component._notifyEventListeners( evt ) --- 118,122 ---- if evt is not None : ! self._component.notifyEventListeners( evt ) Index: list.py =================================================================== RCS file: /cvsroot/pythoncard/PythonCard/components/list.py,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -d -r1.22 -r1.23 *** list.py 24 Apr 2004 06:49:46 -0000 1.22 --- list.py 1 May 2004 18:47:48 -0000 1.23 *************** *** 160,164 **** if evt is not None : ! self._component._notifyEventListeners( evt ) --- 160,164 ---- if evt is not None : ! self._component.notifyEventListeners( evt ) Index: multicolumnlist.py =================================================================== RCS file: /cvsroot/pythoncard/PythonCard/components/multicolumnlist.py,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -d -r1.23 -r1.24 *** multicolumnlist.py 21 Apr 2004 03:45:00 -0000 1.23 --- multicolumnlist.py 1 May 2004 18:47:48 -0000 1.24 *************** *** 533,537 **** if evt is not None: ! self._component._notifyEventListeners(evt) --- 533,537 ---- if evt is not None: ! self._component.notifyEventListeners(evt) Index: combobox.py =================================================================== RCS file: /cvsroot/pythoncard/PythonCard/components/combobox.py,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -d -r1.24 -r1.25 *** combobox.py 25 Apr 2004 06:26:49 -0000 1.24 --- combobox.py 1 May 2004 18:47:48 -0000 1.25 *************** *** 82,86 **** if wx.Platform == '__WXMAC__': def _setStringSelection(self, s): self.SetSelection(self.FindString(s)) ! stringSelection = property(ContainerMixin._getStringSelection, _setStringSelection) --- 82,86 ---- if wx.Platform == '__WXMAC__': def _setStringSelection(self, s): self.SetSelection(self.FindString(s)) ! stringSelection = property(ContainerMixin._getStringSelection, _setStringSelection) *************** *** 130,134 **** if evt is not None : ! self._component._notifyEventListeners( evt ) if not evt.getUsed(): aWxEvent.Skip() --- 130,134 ---- if evt is not None : ! self._component.notifyEventListeners( evt ) if not evt.getUsed(): aWxEvent.Skip() Index: calendar.py =================================================================== RCS file: /cvsroot/pythoncard/PythonCard/components/calendar.py,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** calendar.py 21 Apr 2004 03:45:00 -0000 1.16 --- calendar.py 1 May 2004 18:47:48 -0000 1.17 *************** *** 100,104 **** if evt is not None: ! component._notifyEventListeners(evt) --- 100,104 ---- if evt is not None: ! component.notifyEventListeners(evt) Index: choice.py =================================================================== RCS file: /cvsroot/pythoncard/PythonCard/components/choice.py,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** choice.py 22 Apr 2004 16:42:36 -0000 1.17 --- choice.py 1 May 2004 18:47:48 -0000 1.18 *************** *** 88,92 **** if evt is not None : ! self._component._notifyEventListeners( evt ) import sys --- 88,92 ---- if evt is not None : ! self._component.notifyEventListeners( evt ) import sys |
From: Rowland S. <mon...@us...> - 2004-05-01 18:47:58
|
Update of /cvsroot/pythoncard/PythonCard In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4329 Modified Files: menu.py debug.py event.py Log Message: Made the event.EventSource interface public and changed all references to EventSource methods. Index: debug.py =================================================================== RCS file: /cvsroot/pythoncard/PythonCard/debug.py,v retrieving revision 1.126 retrieving revision 1.127 diff -C2 -d -r1.126 -r1.127 *** debug.py 1 May 2004 18:11:23 -0000 1.126 --- debug.py 1 May 2004 18:47:50 -0000 1.127 *************** *** 124,132 **** event.EventQueue().addListener( self ) ! event.EventLog.getInstance().addListener( self ) def eventOccurred(self, eventAdapter): if isinstance(eventAdapter, tuple): ! # new way hack to stay compatible with one arg _notifyEventListeners eventName, sourceName, used = eventAdapter if eventName == event.IdleEvent.name: --- 124,132 ---- event.EventQueue().addListener( self ) ! event.EventLog.getInstance().addEventListener( self ) def eventOccurred(self, eventAdapter): if isinstance(eventAdapter, tuple): ! # new way hack to stay compatible with one arg notifyEventListeners eventName, sourceName, used = eventAdapter if eventName == event.IdleEvent.name: Index: event.py =================================================================== RCS file: /cvsroot/pythoncard/PythonCard/event.py,v retrieving revision 1.60 retrieving revision 1.61 diff -C2 -d -r1.60 -r1.61 *** event.py 1 May 2004 18:11:24 -0000 1.60 --- event.py 1 May 2004 18:47:50 -0000 1.61 *************** *** 257,261 **** self._listeners = [] ! def _addEventListener(self, listener): """ Add an EventListener as an observer of this object. --- 257,261 ---- self._listeners = [] ! def addEventListener(self, listener): """ Add an EventListener as an observer of this object. *************** *** 268,275 **** # KEA 2004-04-24 # need this to disconnect the Message Watcher ! def _removeEventListener(self, listener): self._listeners.remove(listener) ! def _notifyEventListeners( self, event ) : """ Notify all of our EventListeners that an event has occured. --- 268,275 ---- # KEA 2004-04-24 # need this to disconnect the Message Watcher ! def removeEventListener(self, listener): self._listeners.remove(listener) ! def notifyEventListeners( self, event ) : """ Notify all of our EventListeners that an event has occured. *************** *** 646,654 **** Broadcast the event to all listeners. """ ! self._notifyEventListeners( ( eventName, sourceName, used ) ) ! ! def addListener( self, aEventListener ) : ! self._addEventListener( aEventListener ) ! class EventQueue : --- 646,651 ---- Broadcast the event to all listeners. """ ! self.notifyEventListeners( ( eventName, sourceName, used ) ) ! class EventQueue : *************** *** 667,674 **** def eventOccurred( self, aEvent ) : ! self._notifyEventListeners( aEvent ) def eventOccurred2(self, eventName, sourceName, used): ! self._notifyEventListeners((eventName, sourceName, used)) def __init__( self ) : --- 664,671 ---- def eventOccurred( self, aEvent ) : ! self.notifyEventListeners( aEvent ) def eventOccurred2(self, eventName, sourceName, used): ! self.notifyEventListeners((eventName, sourceName, used)) def __init__( self ) : *************** *** 677,689 **** def listenTo( self, aEventSource ) : ! aEventSource._addEventListener(self._impl) def addListener( self, aEventListener ) : ! self._impl._addEventListener(aEventListener) # KEA 2004-04-24 # need this to disconnect the Message Watcher def removeListener(self, aEventListener): ! self._impl._removeEventListener(aEventListener) --- 674,686 ---- def listenTo( self, aEventSource ) : ! aEventSource.addEventListener(self._impl) def addListener( self, aEventListener ) : ! self._impl.addEventListener(aEventListener) # KEA 2004-04-24 # need this to disconnect the Message Watcher def removeListener(self, aEventListener): ! self._impl.removeEventListener(aEventListener) *************** *** 732,736 **** EventSource.__init__(self) self._scriptable = aScriptable ! aEventSource._addEventListener(self) EventQueue().listenTo(self) --- 729,733 ---- EventSource.__init__(self) self._scriptable = aScriptable ! aEventSource.addEventListener(self) EventQueue().listenTo(self) *************** *** 786,790 **** # indicating whether the Event was used or not. adapter = EventAdapter(self, aEvent, used) ! self._notifyEventListeners(adapter) # KEA 2004-04-26 # remove reference to event after notifying the listeners --- 783,787 ---- # indicating whether the Event was used or not. adapter = EventAdapter(self, aEvent, used) ! self.notifyEventListeners(adapter) # KEA 2004-04-26 # remove reference to event after notifying the listeners *************** *** 987,991 **** evt = MouseDragEvent(self._component) evt._nativeEvent = aWxEvent ! self._component._notifyEventListeners(evt) aWxEvent.Skip() --- 984,988 ---- evt = MouseDragEvent(self._component) evt._nativeEvent = aWxEvent ! self._component.notifyEventListeners(evt) aWxEvent.Skip() Index: menu.py =================================================================== RCS file: /cvsroot/pythoncard/PythonCard/menu.py,v retrieving revision 1.30 retrieving revision 1.31 diff -C2 -d -r1.30 -r1.31 *** menu.py 18 Apr 2004 00:34:50 -0000 1.30 --- menu.py 1 May 2004 18:47:50 -0000 1.31 *************** *** 233,237 **** # added missing setNativeEvent evt.setNativeEvent(aWxMenuEvent) ! item._notifyEventListeners(evt) ## def parseMenus(self, aParent, aResource): --- 233,237 ---- # added missing setNativeEvent evt.setNativeEvent(aWxMenuEvent) ! item.notifyEventListeners(evt) ## def parseMenus(self, aParent, aResource): |
From: Rowland S. <mon...@us...> - 2004-05-01 18:47:20
|
Update of /cvsroot/pythoncard/PythonCard/tools/resourceEditor In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4148a/tools/resourceEditor Modified Files: resourceEditor.py Log Message: Changed .DrawRectangle to .DrawRectanglePointSize. Index: resourceEditor.py =================================================================== RCS file: /cvsroot/pythoncard/PythonCard/tools/resourceEditor/resourceEditor.py,v retrieving revision 1.188 retrieving revision 1.189 diff -C2 -d -r1.188 -r1.189 *** resourceEditor.py 30 Apr 2004 16:26:12 -0000 1.188 --- resourceEditor.py 1 May 2004 18:46:55 -0000 1.189 *************** *** 343,347 **** ##print "drawTheRect", rect ##dc.DrawRectangle(rect[0], rect[1], rect[2], rect[3]) ! self.dc.DrawRectangle((position[0], position[1]), (self.startSize[0], self.startSize[1])) ##self.rect = rect self.lastPosition = position --- 343,347 ---- ##print "drawTheRect", rect ##dc.DrawRectangle(rect[0], rect[1], rect[2], rect[3]) ! self.dc.DrawRectanglePointSize((position[0], position[1]), (self.startSize[0], self.startSize[1])) ##self.rect = rect self.lastPosition = position *************** *** 453,457 **** # erase the last rect ! self.dc.DrawRectangle((self.lastPosition[0], self.lastPosition[1]), (self.startSize[0], self.startSize[1])) # use the global mouse position and the initial offset and start --- 453,457 ---- # erase the last rect ! self.dc.DrawRectanglePointSize((self.lastPosition[0], self.lastPosition[1]), (self.startSize[0], self.startSize[1])) # use the global mouse position and the initial offset and start *************** *** 465,469 **** self.lastPosition[0] = xOffset self.lastPosition[1] = yOffset ! self.dc.DrawRectangle((self.lastPosition[0], self.lastPosition[1]), (self.startSize[0], self.startSize[1])) --- 465,469 ---- self.lastPosition[0] = xOffset self.lastPosition[1] = yOffset ! self.dc.DrawRectanglePointSize((self.lastPosition[0], self.lastPosition[1]), (self.startSize[0], self.startSize[1])) *************** *** 478,482 **** if self.startName in self.components: if self.movingComponent: ! self.dc.DrawRectangle((self.lastPosition[0], self.lastPosition[1]), (self.startSize[0], self.startSize[1])) self.components[self.startName].position = (self.lastPosition[0], self.lastPosition[1]) --- 478,482 ---- if self.startName in self.components: if self.movingComponent: ! self.dc.DrawRectanglePointSize((self.lastPosition[0], self.lastPosition[1]), (self.startSize[0], self.startSize[1])) self.components[self.startName].position = (self.lastPosition[0], self.lastPosition[1]) |
From: Kevin A. <ka...@us...> - 2004-05-01 18:11:36
|
Update of /cvsroot/pythoncard/PythonCard In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29784 Modified Files: debug.py event.py model.py Log Message: switched to EventLog for logging events Index: debug.py =================================================================== RCS file: /cvsroot/pythoncard/PythonCard/debug.py,v retrieving revision 1.125 retrieving revision 1.126 diff -C2 -d -r1.125 -r1.126 *** debug.py 29 Apr 2004 23:59:23 -0000 1.125 --- debug.py 1 May 2004 18:11:23 -0000 1.126 *************** *** 124,127 **** --- 124,128 ---- event.EventQueue().addListener( self ) + event.EventLog.getInstance().addListener( self ) def eventOccurred(self, eventAdapter): Index: model.py =================================================================== RCS file: /cvsroot/pythoncard/PythonCard/model.py,v retrieving revision 1.162 retrieving revision 1.163 diff -C2 -d -r1.162 -r1.163 *** model.py 1 May 2004 16:26:00 -0000 1.162 --- model.py 1 May 2004 18:11:24 -0000 1.163 *************** *** 600,606 **** wx.PostEvent(self, wxLatentBackgroundBindEvent()) # for some reason the Message Watcher isn't a listener yet ! # so calling eventOccurred2 doesn't do anything #print event.EventQueue()._impl._listeners ! #event.EventQueue()._impl.eventOccurred2('initialize', self.name) self._bindWindowEvents() --- 600,606 ---- wx.PostEvent(self, wxLatentBackgroundBindEvent()) # for some reason the Message Watcher isn't a listener yet ! # so calling EventLog doesn't do anything #print event.EventQueue()._impl._listeners ! #event.EventLog.getInstance().log('initialize', self.name, True) self._bindWindowEvents() *************** *** 761,765 **** # and will cause Python to crash. try: ! event.EventQueue().removeListener(self.stack.app.mw) except: # already removed Message Watcher or it is not in use --- 761,765 ---- # and will cause Python to crash. try: ! event.EventLog.getInstance().removeListener(self.stack.app.mw) except: # already removed Message Watcher or it is not in use *************** *** 770,774 **** handler = self.eventIdToHandler.get(eventType, None) if handler: ! event.EventQueue()._impl.eventOccurred2(eventName, self.name, True) if 0: print "dispatching", handler._name --- 770,774 ---- handler = self.eventIdToHandler.get(eventType, None) if handler: ! event.EventLog.getInstance().log(eventName, self.name, True) if 0: print "dispatching", handler._name *************** *** 788,792 **** self._exiting = True else: ! event.EventQueue()._impl.eventOccurred2(eventName, self.name, False) # hopefully this is all we need to do for "unused events" aWxEvent.Skip() --- 788,792 ---- self._exiting = True else: ! event.EventLog.getInstance().log(eventName, self.name, False) # hopefully this is all we need to do for "unused events" aWxEvent.Skip() Index: event.py =================================================================== RCS file: /cvsroot/pythoncard/PythonCard/event.py,v retrieving revision 1.59 retrieving revision 1.60 diff -C2 -d -r1.59 -r1.60 *** event.py 1 May 2004 17:51:18 -0000 1.59 --- event.py 1 May 2004 18:11:24 -0000 1.60 *************** *** 6,9 **** --- 6,10 ---- import error import log + import singleton import sys, types import wx *************** *** 632,636 **** id = wxEVT_CLOSE_FIELD ! class EventLog( Singleton, EventSource ) : """ All events are reported to the EventLog. Any interested --- 633,637 ---- id = wxEVT_CLOSE_FIELD ! class EventLog( singleton.Singleton, EventSource ) : """ All events are reported to the EventLog. Any interested *************** *** 638,641 **** --- 639,643 ---- """ def __init__( self ) : + singleton.Singleton.__init__( self ) EventSource.__init__( self ) *************** *** 646,649 **** --- 648,654 ---- self._notifyEventListeners( ( eventName, sourceName, used ) ) + def addListener( self, aEventListener ) : + self._addEventListener( aEventListener ) + class EventQueue : |
From: Kevin A. <ka...@us...> - 2004-05-01 18:11:35
|
Update of /cvsroot/pythoncard/PythonCard/components In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29784/components Modified Files: button.py textfield.py Log Message: switched to EventLog for logging events Index: textfield.py =================================================================== RCS file: /cvsroot/pythoncard/PythonCard/components/textfield.py,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -d -r1.24 -r1.25 *** textfield.py 1 May 2004 06:13:34 -0000 1.24 --- textfield.py 1 May 2004 18:11:25 -0000 1.25 *************** *** 481,485 **** handler = self.eventIdToHandler.get(eventType, None) if handler: ! event.EventQueue()._impl.eventOccurred2(eventName, self.name, True) if 0: print "dispatching", handler._name --- 481,485 ---- handler = self.eventIdToHandler.get(eventType, None) if handler: ! event.EventLog.getInstance().log(eventName, self.name, True) if 0: print "dispatching", handler._name *************** *** 501,505 **** background = None else: ! event.EventQueue()._impl.eventOccurred2(eventName, self.name, False) # hopefully this is all we need to do for "unused events" aWxEvent.Skip() --- 501,505 ---- background = None else: ! event.EventLog.getInstance().log(eventName, self.name, False) # hopefully this is all we need to do for "unused events" aWxEvent.Skip() Index: button.py =================================================================== RCS file: /cvsroot/pythoncard/PythonCard/components/button.py,v retrieving revision 1.26 retrieving revision 1.27 diff -C2 -d -r1.26 -r1.27 *** button.py 30 Apr 2004 23:55:49 -0000 1.26 --- button.py 1 May 2004 18:11:24 -0000 1.27 *************** *** 274,278 **** handler = self.eventIdToHandler.get(eventType, None) if handler: ! event.EventQueue()._impl.eventOccurred2(eventName, self.name, True) if 0: print "dispatching", handler._name --- 274,278 ---- handler = self.eventIdToHandler.get(eventType, None) if handler: ! event.EventLog.getInstance().log(eventName, self.name, True) if 0: print "dispatching", handler._name *************** *** 294,298 **** background = None else: ! event.EventQueue()._impl.eventOccurred2(eventName, self.name, False) # hopefully this is all we need to do for "unused events" aWxEvent.Skip() --- 294,298 ---- background = None else: ! event.EventLog.getInstance().log(eventName, self.name, False) # hopefully this is all we need to do for "unused events" aWxEvent.Skip() |
From: Rowland S. <mon...@us...> - 2004-05-01 17:51:26
|
Update of /cvsroot/pythoncard/PythonCard In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25980 Modified Files: event.py Log Message: Added event.EventLog, a Singleton for logging events that have fired in the system, and provides a listener interface for interested parties to be notified when events have occurred. MessageWatcher will be a client. Index: event.py =================================================================== RCS file: /cvsroot/pythoncard/PythonCard/event.py,v retrieving revision 1.58 retrieving revision 1.59 diff -C2 -d -r1.58 -r1.59 *** event.py 1 May 2004 06:13:34 -0000 1.58 --- event.py 1 May 2004 17:51:18 -0000 1.59 *************** *** 632,635 **** --- 632,648 ---- id = wxEVT_CLOSE_FIELD + class EventLog( Singleton, EventSource ) : + """ + All events are reported to the EventLog. Any interested + parties may register as listeners. + """ + def __init__( self ) : + EventSource.__init__( self ) + + def log( self, eventName, sourceName, used ) : + """ + Broadcast the event to all listeners. + """ + self._notifyEventListeners( ( eventName, sourceName, used ) ) |
From: Kevin A. <ka...@us...> - 2004-05-01 17:29:21
|
Update of /cvsroot/pythoncard/PythonCard In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20957 Modified Files: turtle.py Log Message: general cleanup, switched to True/False; round() before drawPoint/drawLine Index: turtle.py =================================================================== RCS file: /cvsroot/pythoncard/PythonCard/turtle.py,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** turtle.py 21 Apr 2004 07:33:09 -0000 1.14 --- turtle.py 1 May 2004 17:29:13 -0000 1.15 *************** *** 15,19 **** def __init__(self): """ this should be called after a subclass has done its init """ ! self._tracing = 0 self._degrees() --- 15,19 ---- def __init__(self): """ this should be called after a subclass has done its init """ ! self._tracing = False self._degrees() *************** *** 201,205 **** if not self._visible: self._drawTurtle() ! self._visible = 1 def hideTurtle(self): --- 201,205 ---- if not self._visible: self._drawTurtle() ! self._visible = True def hideTurtle(self): *************** *** 209,213 **** if self._dirty: self._drawTurtle() ! self._visible = 0 def _drawTurtle(self): --- 209,213 ---- if self._dirty: self._drawTurtle() ! self._visible = False def _drawTurtle(self): *************** *** 217,225 **** def suspendOdometer(self): """suspends the turtle odometer""" ! self._odometerOn = 0 def resumeOdometer(self): """resumes the turtle odometer""" ! self._odometerOn = 1 def getOdometer(self): --- 217,225 ---- def suspendOdometer(self): """suspends the turtle odometer""" ! self._odometerOn = False def resumeOdometer(self): """resumes the turtle odometer""" ! self._odometerOn = True def getOdometer(self): *************** *** 234,242 **** """raises the turtle pen, so no drawing will occur on subsequent commands until the pen is lowered with penDown""" ! self._drawing = 0 def penDown(self): """lowers the turtle pen""" ! self._drawing = 1 """ --- 234,242 ---- """raises the turtle pen, so no drawing will occur on subsequent commands until the pen is lowered with penDown""" ! self._drawing = False def penDown(self): """lowers the turtle pen""" ! self._drawing = True """ *************** *** 312,328 **** #self._color = wx.Pen(wx.NamedColour("black")) ! self._origin = float(width)/2.0, float(height)/2.0 self._position = self._origin self._odometer = 0.0 ! self._odometerOn = 0 # don't waste time tracking unless requested self._angle = 0.0 ! self._drawing = 1 self._width = 1 self._filling = 0 self._path = [] self._tofill = [] ! self._dirty = 0 ! self._visible = 0 ! self._drawingTurtle = 0 self._turtleDelay = 0 --- 312,329 ---- #self._color = wx.Pen(wx.NamedColour("black")) ! self._origin = width/2.0, height/2.0 self._position = self._origin self._odometer = 0.0 ! # don't waste time tracking unless requested ! self._odometerOn = False self._angle = 0.0 ! self._drawing = True self._width = 1 self._filling = 0 self._path = [] self._tofill = [] ! self._dirty = False ! self._visible = False ! self._drawingTurtle = False self._turtleDelay = 0 *************** *** 335,339 **** y = self._position[1] drawingState = self._drawing ! self._drawing = 0 self._goto(x, y) self._drawing = drawingState --- 336,340 ---- y = self._position[1] drawingState = self._drawing ! self._drawing = False self._goto(x, y) self._drawing = drawingState *************** *** 378,382 **** # that means keeping the variable in a form that is # simple to compare to the underlying dc canvas ! self.canvas.drawPoint((x, y)) # other variations #self.dc.DrawLine(x, y, x+1, y+1) --- 379,383 ---- # that means keeping the variable in a form that is # simple to compare to the underlying dc canvas ! self.canvas.drawPoint((round(x), round(y))) # other variations #self.dc.DrawLine(x, y, x+1, y+1) *************** *** 390,394 **** self.canvas._bufImage.SetPen(self._pen) ###self.dc.DrawLine(x1, y1, x2, y2) ! self.canvas.drawLine((x1, y1), (x2, y2)) # probably replace this with a wxPython primitive for polygons --- 391,395 ---- self.canvas._bufImage.SetPen(self._pen) ###self.dc.DrawLine(x1, y1, x2, y2) ! self.canvas.drawLine((round(x1), round(y1)), (round(x2), round(y2))) # probably replace this with a wxPython primitive for polygons *************** *** 420,424 **** ###self.dc.Clear() self.canvas.clear() ! self._dirty = 0 # need to enhance this to support the various --- 421,425 ---- ###self.dc.Clear() self.canvas.clear() ! self._dirty = False # need to enhance this to support the various *************** *** 519,523 **** #if not self._drawingTurtle: self._dirty = not self._dirty ! self._drawingTurtle = 1 drawingState = self._drawing currentPos = self._position --- 520,524 ---- #if not self._drawingTurtle: self._dirty = not self._dirty ! self._drawingTurtle = True drawingState = self._drawing currentPos = self._position *************** *** 549,553 **** self._drawing = drawingState self._position = currentPos ! self._drawingTurtle = 0 if self._dirty and self._turtleDelay > 0: time.sleep(self._turtleDelay) --- 550,554 ---- self._drawing = drawingState self._position = currentPos ! self._drawingTurtle = False if self._dirty and self._turtleDelay > 0: time.sleep(self._turtleDelay) *************** *** 570,589 **** #AbstractTurtle.reset() ! self._origin = float(width)/2.0, float(height)/2.0 #print "width: %d, height: %d" % (width, height) #print "_origin.x: %f, _origin.y: %f" % (self._origin[0], self._origin[1]) self._position = self._origin self._odometer = 0.0 ! self._odometerOn = 0 # don't waste time tracking unless requested self._angle = 0.0 ! self._drawing = 1 # whether the pen is down self._width = 1 #self._filling = 0 #self._path = [] #self._tofill = [] ! self._visible = 0 # whether the turtle is visible, independent of the pen state ! self._dirty = 0 # if _dirty then erase old turtle before drawing ! self._drawingTurtle = 0 # only true while drawing the turtle ! self._turtleDelay = 0 # number of seconds to pause after drawing the turtle def _goto(self, x1, y1): --- 571,596 ---- #AbstractTurtle.reset() ! self._origin = width/2.0, height/2.0 #print "width: %d, height: %d" % (width, height) #print "_origin.x: %f, _origin.y: %f" % (self._origin[0], self._origin[1]) self._position = self._origin self._odometer = 0.0 ! # don't waste time tracking unless requested ! self._odometerOn = False self._angle = 0.0 ! # whether the pen is down ! self._drawing = True self._width = 1 #self._filling = 0 #self._path = [] #self._tofill = [] ! # whether the turtle is visible, independent of the pen state ! self._visible = False ! # if _dirty then erase old turtle before drawing ! self._dirty = False ! # only true while drawing the turtle ! self._drawingTurtle = False ! # number of seconds to pause after drawing the turtle ! self._turtleDelay = 0 def _goto(self, x1, y1): *************** *** 600,604 **** x0, y0 = start = self._position ! self._position = map(float, (x1, y1)) #if self._filling: # self._path.append(self._position) --- 607,611 ---- x0, y0 = start = self._position ! self._position = (float(x1), float(y1)) #if self._filling: # self._path.append(self._position) *************** *** 623,627 **** self.canvas._bufImage.SetPen(self._pen) ###self.dc.DrawLine(x0, y0, x1, y1) ! self.canvas.drawLine((x0, y0), (x1, y1)) if not self._drawingTurtle: --- 630,634 ---- self.canvas._bufImage.SetPen(self._pen) ###self.dc.DrawLine(x0, y0, x1, y1) ! self.canvas.drawLine((round(x0), round(y0)), (round(x1), round(y1))) if not self._drawingTurtle: |
From: Kevin A. <ka...@us...> - 2004-05-01 17:05:43
|
Update of /cvsroot/pythoncard/PythonCard/samples/spirographInteractive In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16158/samples/spirographInteractive Added Files: .cvsignore readme.txt spirographInteractive.py spirographInteractive.rsrc.py Log Message: made spirographInteractive its own sample --- NEW FILE: .cvsignore --- .cvsignore *.pyc *.log .DS_Store --- NEW FILE: spirographInteractive.py --- #!/usr/bin/python """ __version__ = "$Revision: 1.1 $" __date__ = "$Date: 2004/05/01 17:05:32 $" """ """ this is a direct port of the Java applet at http://www.wordsmith.org/anu/java/spirograph.html """ from PythonCard import clipboard, dialog, graphic, model import wx import os import random import math class Spirograph(model.Background): def on_initialize(self, event): self.filename = None comp = self.components self.sliderLabels = { 'stcFixedCircleRadius':comp.stcFixedCircleRadius.text, 'stcMovingCircleRadius':comp.stcMovingCircleRadius.text, 'stcMovingCircleOffset':comp.stcMovingCircleOffset.text, 'stcRevolutionsInRadians':comp.stcRevolutionsInRadians.text, } self.setSliderLabels() if self.components.chkDarkCanvas.checked: self.components.bufOff.backgroundColor = 'black' self.components.bufOff.clear() self.doSpirograph() def doSpirograph(self): comp = self.components canvas = comp.bufOff width, height = canvas.size xOffset = width / 2 yOffset = height / 2 R = comp.sldFixedCircleRadius.value r = comp.sldMovingCircleRadius.value O = comp.sldMovingCircleOffset.value revolutions = comp.sldRevolutionsInRadians.value color = comp.btnColor.backgroundColor canvas.foregroundColor = color canvas.autoRefresh = 0 canvas.clear() if comp.radDrawingStyle.stringSelection == 'Lines': drawLines = 1 else: drawLines = 0 t = 0.0 if R+r+O == 0: # avoid divide by zero errors s = 5.0/0.0000001 else: s = 5.0/(R+r+O) rSum = R + r # avoid divide by zero errors if r == 0: r = 0.0000001 exprResult = (rSum * t) / r lastX = rSum*math.cos(t) - O*math.cos(exprResult) + xOffset lastY = rSum*math.sin(t) - O*math.sin(exprResult) + yOffset self.keepDrawing = 1 points = [] while abs(t) <= revolutions: exprResult = (rSum * t) / r x = rSum*math.cos(t) - O*math.cos(exprResult) + xOffset y = rSum*math.sin(t) - O*math.sin(exprResult) + yOffset if drawLines: points.append((lastX, lastY, x, y)) lastX = x lastY = y else: points.append((x, y)) t += s if drawLines: canvas.drawLineList(points) else: canvas.drawPointList(points) canvas.autoRefresh = 1 canvas.refresh() def on_btnColor_mouseClick(self, event): result = dialog.colorDialog(self) if result['accepted']: self.components.bufOff.foregroundColor = result['color'] event.target.backgroundColor = result['color'] self.doSpirograph() def on_select(self, event): name = event.target.name # only process Sliders if name.startswith('sld'): labelName = 'stc' + name[3:] self.components[labelName].text = self.sliderLabels[labelName] + \ ' ' + str(event.target.value) self.doSpirograph() def on_chkDarkCanvas_mouseClick(self, event): if event.target.checked: self.components.bufOff.backgroundColor = 'black' else: self.components.bufOff.backgroundColor = 'white' self.doSpirograph() def setSliderLabels(self): comp = self.components for key in self.sliderLabels: sliderName = 'sld' + key[3:] comp[key].text = self.sliderLabels[key] + ' ' + str(comp[sliderName].value) def on_btnRandom_mouseClick(self, event): comp = self.components comp.sldFixedCircleRadius.value = random.randint(1, 100) comp.sldMovingCircleRadius.value = random.randint(-50, 50) comp.sldMovingCircleOffset.value = random.randint(1, 100) self.setSliderLabels() self.doSpirograph() def openFile(self): wildcard = "All files (*.*)|*.*" result = dialog.openFileDialog(None, "Import which file?", '', '', wildcard) if result['accepted']: path = result['paths'][0] os.chdir(os.path.dirname(path)) try: self.filename = path filename = os.path.splitext(os.path.basename(path))[0] if filename.startswith('spiro'): items = filename[5:].split('_') comp = self.components comp.sldFixedCircleRadius.value = int(items[0]) comp.sldMovingCircleRadius.value = int(items[1]) comp.sldMovingCircleOffset.value = int(items[2]) comp.btnColor.backgroundColor = eval(items[3]) comp.chkDarkCanvas.checked = int(items[4]) if items[5] == 'L': comp.radDrawingStyle.stringSelection = 'Lines' else: comp.radDrawingStyle.stringSelection = 'Points' comp.sldRevolutionsInRadians.value = int(items[6]) self.setSliderLabels() bmp = graphic.Bitmap(self.filename) self.components.bufOff.drawBitmap(bmp, (0, 0)) except: pass def on_menuFileOpen_select(self, event): self.openFile() def on_menuFileSaveAs_select(self, event): if self.filename is None: path = '' filename = '' else: path, filename = os.path.split(self.filename) comp = self.components style = comp.radDrawingStyle.stringSelection[0] filename = 'spiro' + str(comp.sldFixedCircleRadius.value) + '_' + \ str(comp.sldMovingCircleRadius.value) + '_' + \ str(comp.sldMovingCircleOffset.value) + '_' + \ str(comp.btnColor.backgroundColor) + '_' + \ str(comp.chkDarkCanvas.checked) + '_' + \ style + '_' + \ str(comp.sldRevolutionsInRadians.value) + \ '.png' wildcard = "All files (*.*)|*.*" result = dialog.saveFileDialog(None, "Save As", path, filename, wildcard) if result['accepted']: path = result['paths'][0] fileType = graphic.bitmapType(path) try: bmp = self.components.bufOff.getBitmap() bmp.SaveFile(path, fileType) return 1 except: return 0 else: return 0 def on_menuEditCopy_select(self, event): clipboard.setClipboard(self.components.bufOff.getBitmap()) def on_menuEditPaste_select(self, event): bmp = clipboard.getClipboard() if isinstance(bmp, wx.Bitmap): self.components.bufOff.drawBitmap(bmp) def on_editClear_command(self, event): self.components.bufOff.clear() def on_menuFileExit_select(self, event): self.close() if __name__ == '__main__': app = model.Application(Spirograph) app.MainLoop() --- NEW FILE: readme.txt --- spirograph.py is a direct port of the Java applet by Anu Garg at: http://www.wordsmith.org/anu/java/spirograph.html The following quote is from Anu's page: What is a Spirograph? A Spirograph is formed by rolling a circle inside or outside of another circle. The pen is placed at any point on the rolling circle. If the radius of fixed circle is R, the radius of moving circle is r, and the offset of the pen point in the moving circle is O, then the equation of the resulting curve is defined by: x = (R+r)*cos(t) - O*cos(((R+r)/r)*t) y = (R+r)*sin(t) - O*sin(((R+r)/r)*t) There is a second sample called spirographInteractive.py which draws the complete spirograph as each slider, color, or other value is changed. This makes spirographInteractive much more like the Java applet and the drawing speed is similar. On a machine with a faster video card, drawing should be sufficiently fast that the UI won't be sluggish unless the number of revolutions is quite high. However, since spirographInteractive doesn't allow you to see the individual points or lines of the pattern as they are drawn or overlay multiple patterns and is more demanding of machine resources I decided to make it a separate program rather than complicating the code and UI of the spirograph sample. --- NEW FILE: spirographInteractive.rsrc.py --- {'stack':{'type':'Stack', 'name':'Spirograph', 'backgrounds': [ {'type':'Background', 'name':'bgSpirograph', 'title':'Spirograph PythonCard Application', 'position':(5, 5), 'size':(750, 595), 'statusBar':1, 'menubar': {'type':'MenuBar', 'menus': [ {'type':'Menu', 'name':'menuFile', 'label':'&File', 'items': [ {'type':'MenuItem', 'name':'menuFileOpen', 'label':'&Open...\tCtrl+O', }, {'type':'MenuItem', 'name':'menuFileSaveAs', 'label':'Save &As...', }, {'type':'MenuItem', 'name':'fileSep1', 'label':'-', }, {'type':'MenuItem', 'name':'menuFileExit', 'label':'E&xit\tAlt+X', }, ] }, {'type':'Menu', 'name':'menuEdit', 'label':'&Edit', 'items': [ {'type':'MenuItem', 'name':'menuEditCopy', 'label':'&Copy\tCtrl+C', }, {'type':'MenuItem', 'name':'menuEditPaste', 'label':'&Paste\tCtrl+V', }, {'type':'MenuItem', 'name':'editSep1', 'label':'-', }, {'type':'MenuItem', 'name':'menuEditClear', 'label':'&Clear', 'command':'editClear', }, ] }, ] }, 'components': [ {'type':'BitmapCanvas', 'name':'bufOff', 'position':(3, 3), 'size':(525, 525), 'thickness':1, }, {'type':'StaticText', 'name':'stcFixedCircleRadius', 'position':(540, 30), 'text':'Fixed circle radius (1 - 100):', }, {'type':'StaticText', 'name':'stcMovingCircleRadius', 'position':(540, 70), 'text':'Moving circle radius (-50 - 50):', }, {'type':'StaticText', 'name':'stcMovingCircleOffset', 'position':(540, 110), 'text':'Moving circle offset (1 - 100):', }, {'type':'StaticText', 'name':'stcRevolutionsInRadians', 'position':(540, 260), 'text':'Revolutions in radians (1 - 500):', }, {'type':'Slider', 'name':'sldFixedCircleRadius', 'position':(540, 46), 'size':(200, 20), 'layout':'horizontal', 'max':100, 'min':1, 'value':74, }, {'type':'Slider', 'name':'sldMovingCircleRadius', 'position':(540, 86), 'size':(200, 20), 'layout':'horizontal', 'max':50, 'min':-50, 'value':25, }, {'type':'Slider', 'name':'sldMovingCircleOffset', 'position':(540, 126), 'size':(200, 20), 'layout':'horizontal', 'max':100, 'min':1, 'value':78, }, {'type':'Button', 'name':'btnColor', 'position':(540, 154), 'label':'Foreground Color', 'backgroundColor':(0, 128, 255), }, {'type':'CheckBox', 'name':'chkDarkCanvas', 'position':(652, 160), 'checked':0, 'label':'Dark Canvas', }, {'type':'RadioGroup', 'name':'radDrawingStyle', 'position':(540, 200), 'items':['Lines', 'Points'], 'label':'Draw as', 'layout':'horizontal', 'max':1, 'stringSelection':'Lines', }, {'type':'Slider', 'name':'sldRevolutionsInRadians', 'position':(540, 276), 'size':(200, 20), 'layout':'horizontal', 'max':500, 'min':1, 'value':50, }, {'type':'Button', 'name':'btnRandom', 'position':(540, 360), 'label':'Random Circle Values', }, ] # end components } # end background ] # end backgrounds } } |
From: Kevin A. <ka...@us...> - 2004-05-01 17:05:39
|
Update of /cvsroot/pythoncard/PythonCard/samples/spirograph In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16158/samples/spirograph Removed Files: spirographInteractive.py spirographInteractive.rsrc.py Log Message: made spirographInteractive its own sample --- spirographInteractive.py DELETED --- --- spirographInteractive.rsrc.py DELETED --- |
From: Kevin A. <ka...@us...> - 2004-05-01 17:05:38
|
Update of /cvsroot/pythoncard/PythonCard/docs In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16158/docs Modified Files: changelog.txt Log Message: made spirographInteractive its own sample Index: changelog.txt =================================================================== RCS file: /cvsroot/pythoncard/PythonCard/docs/changelog.txt,v retrieving revision 1.278 retrieving revision 1.279 diff -C2 -d -r1.278 -r1.279 *** changelog.txt 29 Apr 2004 23:59:23 -0000 1.278 --- changelog.txt 1 May 2004 17:05:29 -0000 1.279 *************** *** 3,6 **** --- 3,7 ---- Release 0.8 2004-05-?? + made spirographInteractive its own sample added restore (inverse of minimize) background window event added twistedEchoClient sample |
From: Kevin A. <ka...@us...> - 2004-05-01 17:05:38
|
Update of /cvsroot/pythoncard/PythonCard/samples In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16158/samples Modified Files: samples.rsrc.py Log Message: made spirographInteractive its own sample Index: samples.rsrc.py =================================================================== RCS file: /cvsroot/pythoncard/PythonCard/samples/samples.rsrc.py,v retrieving revision 1.54 retrieving revision 1.55 diff -C2 -d -r1.54 -r1.55 *** samples.rsrc.py 27 Apr 2004 22:03:05 -0000 1.54 --- samples.rsrc.py 1 May 2004 17:05:30 -0000 1.55 *************** *** 63,67 **** 'samples', 'saveClipboardBitmap', 'searchexplorer', \ 'simpleBrowser', 'simpleIEBrowser', 'slideshow', 'sounds', 'SourceForgeTracker', \ ! 'spirograph', 'stockprice', 'textIndexer', 'textRouter', \ 'tictactoe', 'turtle', 'twistedEchoClient', \ 'webgrabber', 'webserver', 'widgets', 'worldclock'], --- 63,67 ---- 'samples', 'saveClipboardBitmap', 'searchexplorer', \ 'simpleBrowser', 'simpleIEBrowser', 'slideshow', 'sounds', 'SourceForgeTracker', \ ! 'spirograph', 'spirographInteractive', 'stockprice', 'textIndexer', 'textRouter', \ 'tictactoe', 'turtle', 'twistedEchoClient', \ 'webgrabber', 'webserver', 'widgets', 'worldclock'], |
From: Kevin A. <ka...@us...> - 2004-05-01 17:00:03
|
Update of /cvsroot/pythoncard/PythonCard/samples/spirographInteractive In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15031/spirographInteractive Log Message: Directory /cvsroot/pythoncard/PythonCard/samples/spirographInteractive added to the repository |
From: Kevin A. <ka...@us...> - 2004-05-01 16:26:09
|
Update of /cvsroot/pythoncard/PythonCard/components In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8381/components Modified Files: bitmapcanvas.py Log Message: added fixdc.py - wxPython 2.5.1.5 DC methods workaround modified bitmapcanvas.py methods to use Point Size variations of names Index: bitmapcanvas.py =================================================================== RCS file: /cvsroot/pythoncard/PythonCard/components/bitmapcanvas.py,v retrieving revision 1.38 retrieving revision 1.39 diff -C2 -d -r1.38 -r1.39 *** bitmapcanvas.py 21 Apr 2004 07:34:16 -0000 1.38 --- bitmapcanvas.py 1 May 2004 16:26:01 -0000 1.39 *************** *** 206,214 **** def blit(self, destXY, widthHeight, source, srcXY, logicalFunc=wx.COPY, useMask=False): #, xsrcMask=-1, ysrcMask=-1): ! self._bufImage.Blit(destXY, widthHeight, source, srcXY, logicalFunc, useMask) #, xsrcMask, ysrcMask) if self.autoRefresh: dc = wx.ClientDC(self) ! dc.Blit((0, 0), (self._size[0], self._size[1]), self._bufImage, (0, 0)) def clear(self): --- 206,214 ---- def blit(self, destXY, widthHeight, source, srcXY, logicalFunc=wx.COPY, useMask=False): #, xsrcMask=-1, ysrcMask=-1): ! self._bufImage.BlitPointSize(destXY, widthHeight, source, srcXY, logicalFunc, useMask) #, xsrcMask, ysrcMask) if self.autoRefresh: dc = wx.ClientDC(self) ! dc.BlitPointSize((0, 0), (self._size[0], self._size[1]), self._bufImage, (0, 0)) def clear(self): *************** *** 216,227 **** if self.autoRefresh: dc = wx.ClientDC(self) ! dc.Blit((0, 0), (self._size[0], self._size[1]), self._bufImage, (0, 0)) # this is poorly named, it should be DrawAxis def crossHair(self, xy): ! self._bufImage.CrossHair(xy) if self.autoRefresh: dc = wx.ClientDC(self) ! dc.Blit((0, 0), (self._size[0], self._size[1]), self._bufImage, (0, 0)) def drawArc(self, x1y1, x2y2, xcyc): --- 216,227 ---- if self.autoRefresh: dc = wx.ClientDC(self) ! dc.BlitPointSize((0, 0), (self._size[0], self._size[1]), self._bufImage, (0, 0)) # this is poorly named, it should be DrawAxis def crossHair(self, xy): ! self._bufImage.CrossHairPoint(xy) if self.autoRefresh: dc = wx.ClientDC(self) ! dc.BlitPointSize((0, 0), (self._size[0], self._size[1]), self._bufImage, (0, 0)) def drawArc(self, x1y1, x2y2, xcyc): *************** *** 235,242 **** """ ! self._bufImage.DrawArc(x1y1, x2y2, xcyc) if self.autoRefresh: dc = wx.ClientDC(self) ! dc.Blit((0, 0), (self._size[0], self._size[1]), self._bufImage, (0, 0)) # doesn't exist in wxMemoryDC --- 235,242 ---- """ ! self._bufImage.DrawArcPoint(x1y1, x2y2, xcyc) if self.autoRefresh: dc = wx.ClientDC(self) ! dc.BlitPointSize((0, 0), (self._size[0], self._size[1]), self._bufImage, (0, 0)) # doesn't exist in wxMemoryDC *************** *** 259,266 **** return ! self._bufImage.DrawBitmap(bmp, xy, transparency) if self.autoRefresh: dc = wx.ClientDC(self) ! dc.Blit((0, 0), (self._size[0], self._size[1]), self._bufImage, (0, 0)) def drawBitmapScaled(self, aBitmap, xy, size, transparency=1): --- 259,266 ---- return ! self._bufImage.DrawBitmapPoint(bmp, xy, transparency) if self.autoRefresh: dc = wx.ClientDC(self) ! dc.BlitPointSize((0, 0), (self._size[0], self._size[1]), self._bufImage, (0, 0)) def drawBitmapScaled(self, aBitmap, xy, size, transparency=1): *************** *** 279,316 **** bmp = wx.BitmapFromImage(img.Scale(size[0], size[1])) ! self._bufImage.DrawBitmap(bmp, xy, transparency) if self.autoRefresh: dc = wx.ClientDC(self) ! dc.Blit((0, 0), (self._size[0], self._size[1]), self._bufImage, (0, 0)) def drawCircle(self, xy, radius): ! self._bufImage.DrawCircle(xy, radius) if self.autoRefresh: dc = wx.ClientDC(self) ! dc.Blit((0, 0), (self._size[0], self._size[1]), self._bufImage, (0, 0)) def drawEllipse(self, xy, widthHeight): ! self._bufImage.DrawEllipse(xy, widthHeight) if self.autoRefresh: dc = wx.ClientDC(self) ! dc.Blit((0, 0), (self._size[0], self._size[1]), self._bufImage, (0, 0)) def drawEllipticArc(self, xy, widthHeight, startEnd): ! self._bufImage.DrawEllipticArc(xy, widthHeight, startEnd) if self.autoRefresh: dc = wx.ClientDC(self) ! dc.Blit((0, 0), (self._size[0], self._size[1]), self._bufImage, (0, 0)) def drawIcon(self, aIcon, xy): ! self._bufImage.DrawIcon(aIcon, xy) if self.autoRefresh: dc = wx.ClientDC(self) ! dc.Blit((0, 0), (self._size[0], self._size[1]), self._bufImage, (0, 0)) def drawLine(self, startXY, endXY): ! self._bufImage.DrawLine(startXY, endXY) if self.autoRefresh: dc = wx.ClientDC(self) ! dc.Blit((0, 0), (self._size[0], self._size[1]), self._bufImage, (0, 0)) def drawLines(self, pointsList): --- 279,316 ---- bmp = wx.BitmapFromImage(img.Scale(size[0], size[1])) ! self._bufImage.DrawBitmapPoint(bmp, xy, transparency) if self.autoRefresh: dc = wx.ClientDC(self) ! dc.BlitPointSize((0, 0), (self._size[0], self._size[1]), self._bufImage, (0, 0)) def drawCircle(self, xy, radius): ! self._bufImage.DrawCirclePoint(xy, radius) if self.autoRefresh: dc = wx.ClientDC(self) ! dc.BlitPointSize((0, 0), (self._size[0], self._size[1]), self._bufImage, (0, 0)) def drawEllipse(self, xy, widthHeight): ! self._bufImage.DrawEllipsePointSize(xy, widthHeight) if self.autoRefresh: dc = wx.ClientDC(self) ! dc.BlitPointSize((0, 0), (self._size[0], self._size[1]), self._bufImage, (0, 0)) def drawEllipticArc(self, xy, widthHeight, startEnd): ! self._bufImage.DrawEllipticArcPointSize(xy, widthHeight, startEnd) if self.autoRefresh: dc = wx.ClientDC(self) ! dc.BlitPointSize((0, 0), (self._size[0], self._size[1]), self._bufImage, (0, 0)) def drawIcon(self, aIcon, xy): ! self._bufImage.DrawIconPoint(aIcon, xy) if self.autoRefresh: dc = wx.ClientDC(self) ! dc.BlitPointSize((0, 0), (self._size[0], self._size[1]), self._bufImage, (0, 0)) def drawLine(self, startXY, endXY): ! self._bufImage.DrawLinePoint(startXY, endXY) if self.autoRefresh: dc = wx.ClientDC(self) ! dc.BlitPointSize((0, 0), (self._size[0], self._size[1]), self._bufImage, (0, 0)) def drawLines(self, pointsList): *************** *** 318,328 **** if self.autoRefresh: dc = wx.ClientDC(self) ! dc.Blit((0, 0), (self._size[0], self._size[1]), self._bufImage, (0, 0)) def drawPoint(self, xy): ! self._bufImage.DrawPoint(xy) if self.autoRefresh: dc = wx.ClientDC(self) ! dc.Blit((0, 0), (self._size[0], self._size[1]), self._bufImage, (0, 0)) def drawPolygon(self, pointsList): --- 318,328 ---- if self.autoRefresh: dc = wx.ClientDC(self) ! dc.BlitPointSize((0, 0), (self._size[0], self._size[1]), self._bufImage, (0, 0)) def drawPoint(self, xy): ! self._bufImage.DrawPointPoint(xy) if self.autoRefresh: dc = wx.ClientDC(self) ! dc.BlitPointSize((0, 0), (self._size[0], self._size[1]), self._bufImage, (0, 0)) def drawPolygon(self, pointsList): *************** *** 330,340 **** if self.autoRefresh: dc = wx.ClientDC(self) ! dc.Blit((0, 0), (self._size[0], self._size[1]), self._bufImage, (0, 0)) def drawRectangle(self, xy, widthHeight): ! self._bufImage.DrawRectangle(xy, widthHeight) if self.autoRefresh: dc = wx.ClientDC(self) ! dc.Blit((0, 0), (self._size[0], self._size[1]), self._bufImage, (0, 0)) def drawPointList(self, points, pens=None): --- 330,340 ---- if self.autoRefresh: dc = wx.ClientDC(self) ! dc.BlitPointSize((0, 0), (self._size[0], self._size[1]), self._bufImage, (0, 0)) def drawRectangle(self, xy, widthHeight): ! self._bufImage.DrawRectanglePointSize(xy, widthHeight) if self.autoRefresh: dc = wx.ClientDC(self) ! dc.BlitPointSize((0, 0), (self._size[0], self._size[1]), self._bufImage, (0, 0)) def drawPointList(self, points, pens=None): *************** *** 342,346 **** if self.autoRefresh: dc = wx.ClientDC(self) ! dc.Blit((0, 0), (self._size[0], self._size[1]), self._bufImage, (0, 0)) # KEA 2003-03-14 --- 342,346 ---- if self.autoRefresh: dc = wx.ClientDC(self) ! dc.BlitPointSize((0, 0), (self._size[0], self._size[1]), self._bufImage, (0, 0)) # KEA 2003-03-14 *************** *** 351,367 **** if self.autoRefresh: dc = wx.ClientDC(self) ! dc.Blit((0, 0), (self._size[0], self._size[1]), self._bufImage, (0, 0)) def drawRotatedText(self, aString, xy, angle): ! self._bufImage.DrawRotatedText(aString, xy, angle) if self.autoRefresh: dc = wx.ClientDC(self) ! dc.Blit((0, 0), (self._size[0], self._size[1]), self._bufImage, (0, 0)) def drawRoundedRectangle(self, xy, widthHeight, radius): ! self._bufImage.DrawRoundedRectangle(xy, widthHeight, radius) if self.autoRefresh: dc = wx.ClientDC(self) ! dc.Blit((0, 0), (self._size[0], self._size[1]), self._bufImage, (0, 0)) def drawSpline(self, pointsList): --- 351,367 ---- if self.autoRefresh: dc = wx.ClientDC(self) ! dc.BlitPointSize((0, 0), (self._size[0], self._size[1]), self._bufImage, (0, 0)) def drawRotatedText(self, aString, xy, angle): ! self._bufImage.DrawRotatedTextPoint(aString, xy, angle) if self.autoRefresh: dc = wx.ClientDC(self) ! dc.BlitPointSize((0, 0), (self._size[0], self._size[1]), self._bufImage, (0, 0)) def drawRoundedRectangle(self, xy, widthHeight, radius): ! self._bufImage.DrawRoundedRectanglePointSize(xy, widthHeight, radius) if self.autoRefresh: dc = wx.ClientDC(self) ! dc.BlitPointSize((0, 0), (self._size[0], self._size[1]), self._bufImage, (0, 0)) def drawSpline(self, pointsList): *************** *** 369,373 **** if self.autoRefresh: dc = wx.ClientDC(self) ! dc.Blit((0, 0), (self._size[0], self._size[1]), self._bufImage, (0, 0)) def drawLineList(self, lines, pens=None): --- 369,373 ---- if self.autoRefresh: dc = wx.ClientDC(self) ! dc.BlitPointSize((0, 0), (self._size[0], self._size[1]), self._bufImage, (0, 0)) def drawLineList(self, lines, pens=None): *************** *** 375,415 **** if self.autoRefresh: dc = wx.ClientDC(self) ! dc.Blit((0, 0), (self._size[0], self._size[1]), self._bufImage, (0, 0)) def drawText(self, aString, xy): ! self._bufImage.DrawText(aString, xy) if self.autoRefresh: dc = wx.ClientDC(self) ! dc.Blit((0, 0), (self._size[0], self._size[1]), self._bufImage, (0, 0)) # KEA 2002-03-31 this doesn't seem to work def floodFill(self, xy, colour, style=wx.FLOOD_SURFACE): ! self._bufImage.FloodFill(xy, colour, style) if self.autoRefresh: dc = wx.ClientDC(self) ! dc.Blit((0, 0), (self._size[0], self._size[1]), self._bufImage, (0, 0)) def getPixel(self, xy): ! return self._bufImage.GetPixel(xy) ! ! """ ! # these are aliases for the old BitmapCanvas methods that ! # started with a lowercase letter ! clear = Clear ! drawBitmap = DrawBitmap ! drawLineList = DrawLineList ! drawPointList = DrawPointList ! drawRectangleList = DrawRectangleList ! drawRect = drawRectangle = DrawRectangle ! drawText = DrawText ! drawRotatedText = DrawRotatedText ! drawEllipse = DrawEllipse ! line = drawLine = DrawLine ! plot = drawPoint = DrawPoint ! """ def refresh(self): dc = wx.ClientDC(self) ! dc.Blit((0, 0), (self._size[0], self._size[1]), self._bufImage, (0, 0)) #self._delegate.Refresh() --- 375,399 ---- if self.autoRefresh: dc = wx.ClientDC(self) ! dc.BlitPointSize((0, 0), (self._size[0], self._size[1]), self._bufImage, (0, 0)) def drawText(self, aString, xy): ! self._bufImage.DrawTextPoint(aString, xy) if self.autoRefresh: dc = wx.ClientDC(self) ! dc.BlitPointSize((0, 0), (self._size[0], self._size[1]), self._bufImage, (0, 0)) # KEA 2002-03-31 this doesn't seem to work def floodFill(self, xy, colour, style=wx.FLOOD_SURFACE): ! self._bufImage.FloodFillPoint(xy, colour, style) if self.autoRefresh: dc = wx.ClientDC(self) ! dc.BlitPointSize((0, 0), (self._size[0], self._size[1]), self._bufImage, (0, 0)) def getPixel(self, xy): ! return self._bufImage.GetPixelPoint(xy) def refresh(self): dc = wx.ClientDC(self) ! dc.BlitPointSize((0, 0), (self._size[0], self._size[1]), self._bufImage, (0, 0)) #self._delegate.Refresh() *************** *** 420,425 **** #print "OnPaint", rect dc = wx.PaintDC(self) ! #dc.Blit((0, 0), (self._size[0], self._size[1]), self._bufImage, (0, 0)) ! dc.Blit((rect[0], rect[1]), (rect[2], rect[3]), self._bufImage, (rect[0], rect[1])) #stoptime = time.time() #elapsed = stoptime - starttime --- 404,409 ---- #print "OnPaint", rect dc = wx.PaintDC(self) ! #dc.BlitPointSize((0, 0), (self._size[0], self._size[1]), self._bufImage, (0, 0)) ! dc.BlitPointSize((rect[0], rect[1]), (rect[2], rect[3]), self._bufImage, (rect[0], rect[1])) #stoptime = time.time() #elapsed = stoptime - starttime *************** *** 438,442 **** _bufImage.SetTextForeground(self._penColor) _bufImage.Clear() ! _bufImage.Blit((0, 0), (self._size[0], self._size[1]), self._bufImage, (0, 0)) self._size = size --- 422,426 ---- _bufImage.SetTextForeground(self._penColor) _bufImage.Clear() ! _bufImage.BlitPointSize((0, 0), (self._size[0], self._size[1]), self._bufImage, (0, 0)) self._size = size *************** *** 480,484 **** bitmap = wx.EmptyBitmap(size[0], size[1]) memory.SelectObject(bitmap) ! memory.Blit((0, 0), size, self._bufImage, (0, 0)) memory.SelectObject(wx.NullBitmap) return bitmap --- 464,468 ---- bitmap = wx.EmptyBitmap(size[0], size[1]) memory.SelectObject(bitmap) ! memory.BlitPointSize((0, 0), size, self._bufImage, (0, 0)) memory.SelectObject(wx.NullBitmap) return bitmap |
From: Kevin A. <ka...@us...> - 2004-05-01 16:26:09
|
Update of /cvsroot/pythoncard/PythonCard In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8381 Modified Files: model.py Added Files: fixdc.py Log Message: added fixdc.py - wxPython 2.5.1.5 DC methods workaround modified bitmapcanvas.py methods to use Point Size variations of names Index: model.py =================================================================== RCS file: /cvsroot/pythoncard/PythonCard/model.py,v retrieving revision 1.161 retrieving revision 1.162 diff -C2 -d -r1.161 -r1.162 *** model.py 29 Apr 2004 23:59:23 -0000 1.161 --- model.py 1 May 2004 16:26:00 -0000 1.162 *************** *** 16,19 **** --- 16,23 ---- assert wx.VERSION >= (2, 5) + # KEA 2004-05-01 + # temporary fix for wxPython 2.5.1.5 + import fixdc + import configuration import log --- NEW FILE: fixdc.py --- """ This module will do surgery on the wx.DC class in wxPython 2.5.1.5 to make it act like the wx.DC class in later versions will. In a nutshell, the old 2.4.x style of method names, where the 'normal' name takes separate parameters for x, y, width and height will be restored, and the new methods that take wx.Point and/or wx.Size (which can also be converted from 2-element sequences) will be given new non-default method names. The new names are: * FloodFillPoint * GetPixelPoint * DrawLinePoint * CrossHairPoint * DrawArcPoint * DrawCheckMarkRect * DrawEllipticArcPointSize * DrawPointPoint * DrawRectanglePointSize * DrawRoundedRectanglePointSize * DrawCirclePoint * DrawEllipsePointSize * DrawIconPoint * DrawBitmapPoint * DrawTextPoint * DrawRotatedTextPoint * BlitPointSize WARNING: If you import this module the the wx.DC class will be changed for the entire application, so if you use code from the wx.lib package or 3rd party modules that have already been converted to the doomed 2.5.1.5 implementaion of the DC Draw methods then that code will break. This is an all-or-nothing fix, (just like the next version of wxPython will be,) so you *will* need to do something to resolve this situation if you run into it. The best thing to do of course is to correct the library module to work with the corrected DC semantics and then send me a patch. --Robin """ import wx _names = [ ("FloodFillXY", "FloodFill", "FloodFillPoint"), ("GetPixelXY", "GetPixel", "GetPixelPoint"), ("DrawLineXY", "DrawLine", "DrawLinePoint"), ("CrossHairXY", "CrossHair", "CrossHairPoint"), ("DrawArcXY", "DrawArc", "DrawArcPoint"), ("DrawCheckMarkXY", "DrawCheckMark", "DrawCheckMarkRect"), ("DrawEllipticArcXY", "DrawEllipticArc", "DrawEllipticArcPointSize"), ("DrawPointXY", "DrawPoint", "DrawPointPoint"), ("DrawRectangleXY", "DrawRectangle", "DrawRectanglePointSize"), ("DrawRoundedRectangleXY", "DrawRoundedRectangle", "DrawRoundedRectanglePointSize"), ("DrawCircleXY", "DrawCircle", "DrawCirclePoint"), ("DrawEllipseXY", "DrawEllipse", "DrawEllipsePointSize"), ("DrawIconXY", "DrawIcon", "DrawIconPoint"), ("DrawBitmapXY", "DrawBitmap", "DrawBitmapPoint"), ("DrawTextXY", "DrawText", "DrawTextPoint"), ("DrawRotatedTextXY", "DrawRotatedText", "DrawRotatedTextPoint"), ("BlitXY", "Blit", "BlitPointSize"), ] if wx.VERSION[:4] == (2,5,1,5): cls = wx.DC for old, norm, new in _names: m_old = getattr(cls, old) m_norm = getattr(cls, norm) setattr(cls, new, m_norm) setattr(cls, norm, m_old) delattr(cls, old) |
From: Kevin A. <ka...@us...> - 2004-05-01 06:13:42
|
Update of /cvsroot/pythoncard/PythonCard/components In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29518/components Modified Files: textfield.py Log Message: transition code to new style event bindings and dispatch this is essentially the same code as used by button.py _bindEvents and _dispatch Index: textfield.py =================================================================== RCS file: /cvsroot/pythoncard/PythonCard/components/textfield.py,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -d -r1.23 -r1.24 *** textfield.py 21 Apr 2004 03:45:00 -0000 1.23 --- textfield.py 1 May 2004 06:13:34 -0000 1.24 *************** *** 8,11 **** --- 8,35 ---- from PythonCard import event, widget + # KEA 2002-04-04 + # custom event posted after loseFocus when a field + # has been changed + wxEVT_CLOSE_FIELD = wx.NewEventType() + + ##def EVT_CLOSE_FIELD(win, id, func): + ## win.Connect(id, -1, wxEVT_CLOSE_FIELD, func) + # use the new PyEventBinder in 2.5.x + EVT_CLOSE_FIELD = wx.PyEventBinder(wxEVT_CLOSE_FIELD) + + class CloseFieldEvent(event.Event): + name = 'closeField' + binding = EVT_CLOSE_FIELD + id = wxEVT_CLOSE_FIELD + + + TextFieldEvents = ( + event.KeyPressEvent, + event.KeyDownEvent, + event.KeyUpEvent, + event.TextUpdateEvent, + CloseFieldEvent + ) + class TextFieldSpec(widget.WidgetSpec): def __init__( self ) : *************** *** 16,20 **** #event.TextEnterEvent, event.TextUpdateEvent, ! event.CloseFieldEvent ] attributes = { --- 40,44 ---- #event.TextEnterEvent, event.TextUpdateEvent, ! CloseFieldEvent ] attributes = { *************** *** 77,82 **** self.SetBackgroundColour(self.GetParent().GetBackgroundColour()) ! adapter = TextFieldEventBinding(self) ! adapter.bindEvents() def _getAlignment(self): --- 101,107 ---- self.SetBackgroundColour(self.GetParent().GetBackgroundColour()) ! #adapter = TextFieldEventBinding(self) ! #adapter.bindEvents() ! self._bindEvents() def _getAlignment(self): *************** *** 103,127 **** # capabilities or more - ## def _setText( self, aString ) : - ## """Sets the text value and marks the widget as not-modified. - ## aString may contain newline characters if the text widget is multi-line.""" - ## self.SetValue( aString ) - ## - ## def _getText( self ) : - ## """Gets the contents of the widget. Notice that for a multiline text - ## widget, the lines will be separated by (Unix-style) \\n characters, - ## even under Windows where they are separated by a \\r\\n sequence in - ## the native control.""" - ## return self.GetValue() - ## - ## def _getEditable( self ) : - ## """Returns whether the text widget is editable or read-only.""" - ## # KEA the test below doesn't seem to be working, so... - ## #return not self._delegate.GetWindowStyleFlag() & wxTE_READONLY - ## return self.IsEditable() - ## - ## def _setEditable( self, aBoolean ) : - ## """Makes the text widget editable or read-only.""" - ## self.SetEditable( aBoolean ) # KEA new methods to mirror wxPython wxTextCtrl capabilities --- 128,131 ---- *************** *** 224,239 **** def replaceSelection(self, aString, select=0): - """ - if wxPlatform == "__WXMSW__": - if select: - sel = self._delegate.GetSelection() - numNewlines = aString.count('\n') - self._delegate.WriteText(aString) - self._delegate.SetSelection( sel[0], sel[0] + len(aString) + numNewlines) - else: - self._delegate.WriteText(aString) - else: - # Linux - """ sel = self.GetSelection() self.Remove(sel[0], sel[1]) --- 228,231 ---- *************** *** 241,253 **** if select: self.SetSelection(sel[0], sel[0] + len(aString)) - """ - ins = self._delegate.GetInsertionPoint() - sel = self._delegate.GetSelection() - self._delegate.Remove( sel[0], sel[1] ) - #self._delegate.SetInsertionPoint( aFrom ) - self._delegate.WriteText( aString ) - self._delegate.SetSelection( ins, ins + len(aString)) - #self._delegate.SetInsertionPoint( i ) - """ # KEA support SaveFile? --- 233,236 ---- *************** *** 280,325 **** raise AttributeError, "border attribute is read-only" ! # KEA added 2001-11-13 ! # this will be replaced once 2.3.2 has GetStringSelection ! def getStringSelection(self): ! sel = self.getSelection() ! txt = self._getText() ! """ ! if wxPlatform == '__WXMSW__': ! numNewlines = txt.count('\n', 0, sel[0]) ! start = sel[0] - numNewlines ! # have to special-case a selection to the end of the line ! # this is in a try block to avoid an exception when we index past the end ! # of the string try: ! if txt[start + 1] == "\n": ! start = start + 1 except: pass ! #print numNewlines, start ! numNewlines = txt.count('\n', 0, sel[1]) ! end = sel[1] - numNewlines ! # have to special-case a selection to the end of the line ! # this is in a try block to avoid an exception when we index past the end ! # of the string try: ! if txt[end + 1] == "\n": ! end = end + 1 except: pass ! #print numNewlines, end ! selectedText = txt[start:end] ! #print selectedText else: ! """ ! selectedText = txt[sel[0]:sel[1]] ! return selectedText ! def getString(self, aFrom, aTo): ! return self.GetValue()[aFrom:aTo] - # mimic wxSTC method - ClearAll = wx.TextCtrl.Clear - alignment = property(_getAlignment, _setAlignment) border = property(_getBorder, _setBorder) --- 263,511 ---- raise AttributeError, "border attribute is read-only" ! getStringSelection = wx.TextCtrl.GetStringSelection ! ! def getString(self, aFrom, aTo): ! return self.GetValue()[aFrom:aTo] ! ! # mimic wxSTC method ! ClearAll = wx.TextCtrl.Clear ! ! def _bindEvents(self): ! # shouldn't components be subclasses of Scriptable? ! # components would have their own handlers but when ! # looking for a handler match it will search the parents ! # for now just grab handlers from the background ! background = self.GetParent().GetParent() ! ! # where should this check go? ! # should we just set a "global" in the app instance such as ! # self.stack.app.bindUnusedEvents ! # this kind of thing isn't going to work for Rowland's compound ! # components ! if background.stack.app._showDebugMenu: ! bindUnusedEvents = True ! else: ! bindUnusedEvents = False ! ! # helper variable to simplify test for whether to bind InsteadOfTypeEvents ! boundEvents = {} ! ! self.eventIdToHandler = {} ! self.wxEventIdMap = {} ! ! if 0: ! print "\nBINDING...", self.name ! ! #for eventClass in event.WIDGET_EVENTS + ButtonEvents: ! #for eventClass in ButtonEvents: ! for eventClass in event.WIDGET_EVENTS + TextFieldEvents: ! # need to figure out a way to avoid the need ! # for this id to class mapping which is used in _dispatch below ! self.wxEventIdMap[eventClass.id] = eventClass ! # command handler overrides normal mouseClick or select handler ! # so dispatch will automatically dispatch to the command handler ! # by looking up the handler this way ! # it also means that if there is a command association with this component ! # then the regular mouseClick or select handler will never be bound, just ignored ! if issubclass(eventClass, event.CommandTypeEvent) and self.command: ! handler = background.findHandler('on_' + self.command + '_command') ! if not handler: ! handler = background.findHandler('on_' + self.name + '_' + eventClass.name) ! else: ! handler = background.findHandler('on_' + self.name + '_' + eventClass.name) ! if not handler: ! handler = background.findHandler('on_' + eventClass.name) ! if handler or bindUnusedEvents: ! # only bind events that have an event handler ! # in this scenario unused events are never bound ! # which is more efficient, but the Message Watcher needs ! # to be changed ! # alternatively we can bind everything and then in _dispatch ! # if there isn't a match in eventIdToHandler then we know ! # the event isn't used and we can set used to False ! # the complication would be that we probably have to have to ! # always call Skip() which may or may not be a hassle with components ! ! # this doesn't bind command events ! # they would be of the form on_somename_command ! # or perhaps on_command but I don't think we would want ! # to support that ! # the event binding would be specific to a component ! # since on dispatch command overrides something like mouseClickEvent ! # but the name of the command is not related to the component ! # need to look at whether self.command has a value and then bind ! # with ButtonMouseClickEvent.binding if that isn't already bound ! # then in dispatch have to check again I think ! ! # need to avoid double binding ! # also binding shouldn't be order-specific ! # so how to avoid binding mouseDrag to _dispatch ! # if mouseMove is already bound or if binding mouseMove ! # not rebinding if mouseDrag is already bound ! # perhaps MouseDragEvent keeps a reference to MouseMoveEvent ! # and that is inserted into boundEvents, then we check boundEvents ! # prior to rebinding? ! if not boundEvents.get(eventClass.binding, None): ! self.Bind(eventClass.binding, self._dispatch) ! boundEvents[eventClass.binding] = eventClass.name ! if handler: ! if 0: ! print " binding", self.name, eventClass.name, handler._name, eventClass.id ! self.eventIdToHandler[eventClass.id] = handler ! ! # in order for closeField to work properly ! # both gainFocus and loseFocus have to be bound to _dispatch ! # regardless of whether they have handlers or not ! # everything else above is generic except the for statement ! # but that can be generalized once all components are bound ! # the same way ! for eventClass in [event.GainFocusEvent, event.LoseFocusEvent]: ! if not boundEvents.get(eventClass.binding, None): ! self.Bind(eventClass.binding, self._dispatch) ! boundEvents[eventClass.binding] = eventClass.name ! ! ! if 0: ! print "\n boundEvents:" ! for name in boundEvents.values(): ! print " ", name ! print "\n\n" ! print "\n self.eventIdToHandler:" ! for id in self.eventIdToHandler: ! print " ", id, self.eventIdToHandler[id]._function ! print "\n\n" ! boundEvents = None ! ! # this is pretty generic, but Button doesn't have any specific ! # handling that is required so I need to do the same kind of code ! # for TextField and see what the special handling for gainFocus, ! # loseFocus, closeField will look like ! # it probably won't need special handling for the key events ! def _dispatch(self, aWxEvent): ! eventType = aWxEvent.GetEventType() ! ! eventName = None ! ! if eventType == wx.wxEVT_TIMER: ! aWxEvent.interval = aWxEvent.GetInterval() ! # wxPython 2.5.1.5 workaround ! # for some reason wx.TimerEvent does not contain the event target ! # so we have to set it ourselves ! aWxEvent.target = aWxEvent.eventObject = self ! else: try: ! # all events should have GetEventObject() ! # except of course for wx.TimerEvent above ! # KEA 2004-04-25 ! # should we remove this redundant identifier? ! aWxEvent.target = aWxEvent.eventObject = self except: pass ! # Each of these could check the event class like ! # wxListEvent and wxTreeEvent above. try: ! # mouse and key events ! aWxEvent.position = tuple(aWxEvent.GetPosition()) ! aWxEvent.x = aWxEvent.GetX() ! aWxEvent.y = aWxEvent.GetY() ! aWxEvent.altDown = aWxEvent.AltDown() ! aWxEvent.controlDown = aWxEvent.ControlDown() ! aWxEvent.shiftDown = aWxEvent.ShiftDown() except: pass ! try: ! # key events ! aWxEvent.keyCode = aWxEvent.GetKeyCode() ! except: ! pass ! if issubclass(self.wxEventIdMap[eventType], event.CommandTypeEvent): ! # could be command, so need to report the name ! # for the handler if it exists ! if self.command: ! eventName = 'command' ! elif eventType == event.MouseMoveEvent.id: ! # check to see if this is a mouseDrag ! if aWxEvent.Dragging(): ! eventType = event.MouseDragEvent.id ! # don't need this if all event types have unique ids ! #eventName = event.MouseDragEvent.name ! ! # TextField specific stuff ! # the question is how we either call the generic stuff above ! # due to the try/except blocks this code would probably ! # work in the generic event handling but that would be unclean <wink> ! if eventType == wx.wxEVT_SET_FOCUS: ! try: ! aWxEvent.target.DiscardEdits() ! except: ! pass ! elif eventType == wx.wxEVT_KILL_FOCUS: ! try: ! # only wxTextCtrl and wxRightTextCtrl should have IsModified ! # so an exception will be thrown and the event won't be posted ! # for other components, but they shouldn't be binding to these ! # handlers anyway, so I'm just be overly defensive ! # same with DiscardEdits() above ! #modified = obj.IsModified() ! if aWxEvent.target.IsModified(): ! #closeFieldEvent = aWxEvent.Clone() ! #closeFieldEvent.SetEventType(event.wxEVT_CLOSE_FIELD) ! # should I be using wx.PyEvent() instead? ! closeFieldEvent = wx.WindowCreateEvent() ! closeFieldEvent.SetEventType(wxEVT_CLOSE_FIELD) ! closeFieldEvent.SetEventObject(aWxEvent.target) ! closeFieldEvent.SetId(aWxEvent.GetId()) ! closeFieldEvent.SetTimestamp(aWxEvent.GetTimestamp()) ! # this is what Robin suggested instead, see: ! # http://aspn.activestate.com/ASPN/Mail/Message/wxPython-users/1103427 ! #obj.GetParent().GetEventHandler().ProcessEvent(closeFieldEvent) ! # KEA 2004-04-30 ! # ProcessEvent will cause closeField to occur before loseFocus and ! # gainFocus messages, so should we do a wxCallAfter instead? ! # in the case of fields should closeField be an InsteadOfTypeEvent ! # and replace the loseFocus event? probably not since they mean ! # different things ! aWxEvent.target.GetEventHandler().ProcessEvent(closeFieldEvent) ! #wx.PostEvent(obj.GetParent(), evt) ! #print 'posted closeField' ! except: ! pass ! ! ! ! if not eventName: ! eventName = self.wxEventIdMap[eventType].name ! ! # it shouldn't be possible to be in _dispatch for an event ! # that wasn't bound above, but just in case... ! handler = self.eventIdToHandler.get(eventType, None) ! if handler: ! event.EventQueue()._impl.eventOccurred2(eventName, self.name, True) ! if 0: ! print "dispatching", handler._name ! # make a lowercase alias ! aWxEvent.skip = aWxEvent.Skip ! ! # the event handlers are part of the Background so ! # we have to have a reference to call the handler below ! background = self.GetParent().GetParent() ! ! # this is what is in event.py ! # aHandler.getFunction()( aOwner, self.getSource(), self ) ! handler.getFunction()(background, aWxEvent) ! ! # do we have to clean up this alias? ! aWxEvent.skip = None ! # how about this local reference to handler? ! handler = None ! background = None else: ! event.EventQueue()._impl.eventOccurred2(eventName, self.name, False) ! # hopefully this is all we need to do for "unused events" ! aWxEvent.Skip() ! # cleanup ! aWxEvent.target = aWxEvent.eventObject = None alignment = property(_getAlignment, _setAlignment) border = property(_getBorder, _setBorder) |
From: Kevin A. <ka...@us...> - 2004-05-01 06:13:42
|
Update of /cvsroot/pythoncard/PythonCard In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29518 Modified Files: event.py Log Message: transition code to new style event bindings and dispatch this is essentially the same code as used by button.py _bindEvents and _dispatch Index: event.py =================================================================== RCS file: /cvsroot/pythoncard/PythonCard/event.py,v retrieving revision 1.57 retrieving revision 1.58 diff -C2 -d -r1.57 -r1.58 *** event.py 30 Apr 2004 23:29:44 -0000 1.57 --- event.py 1 May 2004 06:13:34 -0000 1.58 *************** *** 355,371 **** class KeyPressEvent( Event ) : name = 'keyPress' class KeyDownEvent( Event ) : name = 'keyDown' class KeyUpEvent( Event ) : name = 'keyUp' ! class TextUpdateEvent( Event ) : name = 'textUpdate' ! class TextEnterEvent( Event ) : --- 355,377 ---- class KeyPressEvent( Event ) : name = 'keyPress' + binding = wx.EVT_CHAR + id = wx.wxEVT_CHAR class KeyDownEvent( Event ) : name = 'keyDown' + binding = wx.EVT_KEY_DOWN + id = wx.wxEVT_KEY_DOWN class KeyUpEvent( Event ) : name = 'keyUp' ! binding = wx.EVT_KEY_UP ! id = wx.wxEVT_KEY_UP class TextUpdateEvent( Event ) : name = 'textUpdate' ! binding = wx.EVT_TEXT ! id = wx.wxEVT_COMMAND_TEXT_UPDATED class TextEnterEvent( Event ) : |
From: Kevin A. <ka...@us...> - 2004-05-01 06:09:08
|
Update of /cvsroot/pythoncard/PythonCard/samples/widgets In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28900 Modified Files: widgets.py Log Message: added event.skip to mouseDown and mouseUp handlers as a event bug fix Index: widgets.py =================================================================== RCS file: /cvsroot/pythoncard/PythonCard/samples/widgets/widgets.py,v retrieving revision 1.36 retrieving revision 1.37 diff -C2 -d -r1.36 -r1.37 *** widgets.py 27 Apr 2004 06:07:48 -0000 1.36 --- widgets.py 1 May 2004 06:09:00 -0000 1.37 *************** *** 190,193 **** --- 190,194 ---- print "drag y" self.yOp = DRAG_Y + event.skip() def on_mouseDrag(self, event): *************** *** 237,240 **** --- 238,242 ---- target.SetSize((newWidth, newHeight)) #target._delegate.SetDimensions(xOff, yOff, newWidth, newHeight) + event.skip() |
From: Kevin A. <ka...@us...> - 2004-04-30 23:55:59
|
Update of /cvsroot/pythoncard/PythonCard/components In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8284/components Modified Files: button.py Log Message: transition code to new style event binding and dispatch I don't want to lose this code, so I'm "backing up" to cvs :) note that ImageButton which relies on Button binding has been broken since earlier this week when we started the new style tests Index: button.py =================================================================== RCS file: /cvsroot/pythoncard/PythonCard/components/button.py,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -d -r1.25 -r1.26 *** button.py 27 Apr 2004 02:43:33 -0000 1.25 --- button.py 30 Apr 2004 23:55:49 -0000 1.26 *************** *** 8,12 **** from PythonCard import event, widget ! ButtonEvents = [event.ButtonMouseClickEvent] class ButtonSpec(widget.WidgetSpec): --- 8,17 ---- from PythonCard import event, widget ! class ButtonMouseClickEvent(event.MouseClickEvent): ! binding = wx.EVT_BUTTON ! id = wx.wxEVT_COMMAND_BUTTON_CLICKED ! ! ButtonEvents = (ButtonMouseClickEvent,) ! #ButtonEvents = [ButtonMouseClickEvent] class ButtonSpec(widget.WidgetSpec): *************** *** 14,18 **** # KEA 2004-04-26 # test to use new event classes ! events = ButtonEvents ## events = [event.MouseClickEvent] attributes = { --- 19,24 ---- # KEA 2004-04-26 # test to use new event classes ! events = list(ButtonEvents) ! #events = ButtonEvents ## events = [event.MouseClickEvent] attributes = { *************** *** 47,52 **** self._setDefault(self._resource.default) ! adapter = ButtonEventBinding(self) ! adapter.bindEvents() def _getDefault(self): --- 53,59 ---- self._setDefault(self._resource.default) ! #adapter = ButtonEventBinding(self) ! #adapter.bindEvents() ! self._bindEvents() def _getDefault(self): *************** *** 74,77 **** --- 81,305 ---- pass + def _bindEvents(self): + # shouldn't components be subclasses of Scriptable? + # components would have their own handlers but when + # looking for a handler match it will search the parents + # for now just grab handlers from the background + background = self.GetParent().GetParent() + + # where should this check go? + # should we just set a "global" in the app instance such as + # self.stack.app.bindUnusedEvents + # this kind of thing isn't going to work for Rowland's compound + # components + if background.stack.app._showDebugMenu: + bindUnusedEvents = True + else: + bindUnusedEvents = False + + # helper variable to simplify test for whether to bind InsteadOfTypeEvents + boundEvents = {} + + self.eventIdToHandler = {} + self.wxEventIdMap = {} + + if 0: + print "\nBINDING...", self.name + + for eventClass in event.WIDGET_EVENTS + ButtonEvents: + #for eventClass in ButtonEvents: + # need to figure out a way to avoid the need + # for this id to class mapping which is used in _dispatch below + self.wxEventIdMap[eventClass.id] = eventClass + # command handler overrides normal mouseClick or select handler + # so dispatch will automatically dispatch to the command handler + # by looking up the handler this way + # it also means that if there is a command association with this component + # then the regular mouseClick or select handler will never be bound, just ignored + if issubclass(eventClass, event.CommandTypeEvent) and self.command: + handler = background.findHandler('on_' + self.command + '_command') + if not handler: + handler = background.findHandler('on_' + self.name + '_' + eventClass.name) + else: + handler = background.findHandler('on_' + self.name + '_' + eventClass.name) + if not handler: + handler = background.findHandler('on_' + eventClass.name) + if handler or bindUnusedEvents: + # only bind events that have an event handler + # in this scenario unused events are never bound + # which is more efficient, but the Message Watcher needs + # to be changed + # alternatively we can bind everything and then in _dispatch + # if there isn't a match in eventIdToHandler then we know + # the event isn't used and we can set used to False + # the complication would be that we probably have to have to + # always call Skip() which may or may not be a hassle with components + + # this doesn't bind command events + # they would be of the form on_somename_command + # or perhaps on_command but I don't think we would want + # to support that + # the event binding would be specific to a component + # since on dispatch command overrides something like mouseClickEvent + # but the name of the command is not related to the component + # need to look at whether self.command has a value and then bind + # with ButtonMouseClickEvent.binding if that isn't already bound + # then in dispatch have to check again I think + + # need to avoid double binding + # also binding shouldn't be order-specific + # so how to avoid binding mouseDrag to _dispatch + # if mouseMove is already bound or if binding mouseMove + # not rebinding if mouseDrag is already bound + # perhaps MouseDragEvent keeps a reference to MouseMoveEvent + # and that is inserted into boundEvents, then we check boundEvents + # prior to rebinding? + if not boundEvents.get(eventClass.binding, None): + self.Bind(eventClass.binding, self._dispatch) + boundEvents[eventClass.binding] = eventClass.name + if handler: + if 0: + print " binding", self.name, eventClass.name, handler._name, eventClass.id + self.eventIdToHandler[eventClass.id] = handler + + if 0: + print "\n boundEvents:" + for name in boundEvents.values(): + print " ", name + print "\n\n" + print "\n self.eventIdToHandler:" + for id in self.eventIdToHandler: + print " ", id, self.eventIdToHandler[id]._function + print "\n\n" + boundEvents = None + + # this is pretty generic, but Button doesn't have any specific + # handling that is required so I need to do the same kind of code + # for TextField and see what the special handling for gainFocus, + # loseFocus, closeField will look like + # it probably won't need special handling for the key events + def _dispatch(self, aWxEvent): + eventType = aWxEvent.GetEventType() + + eventName = None + + if eventType == wx.wxEVT_TIMER: + aWxEvent.interval = aWxEvent.GetInterval() + # wxPython 2.5.1.5 workaround + # for some reason wx.TimerEvent does not contain the event target + # so we have to set it ourselves + aWxEvent.target = aWxEvent.eventObject = self + else: + try: + # all events should have GetEventObject() + # except of course for wx.TimerEvent above + # KEA 2004-04-25 + # should we remove this redundant identifier? + aWxEvent.target = aWxEvent.eventObject = self + except: + pass + # Each of these could check the event class like + # wxListEvent and wxTreeEvent above. + try: + # mouse and key events + aWxEvent.position = tuple(aWxEvent.GetPosition()) + aWxEvent.x = aWxEvent.GetX() + aWxEvent.y = aWxEvent.GetY() + aWxEvent.altDown = aWxEvent.AltDown() + aWxEvent.controlDown = aWxEvent.ControlDown() + aWxEvent.shiftDown = aWxEvent.ShiftDown() + except: + pass + try: + # key events + aWxEvent.keyCode = aWxEvent.GetKeyCode() + except: + pass + if issubclass(self.wxEventIdMap[eventType], event.CommandTypeEvent): + # could be command, so need to report the name + # for the handler if it exists + if self.command: + eventName = 'command' + elif eventType == event.MouseMoveEvent.id: + # check to see if this is a mouseDrag + if aWxEvent.Dragging(): + eventType = event.MouseDragEvent.id + # don't need this if all event types have unique ids + #eventName = event.MouseDragEvent.name + + # the component-specific helper attributes below + # should be handled in the relevant component _dispatch + # not the generic one + """ + if eventType in [wx.wxEVT_COMMAND_LIST_KEY_DOWN, + wx.wxEVT_COMMAND_TREE_KEY_DOWN]: + try: + # key events are different for wxTreeCtrl and wxListCtrl + aWxEvent.keyCode = aWxEvent.GetCode() + except: + pass + try: + # wxListEvent doesn't have GetKeyEvent for some reason + keyEvent = aWxEvent.GetKeyEvent() + aWxEvent.altDown = keyEvent.AltDown() + aWxEvent.controlDown = keyEvent.ControlDown() + aWxEvent.shiftDown = keyEvent.ShiftDown() + except: + pass + elif eventType in [wx.wxEVT_COMMAND_TREE_BEGIN_DRAG, \ + wx.wxEVT_COMMAND_TREE_BEGIN_RDRAG, \ + wx.wxEVT_COMMAND_TREE_END_DRAG, \ + wx.wxEVT_COMMAND_LIST_BEGIN_DRAG, \ + wx.wxEVT_COMMAND_LIST_BEGIN_RDRAG, \ + wx.wxEVT_COMMAND_LIST_COL_BEGIN_DRAG, \ + wx.wxEVT_COMMAND_LIST_COL_DRAGGING, \ + wx.wxEVT_COMMAND_LIST_COL_END_DRAG]: + try: + # The mouse position during a drag event + # there doesn't appear to be a way of getting the + # state of the shift, alt, and control keys + # during a mouse drag. + aWxEvent.position = tuple(aWxEvent.GetPoint()) + aWxEvent.x = aWxEvent.position[0] + aWxEvent.y = aWxEvent.position[1] + except: + pass + """ + + if not eventName: + eventName = self.wxEventIdMap[eventType].name + + # it shouldn't be possible to be in _dispatch for an event + # that wasn't bound above, but just in case... + handler = self.eventIdToHandler.get(eventType, None) + if handler: + event.EventQueue()._impl.eventOccurred2(eventName, self.name, True) + if 0: + print "dispatching", handler._name + # make a lowercase alias + aWxEvent.skip = aWxEvent.Skip + + # the event handlers are part of the Background so + # we have to have a reference to call the handler below + background = self.GetParent().GetParent() + + # this is what is in event.py + # aHandler.getFunction()( aOwner, self.getSource(), self ) + handler.getFunction()(background, aWxEvent) + + # do we have to clean up this alias? + aWxEvent.skip = None + # how about this local reference to handler? + handler = None + background = None + else: + event.EventQueue()._impl.eventOccurred2(eventName, self.name, False) + # hopefully this is all we need to do for "unused events" + aWxEvent.Skip() + + # cleanup + aWxEvent.target = aWxEvent.eventObject = None + + default = property(_getDefault, _setDefault) label = property(wx.Button.GetLabel, wx.Button.SetLabel) |
From: Kevin A. <ka...@us...> - 2004-04-30 23:51:11
|
Update of /cvsroot/pythoncard/PythonCard In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7713 Modified Files: flatfileDatabase.py Log Message: I think loseFocus should be calling event.skip, so I added it Index: flatfileDatabase.py =================================================================== RCS file: /cvsroot/pythoncard/PythonCard/flatfileDatabase.py,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** flatfileDatabase.py 24 Apr 2004 22:13:14 -0000 1.21 --- flatfileDatabase.py 30 Apr 2004 23:51:03 -0000 1.22 *************** *** 840,844 **** self.saveFocus(event.target) ! #event.Skip() def on_findRecord_command(self, event): --- 840,844 ---- self.saveFocus(event.target) ! event.skip() def on_findRecord_command(self, event): |