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: Alex T. <ale...@us...> - 2004-09-30 23:05:06
|
Update of /cvsroot/pythoncard/PythonCard/components In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17777/components Modified Files: textarea.py Log Message: Added horizontalScrollbar to TextArea, updated ResourceEditor to include it. Index: textarea.py =================================================================== RCS file: /cvsroot/pythoncard/PythonCard/components/textarea.py,v retrieving revision 1.28 retrieving revision 1.29 diff -C2 -d -r1.28 -r1.29 *** textarea.py 28 Sep 2004 14:41:50 -0000 1.28 --- textarea.py 30 Sep 2004 23:04:52 -0000 1.29 *************** *** 22,25 **** --- 22,26 ---- 'alignment' : {'presence' : 'optional', 'default' : 'left', 'values' :['left', 'right', 'center']}, 'border' : {'presence' : 'optional', 'default' : '3d', 'values' : ['3d', 'none']}, + 'horizontalScrollbar' : {'presence' : 'optional', 'default' : False}, 'size' : { 'presence' : 'optional', 'default' : [ -1, 50 ] }, } *************** *** 34,39 **** def __init__( self, aParent, aResource ) : self._border = aResource.border - if aResource.border == 'none': borderStyle = wx.NO_BORDER --- 35,45 ---- def __init__( self, aParent, aResource ) : + self._horizontalScrollbar = aResource.horizontalScrollbar + if aResource.horizontalScrollbar: + hScroll = wx.HSCROLL + else: + hScroll = 0 + self._border = aResource.border if aResource.border == 'none': borderStyle = wx.NO_BORDER *************** *** 54,58 **** ## style = wx.TE_RICH2 | wx.TE_PROCESS_TAB | wx.TE_MULTILINE | borderStyle | \ style = wx.TE_RICH2 | wx.TE_MULTILINE | borderStyle | \ ! textfield.getAlignment(aResource.alignment) | \ wx.NO_FULL_REPAINT_ON_RESIZE | wx.CLIP_SIBLINGS, name = aResource.name ) --- 60,64 ---- ## style = wx.TE_RICH2 | wx.TE_PROCESS_TAB | wx.TE_MULTILINE | borderStyle | \ style = wx.TE_RICH2 | wx.TE_MULTILINE | borderStyle | \ ! textfield.getAlignment(aResource.alignment) | hScroll |\ wx.NO_FULL_REPAINT_ON_RESIZE | wx.CLIP_SIBLINGS, name = aResource.name ) *************** *** 112,115 **** --- 118,128 ---- text = property(_getText, wx.TextCtrl.SetValue) + def _getHorizontalScrollbar( self ) : + return self._horizontalScrollbar + + def _setHorizontalScrollbar ( self, aBool ) : + raise AttributeError, "horizontalScrollbar attribute is read-only" + + horizontalScrollbar = property(_getHorizontalScrollbar, _setHorizontalScrollbar) import sys |
From: Alex T. <ale...@us...> - 2004-09-30 23:05:06
|
Update of /cvsroot/pythoncard/PythonCard/docs In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17777/docs Modified Files: changelog.txt Log Message: Added horizontalScrollbar to TextArea, updated ResourceEditor to include it. Index: changelog.txt =================================================================== RCS file: /cvsroot/pythoncard/PythonCard/docs/changelog.txt,v retrieving revision 1.310 retrieving revision 1.311 diff -C2 -d -r1.310 -r1.311 *** changelog.txt 28 Sep 2004 14:44:04 -0000 1.310 --- changelog.txt 30 Sep 2004 23:04:52 -0000 1.311 *************** *** 8,11 **** --- 8,12 ---- Release 0.8.1 2004-10-?? + added horizontalScrollbar flag to TextArea component added appendText ScrollLines workaround to TextArea component on Windows added lexicon and pattern files downloading to life sample |
From: Alex T. <ale...@us...> - 2004-09-30 23:05:06
|
Update of /cvsroot/pythoncard/PythonCard/tools/resourceEditor/modules In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17777/tools/resourceEditor/modules Modified Files: propertyEditor.py resourceOutput.py Log Message: Added horizontalScrollbar to TextArea, updated ResourceEditor to include it. Index: propertyEditor.py =================================================================== RCS file: /cvsroot/pythoncard/PythonCard/tools/resourceEditor/modules/propertyEditor.py,v retrieving revision 1.54 retrieving revision 1.55 diff -C2 -d -r1.54 -r1.55 *** propertyEditor.py 15 Sep 2004 17:43:29 -0000 1.54 --- propertyEditor.py 30 Sep 2004 23:04:53 -0000 1.55 *************** *** 184,190 **** def updateComponent(self): # make these attributes of self, since they are duplicated below in displayProperty ! checkItems = ['enabled', 'visible', 'editable', 'checked', 'default', 'rules', 'labels', 'ticks'] popItems = ['layout', 'border', 'style', 'alignment', 'stringSelection'] ! cantmodify = ['id', 'name', 'alignment', 'layout', 'style', 'border', \ 'min', 'max', 'columns', 'rules', 'labels', 'ticks'] --- 184,190 ---- def updateComponent(self): # make these attributes of self, since they are duplicated below in displayProperty ! checkItems = ['enabled', 'visible', 'editable', 'checked', 'default', 'rules', 'labels', 'ticks', 'horizontalScrollbar'] popItems = ['layout', 'border', 'style', 'alignment', 'stringSelection'] ! cantmodify = ['id', 'name', 'alignment', 'layout', 'style', 'border', 'horizontalScrollbar', \ 'min', 'max', 'columns', 'rules', 'labels', 'ticks'] *************** *** 358,362 **** def displayProperty(self, wName, wClass, propName): ! checkItems = ['enabled', 'visible', 'editable', 'checked', 'default', 'rules', 'labels', 'ticks'] popItems = ['layout', 'border', 'style', 'alignment', 'stringSelection'] --- 358,362 ---- def displayProperty(self, wName, wClass, propName): ! checkItems = ['enabled', 'visible', 'editable', 'checked', 'default', 'rules', 'labels', 'ticks', 'horizontalScrollbar'] popItems = ['layout', 'border', 'style', 'alignment', 'stringSelection'] Index: resourceOutput.py =================================================================== RCS file: /cvsroot/pythoncard/PythonCard/tools/resourceEditor/modules/resourceOutput.py,v retrieving revision 1.29 retrieving revision 1.30 diff -C2 -d -r1.29 -r1.30 *** resourceOutput.py 16 Aug 2004 20:26:13 -0000 1.29 --- resourceOutput.py 30 Sep 2004 23:04:53 -0000 1.30 *************** *** 101,105 **** else: if (key in ['editable', 'enabled', 'visible'] and value == True) or \ ! (key in ['checked', 'default'] and value == False): # don't include default values pass --- 101,105 ---- else: if (key in ['editable', 'enabled', 'visible'] and value == True) or \ ! (key in ['checked', 'default', 'horizontalScrollbar'] and value == False): # don't include default values pass |
From: Kevin A. <ka...@us...> - 2004-09-30 21:16:35
|
Update of /cvsroot/pythoncard/PythonCard/tools/resourceEditor In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25956/tools/resourceEditor Modified Files: resourceEditor.py Log Message: compensate for spinner offset on Windows Index: resourceEditor.py =================================================================== RCS file: /cvsroot/pythoncard/PythonCard/tools/resourceEditor/resourceEditor.py,v retrieving revision 1.218 retrieving revision 1.219 diff -C2 -d -r1.218 -r1.219 *** resourceEditor.py 25 Sep 2004 16:14:21 -0000 1.218 --- resourceEditor.py 30 Sep 2004 21:16:24 -0000 1.219 *************** *** 473,476 **** --- 473,480 ---- self.startGlobalOffset = [self.startGlobalOffset[0] + wx.SystemSettings.GetMetric(wx.SYS_BORDER_X), self.startGlobalOffset[1] + wx.SystemSettings.GetMetric(wx.SYS_BORDER_Y)] + elif t == 'Spinner': + # compensate for width of TextCtrl portion of + # compound control - width of arrow buttons + self.startGlobalOffset[0] += target.size[0] - 16 elif wx.Platform == "__WXMAC__": # KEA 2004-07-27 |
From: Kevin A. <ka...@us...> - 2004-09-28 21:24:35
|
Update of /cvsroot/pythoncard/PythonCard In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18704 Modified Files: model.py Log Message: added SplitterBackground Index: model.py =================================================================== RCS file: /cvsroot/pythoncard/PythonCard/model.py,v retrieving revision 1.189 retrieving revision 1.190 diff -C2 -d -r1.189 -r1.190 *** model.py 25 Sep 2004 15:37:40 -0000 1.189 --- model.py 28 Sep 2004 21:24:24 -0000 1.190 *************** *** 1191,1194 **** --- 1191,1250 ---- + # KEA 2004-09-28 + # it appears that if you are going to use splitters + # you can't just put them a wx.Panel within a wx.Frame + # so the SplitterBackground has no self.panel + # and the question becomes how are the various splitter + # combinations specified? + # when the PageBackground children are created, they + # will need to use the correct splitters as parents + class SplitterBackground(Background): + def _initLayout(self, aResourceList): + # should we just set self.panel = self instead?! + self.panel = None + + # KEA 2001-07-31 + # we may want to put this someplace else, but we do need access + # to the componenet list + def findFocus(self): + # the wxPython widget that has focus + widgetWX = wx.Window_FindFocus() + if widgetWX is None: + return None + else: + # KEA 2004-09-28 + # this needs to iterate through the splitters + # children correctly and my brain hurts + # too much from getting splitters working + # to fix this ;-) + for widget in self.components.itervalues(): + if widgetWX == widget: + return widget + # is this even possible? focus in another window maybe? + return None + + # these really don't have any purpose within the + # context of a SplitterBackground + # but I'll leave them here for now + + # there are probably additional references in Background to self.panel + # that also need overriding methods here + + def _getBackgroundColor(self): + return self.GetBackgroundColour() + + def _setBackgroundColor(self, aColor): + self.SetBackgroundColour(aColor) + + def _getForegroundColor(self): + return self.GetForegroundColour() + + def _setForegroundColor(self, aColor): + self.SetForegroundColour(aColor) + + backgroundColor = property(_getBackgroundColor, _setBackgroundColor, doc="backgroundColor of the background") + foregroundColor = property(_getForegroundColor, _setForegroundColor, doc="foregroundColor of the background") + + PageBackgroundEvents = ( ## ActivateEvent, |
Update of /cvsroot/pythoncard/PythonCard/samples/testSplitter In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18557 Added Files: .cvsignore doodle.py doodle.rsrc.py minimal.py minimal.rsrc.py readme.txt testSplitter.py testSplitter.rsrc.py Log Message: added testSplitter sample --- NEW FILE: .cvsignore --- .cvsignore *.pyc *.log .DS_Store --- NEW FILE: doodle.py --- #!/usr/bin/python """ __version__ = "$Revision: 1.1 $" __date__ = "$Date: 2004/09/28 21:23:55 $" """ from PythonCard import clipboard, dialog, graphic, model import wx import os class Doodle(model.PageBackground): def on_initialize(self, event): self.x = 0 self.y = 0 self.filename = None self.initSizers() def initSizers(self): sizer1 = wx.BoxSizer(wx.VERTICAL) comp = self.components flags = wx.LEFT | wx.RIGHT | wx.BOTTOM | wx.ALIGN_BOTTOM # Mac wxButton needs 7 pixels on bottom and right macPadding = 7 sizer1.Add(comp.btnColor, 0, flags, macPadding) sizer1.Add(comp.bufOff, 1, wx.EXPAND) sizer1.Fit(self) sizer1.SetSizeHints(self) self.panel.SetSizer(sizer1) self.panel.SetAutoLayout(1) self.panel.Layout() def on_bufOff_mouseEnter(self, event): self.x, self.y = event.position def on_bufOff_mouseDown(self, event): self.x, self.y = event.position event.target.drawLine((self.x, self.y), (self.x + 1, self.y + 1)) def on_bufOff_mouseDrag(self, event): x, y = event.position event.target.drawLine((self.x, self.y), (x, y)) self.x = x self.y = y def on_btnColor_mouseClick(self, event): result = dialog.colorDialog(self) if result.accepted: self.components.bufOff.foregroundColor = result.color event.target.backgroundColor = result.color def openFile(self): result = dialog.openFileDialog(None, "Import which file?") if result.accepted: path = result.paths[0] os.chdir(os.path.dirname(path)) self.filename = path bmp = graphic.Bitmap(self.filename) self.components.bufOff.drawBitmap(bmp, (0, 0)) 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) result = dialog.saveFileDialog(None, "Save As", path, filename) if result.accepted: path = result.paths[0] fileType = graphic.bitmapType(path) print fileType, 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() if __name__ == '__main__': app = model.Application(Doodle) app.MainLoop() --- NEW FILE: testSplitter.rsrc.py --- { 'application':{ 'type':'Application', 'name':'Doodle', 'backgrounds': [ { 'type':'Background', 'name':'bgDoodle', 'title':'Doodle PythonCard Application', 'size':( 310, 200 ), 'style':['resizeable'], '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', 'command':'exit' } ] }, { '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': [ ] } ] } } --- NEW FILE: readme.txt --- Until we have a Splitter integrated into some of the other samples or tools this will serve as a basic test app, but I don't expect to include it in releases. There should be variations testing all the splitter varieties we're going to support. Instead of minimal I was thinking about something more complicated involving the Tree component, List, or MultiColumnList in the left pane. Perhaps this would also be a good place to test a virtual MultiColumnList, perhaps doing a file list and displaying an image in the top-right pane and EXIF info in the bottom-right or something like that. Anyway, we need a more complicated example to work through issues about how these things are going to work. I suppose we could have yet another RSS reader any other ideas? --- NEW FILE: minimal.rsrc.py --- { 'application':{ 'type':'Application', 'name':'Minimal', 'backgrounds': [ { 'type':'Background', 'name':'bgMin', 'title':'Minimal PythonCard Application', 'size':( 200, 100 ), 'menubar': { 'type':'MenuBar', 'menus': [ { 'type':'Menu', 'name':'menuFile', 'label':'&File', 'items': [ { 'type':'MenuItem', 'name':'menuFileExit', 'label':'E&xit\tAlt+X', 'command':'exit' } ] } ] }, 'components': [ { 'type':'TextField', 'name':'field1', 'position':(5, 5), 'size':(150, -1), 'text':'Hello PythonCard' }, ] } ] } } --- NEW FILE: doodle.rsrc.py --- { 'application':{ 'type':'Application', 'name':'Doodle', 'backgrounds': [ { 'type':'Background', 'name':'bgDoodle', 'title':'Doodle PythonCard Application', 'size':( 310, 300 ), 'style':['resizeable'], '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', 'command':'exit' } ] }, { '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':'Button', 'name':'btnColor', 'position':(0, 0), 'label':'Color' }, { 'type':'BitmapCanvas', 'name':'bufOff', 'position':(0, 30), 'size':(300, 230) }, ] } ] } } --- NEW FILE: minimal.py --- #!/usr/bin/python """ __version__ = "$Revision: 1.1 $" __date__ = "$Date: 2004/09/28 21:23:55 $" """ from PythonCard import model class Minimal(model.PageBackground): pass if __name__ == '__main__': app = model.Application(Minimal) app.MainLoop() --- NEW FILE: testSplitter.py --- #!/usr/bin/python """ __version__ = "$Revision: 1.1 $" __date__ = "$Date: 2004/09/28 21:23:55 $" """ from PythonCard import clipboard, dialog, graphic, model import wx import os import minimal import doodle # minimalist panel that works like PageBackground # for testing purposes class MyPanel(wx.Panel): def __init__(self, aParent, size, name): wx.Panel.__init__(self, aParent, -1, size=size, name=name) self.panel = wx.Panel(self, -1, style=wx.TAB_TRAVERSAL | wx.NO_FULL_REPAINT_ON_RESIZE) self.field1 = wx.TextCtrl(self, -1, 'Hello World') self._sizer = wx.BoxSizer(wx.VERTICAL) self._sizer.Add(self.panel, True, wx.EXPAND) self._sizer.Fit(self) self._sizer.SetSizeHints(self) self.SetSizer(self._sizer) self.Layout() class TestSplitter(model.SplitterBackground): def on_initialize(self, event): # the splitter code is adapted from the wxPython demo Main.py # I was having to do RemoveChild with Background # but SplitterBackground seems okay ## self.RemoveChild(self.panel) ## self.panel = None splitter = wx.SplitterWindow(self, -1, style=wx.CLIP_CHILDREN | wx.SP_LIVE_UPDATE | wx.SP_3D) splitter2 = wx.SplitterWindow(splitter, -1, style=wx.CLIP_CHILDREN | wx.SP_LIVE_UPDATE | wx.SP_3D) self.splitter = splitter self.splitter2 = splitter2 win1 = MyPanel(splitter, (100, 50), 'win1') #win1 = model.childWindow(splitter, doodle.Doodle) win1 = model.childWindow(splitter, minimal.Minimal) #win2 = model.childWindow(splitter, minimal.Minimal) #win2 = MyPanel(splitter, (100, 50), 'win2') win2 = model.childWindow(splitter2, doodle.Doodle) #win2 = model.childWindow(splitter2, minimal.Minimal) win3 = model.childWindow(splitter2, doodle.Doodle) self.win1 = win1 self.win2 = win2 self.win3 = win3 # add the windows to the splitter and split it. splitter2.SplitHorizontally(win2, win3, 160) splitter.SplitVertically(win1, splitter2, 200) #splitter.SplitVertically(win1, win2, 150) splitter.SetMinimumPaneSize(20) splitter2.SetMinimumPaneSize(20) self.size = (600, 400) # Make the splitter on the right expand the top window when resized def SplitterOnSize(evt): splitter = evt.GetEventObject() sz = splitter.GetSize() splitter.SetSashPosition(sz.height - 160, False) evt.Skip() #splitter2.Bind(wx.EVT_SIZE, SplitterOnSize) """ Doodle methods MAJOR UNRESOLVED ISSUES just like top-level event handlers and methods when dealing with a Notebook how do we want these kinds of methods to work with a SplitterBackground? if the event handlers and methods such as openFile are defined in the top-level parent then they will be found, but rather than references such as self.components.bufOff they would have to make specific references to the child such as self.win3.components.bufOff this makes sense from the standpoint that the associated menus also have to be specified in the top-level Background resource but it would seem to reduce reusability so could we and should we bind and dispatch events such that a child could add menus and menu items from its resource during the initLayout call or something like that? depending on the focus context, events would be directed at the appropriate child. i'm not even sure that is doable. needless to say the containers introduced with Notebook and SplitterBackground are making me worry about PythonCard becoming even more of a confusing hack job than it already is. """ def openFile(self): win = self.findFocus() print win result = dialog.openFileDialog(None, "Import which file?") if result.accepted: path = result.paths[0] os.chdir(os.path.dirname(path)) self.filename = path bmp = graphic.Bitmap(self.filename) #self.components.bufOff.drawBitmap(bmp, (0, 0)) self.win3.components.bufOff.drawBitmap(bmp, (0, 0)) 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) result = dialog.saveFileDialog(None, "Save As", path, filename) if result.accepted: path = result.paths[0] fileType = graphic.bitmapType(path) print fileType, path try: #bmp = self.components.bufOff.getBitmap() bmp = self.win3.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()) clipboard.setClipboard(self.win3.components.bufOff.getBitmap()) def on_menuEditPaste_select(self, event): bmp = clipboard.getClipboard() if isinstance(bmp, wx.Bitmap): #self.components.bufOff.drawBitmap(bmp) self.win3.components.bufOff.drawBitmap(bmp) def on_editClear_command(self, event): #self.components.bufOff.clear() self.win3.components.bufOff.clear() if __name__ == '__main__': app = model.Application(TestSplitter) app.MainLoop() |
From: Kevin A. <ka...@us...> - 2004-09-28 21:09:05
|
Update of /cvsroot/pythoncard/PythonCard/samples/testSplitter In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15405/testSplitter Log Message: Directory /cvsroot/pythoncard/PythonCard/samples/testSplitter added to the repository |
From: Kevin A. <ka...@us...> - 2004-09-28 16:43:19
|
Update of /cvsroot/pythoncard/PythonCard/samples/gravity In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18240/samples/gravity Modified Files: gravity.py Log Message: fixed yield by switching to wx.SafeYield(self, True) Index: gravity.py =================================================================== RCS file: /cvsroot/pythoncard/PythonCard/samples/gravity/gravity.py,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** gravity.py 26 Sep 2004 00:10:40 -0000 1.4 --- gravity.py 28 Sep 2004 16:43:04 -0000 1.5 *************** *** 107,110 **** --- 107,117 ---- self.initSizers() # go ahead and create one ball to get started + # if you want to stress the animation loop + # uncomment the loop below + # my Win2K box can do approximately 130 balls and still + # maintain 30 (29.9...) FPS, but above that and it starts + # to slow down + ## for i in range(130): + ## self.sprites.append(BallSprite(self.components.bufOff, 20, 20, 15, randomColor())) self.on_btnNewBall_mouseClick(None) *************** *** 113,122 **** sizer2 = wx.BoxSizer(wx.HORIZONTAL) comp = self.components ! flags = wx.LEFT | wx.RIGHT | wx.BOTTOM | wx.ALIGN_BOTTOM ! # Mac wxButton needs 7 pixels on bottom and right ! macPadding = 7 ! sizer2.Add(comp.btnNewBall, 0, flags, macPadding) ! sizer2.Add(comp.btnAnimate, 0, flags, macPadding) ! sizer2.Add(comp.btnStop, 0, flags, macPadding) sizer1.Add(sizer2, 0) sizer1.Add(comp.bufOff, 1, wx.EXPAND) --- 120,128 ---- sizer2 = wx.BoxSizer(wx.HORIZONTAL) comp = self.components ! flags = wx.ALL | wx.ALIGN_CENTER_VERTICAL ! padding = 7 ! sizer2.Add(comp.btnNewBall, 0, flags, padding) ! sizer2.Add(comp.btnAnimate, 0, flags, padding) ! sizer2.Add(comp.btnStop, 0, flags, padding) sizer1.Add(sizer2, 0) sizer1.Add(comp.bufOff, 1, wx.EXPAND) *************** *** 137,140 **** --- 143,147 ---- ball.draw() canvas.redraw() + self.statusBar.text = "Balls: %d" % len(self.sprites) *************** *** 176,180 **** self.statusBar.text = "Average FPS: %.4f Balls: %d" % (frame / (seconds - startTime), len(self.sprites)) # give the user a chance to click Stop ! wx.Yield() def on_btnStop_mouseClick(self, event): --- 183,187 ---- self.statusBar.text = "Average FPS: %.4f Balls: %d" % (frame / (seconds - startTime), len(self.sprites)) # give the user a chance to click Stop ! wx.SafeYield(self, True) def on_btnStop_mouseClick(self, event): |
From: Kevin A. <ka...@us...> - 2004-09-28 14:44:14
|
Update of /cvsroot/pythoncard/PythonCard/docs In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23615/docs Modified Files: changelog.txt Log Message: added appendText ScrollLines workaround to TextArea component on Windows Index: changelog.txt =================================================================== RCS file: /cvsroot/pythoncard/PythonCard/docs/changelog.txt,v retrieving revision 1.309 retrieving revision 1.310 diff -C2 -d -r1.309 -r1.310 *** changelog.txt 25 Sep 2004 21:48:59 -0000 1.309 --- changelog.txt 28 Sep 2004 14:44:04 -0000 1.310 *************** *** 8,11 **** --- 8,13 ---- Release 0.8.1 2004-10-?? + added appendText ScrollLines workaround to TextArea component on Windows + added lexicon and pattern files downloading to life sample added time alias to util.py to use time.time() on Windows, time.clock() on *nix added gravity sample |
From: Kevin A. <ka...@us...> - 2004-09-28 14:42:13
|
Update of /cvsroot/pythoncard/PythonCard/components In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23010/components Modified Files: textarea.py Log Message: added AppendText ScrollLines workaround for Windows Index: textarea.py =================================================================== RCS file: /cvsroot/pythoncard/PythonCard/components/textarea.py,v retrieving revision 1.27 retrieving revision 1.28 diff -C2 -d -r1.27 -r1.28 *** textarea.py 25 Sep 2004 03:21:20 -0000 1.27 --- textarea.py 28 Sep 2004 14:41:50 -0000 1.28 *************** *** 75,78 **** --- 75,89 ---- # wxPython 2.5.1.5 workaround if wx.Platform == '__WXMSW__': + + def appendText(self, aString): + """Appends the text to the end of the text widget. + After the text is appended, the insertion point will be at the end + of the text widget. If this behavior is not desired, the programmer + should use getInsertionPoint and setInsertionPoint.""" + self.AppendText(aString) + # workaround for scroll bug + # http://sourceforge.net/tracker/?func=detail&aid=665381&group_id=9863&atid=109863 + self.ScrollLines(-1) + # KEA 2004-04-19 # workaround Windows bug where control is shown *************** *** 98,102 **** # returning text with \r instead of \n def _getText(self): ! return self.GetValue().replace('\r', '\n') text = property(_getText, wx.TextCtrl.SetValue) --- 109,113 ---- # returning text with \r instead of \n def _getText(self): ! return "\n".join(self.GetValue().splitlines()) text = property(_getText, wx.TextCtrl.SetValue) |
From: Kevin A. <ka...@us...> - 2004-09-28 05:09:09
|
Update of /cvsroot/pythoncard/PythonCard/samples/life In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7284 Modified Files: lexicon.py patterns.py Log Message: and yet another menu item tweak Index: lexicon.py =================================================================== RCS file: /cvsroot/pythoncard/PythonCard/samples/life/lexicon.py,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** lexicon.py 28 Sep 2004 05:00:25 -0000 1.17 --- lexicon.py 28 Sep 2004 05:08:54 -0000 1.18 *************** *** 99,103 **** self.components.fldDescription.lineNumbersVisible = False self.components.fldDescription.setEditorStyle('text') ! self.lexiconPath = self.GetParent().lexiconPath self.populatePatternsList() --- 99,103 ---- self.components.fldDescription.lineNumbersVisible = False self.components.fldDescription.setEditorStyle('text') ! self.lexiconPath = self.getParent().lexiconPath self.populatePatternsList() *************** *** 114,117 **** --- 114,119 ---- # now simulate the user doing a selection self.on_lstPatterns_select(None) + self.getParent().menuBar.setEnabled('menuAutomataLexicon', True) + self.visible = True def loadPattern(self, name): Index: patterns.py =================================================================== RCS file: /cvsroot/pythoncard/PythonCard/samples/life/patterns.py,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** patterns.py 28 Sep 2004 05:00:26 -0000 1.16 --- patterns.py 28 Sep 2004 05:08:54 -0000 1.17 *************** *** 21,25 **** self.components.fldDescription.lineNumbersVisible = 0 self.components.fldDescription.setEditorStyle('text') ! self.patternsPath = self.GetParent().patternsPath self.populatePatternsList() --- 21,25 ---- self.components.fldDescription.lineNumbersVisible = 0 self.components.fldDescription.setEditorStyle('text') ! self.patternsPath = self.getParent().patternsPath self.populatePatternsList() |
From: Kevin A. <ka...@us...> - 2004-09-28 05:05:19
|
Update of /cvsroot/pythoncard/PythonCard/samples/life In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6597 Modified Files: life.py Log Message: lexicon.txt fix Index: life.py =================================================================== RCS file: /cvsroot/pythoncard/PythonCard/samples/life/life.py,v retrieving revision 1.45 retrieving revision 1.46 diff -C2 -d -r1.45 -r1.46 *** life.py 28 Sep 2004 05:00:26 -0000 1.45 --- life.py 28 Sep 2004 05:05:08 -0000 1.46 *************** *** 67,72 **** basePath = self.application.applicationDirectory self.lexiconPath = os.path.join(self.configPath, 'lexicon.txt') ! if not os.path.exists(self.lexiconPath): ! shutil.copy2(os.path.join(basePath, 'lexicon.txt'), self.lexiconPath) self.patternsPath = os.path.join(self.configPath, 'patterns') if not os.path.exists(self.patternsPath): --- 67,77 ---- basePath = self.application.applicationDirectory self.lexiconPath = os.path.join(self.configPath, 'lexicon.txt') ! try: ! if not os.path.exists(self.lexiconPath): ! shutil.copy2(os.path.join(basePath, 'lexicon.txt'), self.lexiconPath) ! except: ! # currently lexicon.txt is not part of the distribution ! # but it might be in the future ! pass self.patternsPath = os.path.join(self.configPath, 'patterns') if not os.path.exists(self.patternsPath): |
From: Kevin A. <ka...@us...> - 2004-09-28 05:00:45
|
Update of /cvsroot/pythoncard/PythonCard/samples/life In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5502 Modified Files: lexicon.py life.py life.rsrc.py patterns.py util.py Log Message: added downloading for lexicon and patterns added config directory support Index: lexicon.py =================================================================== RCS file: /cvsroot/pythoncard/PythonCard/samples/life/lexicon.py,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** lexicon.py 8 Aug 2004 18:07:43 -0000 1.16 --- lexicon.py 28 Sep 2004 05:00:25 -0000 1.17 *************** *** 32,38 **** """ ! def readLexiconFile(): try: ! fp = open('lexicon.txt') data = fp.readlines() fp.close() --- 32,38 ---- """ ! def readLexiconFile(path): try: ! fp = open(path) data = fp.readlines() fp.close() *************** *** 99,106 **** self.components.fldDescription.lineNumbersVisible = False self.components.fldDescription.setEditorStyle('text') self.populatePatternsList() def populatePatternsList(self): ! self.lexicon = readLexiconFile() if self.lexicon is None: self.getParent().menuBar.setEnabled('menuAutomataLexicon', False) --- 99,107 ---- self.components.fldDescription.lineNumbersVisible = False self.components.fldDescription.setEditorStyle('text') + self.lexiconPath = self.GetParent().lexiconPath self.populatePatternsList() def populatePatternsList(self): ! self.lexicon = readLexiconFile(self.lexiconPath) if self.lexicon is None: self.getParent().menuBar.setEnabled('menuAutomataLexicon', False) Index: life.py =================================================================== RCS file: /cvsroot/pythoncard/PythonCard/samples/life/life.py,v retrieving revision 1.44 retrieving revision 1.45 diff -C2 -d -r1.44 -r1.45 *** life.py 28 Sep 2004 03:12:55 -0000 1.44 --- life.py 28 Sep 2004 05:00:26 -0000 1.45 *************** *** 12,22 **** pass - from PythonCard import clipboard, dialog, graphic, model, util - import wx import os, sys from patterns import Patterns from lexicon import Lexicon - from util import readLifeFile, translateClipboardPattern, placePattern, neighborsTuple --- 12,23 ---- pass import os, sys + import shutil + import wx + import util as lifeutil + from PythonCard import clipboard, configuration, dialog, graphic, model, util from patterns import Patterns from lexicon import Lexicon *************** *** 24,27 **** --- 25,29 ---- def on_initialize(self, event): + self.createConfigDir() self.filename = None *************** *** 59,62 **** --- 61,80 ---- self.panel.Layout() + def createConfigDir(self): + self.configPath = os.path.join(configuration.homedir, 'life') + if not os.path.exists(self.configPath): + os.mkdir(self.configPath) + basePath = self.application.applicationDirectory + self.lexiconPath = os.path.join(self.configPath, 'lexicon.txt') + if not os.path.exists(self.lexiconPath): + shutil.copy2(os.path.join(basePath, 'lexicon.txt'), self.lexiconPath) + self.patternsPath = os.path.join(self.configPath, 'patterns') + if not os.path.exists(self.patternsPath): + os.mkdir(self.patternsPath) + basePath = os.path.join(basePath, 'patterns') + for name in os.listdir(basePath): + if name.lower().endswith('.lif') and not os.path.exists(os.path.join(self.patternsPath, name)): + shutil.copy2(os.path.join(basePath, name), os.path.join(self.patternsPath, name)) + def initGrid(self): # a populated grid has (x, y) tuples for keys *************** *** 120,124 **** for cell in grid: sum = 0 ! #neighbors = neighborsTuple(cell[0], cell[1]) # it is a bit faster to inline this rather than # calling a function --- 138,142 ---- for cell in grid: sum = 0 ! #neighbors = lifeutil.neighborsTuple(cell[0], cell[1]) # it is a bit faster to inline this rather than # calling a function *************** *** 198,202 **** if alive: # make sure neighbors are in grid ! for neighbor in neighborsTuple(col, row): self.grid.setdefault(neighbor, 0) --- 216,220 ---- if alive: # make sure neighbors are in grid ! for neighbor in lifeutil.neighborsTuple(col, row): self.grid.setdefault(neighbor, 0) *************** *** 304,308 **** column = centerX + x - xDiff row = centerY + y - yDiff ! self.grid = placePattern(self.grid, column, row, pattern['rows']) self.displayGeneration() --- 322,326 ---- column = centerX + x - xDiff row = centerY + y - yDiff ! self.grid = lifeutil.placePattern(self.grid, column, row, pattern['rows']) self.displayGeneration() *************** *** 317,321 **** self.filename = path ! description, patterns, topLeft, size = readLifeFile(path) print description print "topLeft:", topLeft, "size", size --- 335,339 ---- self.filename = path ! description, patterns, topLeft, size = lifeutil.readLifeFile(path) print description print "topLeft:", topLeft, "size", size *************** *** 359,363 **** data = clipboard.getClipboard() if isinstance(data, str): ! description, patterns, topLeft, size = translateClipboardPattern(data) print description print "topLeft:", topLeft, "size", size --- 377,381 ---- data = clipboard.getClipboard() if isinstance(data, str): ! description, patterns, topLeft, size = lifeutil.translateClipboardPattern(data) print description print "topLeft:", topLeft, "size", size *************** *** 412,416 **** def on_menuAutomataPatternsList_select(self, event): self.patternsWindow.visible = True ! if __name__ == '__main__': app = model.Application(Life) --- 430,446 ---- def on_menuAutomataPatternsList_select(self, event): self.patternsWindow.visible = True ! ! def on_menuAutomataDownloadLexiconAndPatterns_select(self, event): ! cwd = os.getcwd() ! os.chdir(self.application.applicationDirectory) ! self.statusBar.text = 'Downloading Lexicon...' ! lifeutil.getLexicon(self.configPath) ! self.lexiconWindow.populatePatternsList() ! self.statusBar.text = 'Downloading Patterns...' ! lifeutil.getPatterns(self.configPath) ! self.patternsWindow.populatePatternsList() ! os.chdir(cwd) ! self.statusBar.text = 'Done' ! if __name__ == '__main__': app = model.Application(Life) Index: life.rsrc.py =================================================================== RCS file: /cvsroot/pythoncard/PythonCard/samples/life/life.rsrc.py,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** life.rsrc.py 10 May 2004 05:02:16 -0000 1.6 --- life.rsrc.py 28 Sep 2004 05:00:26 -0000 1.7 *************** *** 63,66 **** --- 63,70 ---- 'name':'menuAutomataPatternsList', 'label':"Patterns List Window"}, + { 'type':'MenuItem', 'name':'automataSep1', 'label':'-' }, + { 'type':'MenuItem', + 'name':'menuAutomataDownloadLexiconAndPatterns', + 'label':"Download Lexicon and Patterns"}, ] }, { 'type':'Menu', Index: util.py =================================================================== RCS file: /cvsroot/pythoncard/PythonCard/samples/life/util.py,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** util.py 18 Mar 2004 22:10:45 -0000 1.9 --- util.py 28 Sep 2004 05:00:26 -0000 1.10 *************** *** 213,229 **** # downloading another copy ! def getLexicon(): filename = 'lexicon.txt' zipname = 'lex_asc.zip' url = 'http://www.argentum.freeserve.co.uk/' + zipname ! urllib.urlretrieve(url, zipname) ! zz = zipfile.ZipFile(zipname) ! savefile(filename, zz.read(filename)) ! def getPatterns(): zipname = 'lifep.zip' url = 'http://www.ibiblio.org/lifepatterns/' + zipname ! urllib.urlretrieve(url, zipname) ! zz = zipfile.ZipFile(zipname) for name in zz.namelist(): ! savefile(os.path.join('patterns', name), zz.read(name)) --- 213,231 ---- # downloading another copy ! def getLexicon(path): filename = 'lexicon.txt' zipname = 'lex_asc.zip' + zippath = os.path.join(path, zipname) url = 'http://www.argentum.freeserve.co.uk/' + zipname ! urllib.urlretrieve(url, zippath) ! zz = zipfile.ZipFile(zippath) ! savefile(os.path.join(path, filename), zz.read(filename)) ! def getPatterns(path): zipname = 'lifep.zip' + zippath = os.path.join(path, zipname) url = 'http://www.ibiblio.org/lifepatterns/' + zipname ! urllib.urlretrieve(url, zippath) ! zz = zipfile.ZipFile(zippath) for name in zz.namelist(): ! savefile(os.path.join(path, 'patterns', name), zz.read(name)) Index: patterns.py =================================================================== RCS file: /cvsroot/pythoncard/PythonCard/samples/life/patterns.py,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** patterns.py 10 May 2004 00:45:20 -0000 1.15 --- patterns.py 28 Sep 2004 05:00:26 -0000 1.16 *************** *** 21,24 **** --- 21,25 ---- self.components.fldDescription.lineNumbersVisible = 0 self.components.fldDescription.setEditorStyle('text') + self.patternsPath = self.GetParent().patternsPath self.populatePatternsList() *************** *** 38,42 **** def populatePatternsList(self): ! files = glob.glob(os.path.join(self.application.applicationDirectory, 'patterns', '*.[Ll][Ii][Ff]')) items = [] self.files = {} --- 39,43 ---- def populatePatternsList(self): ! files = glob.glob(os.path.join(self.patternsPath, '*.[Ll][Ii][Ff]')) items = [] self.files = {} *************** *** 54,59 **** def loadPattern(self, name): - #filename = name + '.lif' - #path = os.path.join(self.application.applicationDirectory, 'patterns', filename) try: path = self.files[name] --- 55,58 ---- |
From: Kevin A. <ka...@us...> - 2004-09-28 04:12:21
|
Update of /cvsroot/pythoncard/PythonCard/samples/hopalong In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29328/samples/hopalong Modified Files: hopalong.py Log Message: minor cleanup and optimization Index: hopalong.py =================================================================== RCS file: /cvsroot/pythoncard/PythonCard/samples/hopalong/hopalong.py,v retrieving revision 1.27 retrieving revision 1.28 diff -C2 -d -r1.27 -r1.28 *** hopalong.py 11 May 2004 11:45:31 -0000 1.27 --- hopalong.py 28 Sep 2004 04:12:11 -0000 1.28 *************** *** 6,12 **** """ ! from PythonCard import model import math - import time import wx --- 6,11 ---- """ ! from PythonCard import model, util import math import wx *************** *** 81,92 **** colorIter = iterations / len(colors) #print iterations, len(colors), colorIter ! for i in range(len(colors)): points = [] for j in range(colorIter): if x < 0: ! temp = y + math.sqrt(abs(b * x - c)) else: ! temp = y - math.sqrt(abs(b * x - c)) y = a - x x = temp --- 80,92 ---- colorIter = iterations / len(colors) #print iterations, len(colors), colorIter ! ! sqrt = math.sqrt for i in range(len(colors)): points = [] for j in range(colorIter): if x < 0: ! temp = y + sqrt(abs(b * x - c)) else: ! temp = y - sqrt(abs(b * x - c)) y = a - x x = temp *************** *** 97,122 **** def doHopalong(self): self.statusBar.text = "Drawing, please wait..." ! starttime = time.time() totalPointsDrawn = 0 ! if self.drawing: ! self.components.bufOff.clear() ! for color, points in self.hopalong(float(self.components.fldA.text), ! float(self.components.fldB.text), ! float(self.components.fldC.text), ! int(self.components.fldIterations.text), ! float(self.components.fldXOffset.text), ! float(self.components.fldYOffset.text), ! float(self.components.fldScale.text), ! int(self.components.fldColors.text)): ! if not self.drawing: ! break ! self.components.bufOff.foregroundColor = color ! self.components.bufOff.drawPointList(points) totalPointsDrawn += len(points) wx.SafeYield(self) ! stoptime = time.time() ! elapsed = stoptime - starttime self.statusBar.text = "hopalong time: %f seconds (%d points drawn)" % (elapsed, totalPointsDrawn) self.drawing = False --- 97,124 ---- def doHopalong(self): self.statusBar.text = "Drawing, please wait..." ! canvas = self.components.bufOff ! ! a = float(self.components.fldA.text) ! b = float(self.components.fldB.text) ! c = float(self.components.fldC.text) ! iterations = int(self.components.fldIterations.text) ! xOffset = float(self.components.fldXOffset.text) ! yOffset = float(self.components.fldYOffset.text) ! scale = float(self.components.fldScale.text) ! numColors = int(self.components.fldColors.text) ! totalPointsDrawn = 0 + starttime = util.time() ! canvas.clear() ! for color, points in self.hopalong(a, b, c, iterations, xOffset, yOffset, scale, numColors): ! canvas.foregroundColor = color ! canvas.drawPointList(points) totalPointsDrawn += len(points) wx.SafeYield(self) + if not self.drawing: + break ! elapsed = util.time() - starttime self.statusBar.text = "hopalong time: %f seconds (%d points drawn)" % (elapsed, totalPointsDrawn) self.drawing = False *************** *** 125,129 **** def on_btnDraw_mouseClick(self, event): ! self.drawing = not self.drawing event.target.enabled = False self.components.btnCancel.enabled = True --- 127,131 ---- def on_btnDraw_mouseClick(self, event): ! self.drawing = True event.target.enabled = False self.components.btnCancel.enabled = True |
From: Kevin A. <ka...@us...> - 2004-09-28 03:13:06
|
Update of /cvsroot/pythoncard/PythonCard/components In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18803/components Modified Files: bitmapcanvas.py Log Message: added enableAutoRefresh, changed 0/1 to False/True Index: bitmapcanvas.py =================================================================== RCS file: /cvsroot/pythoncard/PythonCard/components/bitmapcanvas.py,v retrieving revision 1.42 retrieving revision 1.43 diff -C2 -d -r1.42 -r1.43 *** bitmapcanvas.py 13 May 2004 02:40:24 -0000 1.42 --- bitmapcanvas.py 28 Sep 2004 03:12:55 -0000 1.43 *************** *** 396,400 **** 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)) --- 396,402 ---- return self._bufImage.GetPixelPoint(xy) ! def refresh(self, enableAutoRefresh=False): ! if enableAutoRefresh: ! self.autoRefresh = True dc = wx.ClientDC(self) dc.BlitPointSize((0, 0), (self._size[0], self._size[1]), self._bufImage, (0, 0)) |
From: Kevin A. <ka...@us...> - 2004-09-28 03:13:06
|
Update of /cvsroot/pythoncard/PythonCard/samples/life In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18803/samples/life Modified Files: life.py Log Message: added enableAutoRefresh, changed 0/1 to False/True Index: life.py =================================================================== RCS file: /cvsroot/pythoncard/PythonCard/samples/life/life.py,v retrieving revision 1.43 retrieving revision 1.44 diff -C2 -d -r1.43 -r1.44 *** life.py 28 Sep 2004 02:14:49 -0000 1.43 --- life.py 28 Sep 2004 03:12:55 -0000 1.44 *************** *** 12,21 **** pass ! from PythonCard import clipboard, dialog, graphic, model import wx import os, sys - import time - from patterns import Patterns from lexicon import Lexicon --- 12,19 ---- pass ! from PythonCard import clipboard, dialog, graphic, model, util import wx import os, sys from patterns import Patterns from lexicon import Lexicon *************** *** 30,37 **** self.grid = None self.toggleToLife = 1 ! self.resizing = 0 # used to protect against # mouseClick after file dialog ! self.openingFileDialog = 0 self.setCanvasAttributes(5) --- 28,35 ---- self.grid = None self.toggleToLife = 1 ! self.resizing = False # used to protect against # mouseClick after file dialog ! self.openingFileDialog = False self.setCanvasAttributes(5) *************** *** 159,163 **** canvas = self.components.bufOff width = self.scale - self.spacing ! canvas.autoRefresh = 0 canvas.clear() grid = self.grid --- 157,161 ---- canvas = self.components.bufOff width = self.scale - self.spacing ! canvas.autoRefresh = False canvas.clear() grid = self.grid *************** *** 176,180 **** if grid[cell]: population += 1 ! points.append((cell[0], cell[1])) canvas.drawPointList(points) else: --- 174,178 ---- if grid[cell]: population += 1 ! points.append(cell) canvas.drawPointList(points) else: *************** *** 188,194 **** canvas.drawRectangleList(rects) ! canvas.refresh() self.statusBar.text = "Generation: %d Population: %d" % (self.generation, population) - canvas.autoRefresh = 1 def cellAlive(self, position): --- 186,191 ---- canvas.drawRectangleList(rects) ! canvas.refresh(True) self.statusBar.text = "Generation: %d Population: %d" % (self.generation, population) def cellAlive(self, position): *************** *** 254,273 **** def on_btnStart_mouseClick(self, event): ! self.components.btnStart.enabled = 0 ! self.components.btnStep.enabled = 0 ! self.keepDrawing = 1 ! startTime = time.time() self.doRunLife() ! print "Draw time: %f" % (time.time() - startTime) def on_btnStop_mouseClick(self, event): ! self.keepDrawing = 0 ! self.components.btnStart.enabled = 1 ! self.components.btnStep.enabled = 1 def on_btnStep_mouseClick(self, event): ! self.keepDrawing = 1 self.doRunLife(1) --- 251,270 ---- def on_btnStart_mouseClick(self, event): ! self.components.btnStart.enabled = False ! self.components.btnStep.enabled = False ! self.keepDrawing = True ! startTime = util.time() self.doRunLife() ! print "Draw time: %f" % (util.time() - startTime) def on_btnStop_mouseClick(self, event): ! self.keepDrawing = False ! self.components.btnStart.enabled = True ! self.components.btnStep.enabled = True def on_btnStep_mouseClick(self, event): ! self.keepDrawing = True self.doRunLife(1) *************** *** 373,377 **** def on_close(self, event): ! self.keepDrawing = 0 event.skip() --- 370,374 ---- def on_close(self, event): ! self.keepDrawing = False event.skip() *************** *** 388,394 **** steps = int(result.text) self.keepDrawing = True ! startTime = time.time() self.doRunLife(steps) ! print "Draw time: %f" % (time.time() - startTime) def on_idle(self, event): --- 385,391 ---- steps = int(result.text) self.keepDrawing = True ! startTime = util.time() self.doRunLife(steps) ! print "Draw time: %f" % (util.time() - startTime) def on_idle(self, event): *************** *** 400,409 **** self.setCanvasAttributes(self.scale) self.displayGeneration() ! self.resizing = 0 ! self.openingFileDialog = 0 def on_size(self, event): # user resized the window ! self.resizing = 1 #print "on_size" #self.setCanvasAttributes(self.scale) --- 397,406 ---- self.setCanvasAttributes(self.scale) self.displayGeneration() ! self.resizing = False ! self.openingFileDialog = False def on_size(self, event): # user resized the window ! self.resizing = True #print "on_size" #self.setCanvasAttributes(self.scale) |
From: Kevin A. <ka...@us...> - 2004-09-28 02:14:58
|
Update of /cvsroot/pythoncard/PythonCard/samples/life In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8772/samples/life Modified Files: life.py Log Message: stupidly had commented out SafeYield Index: life.py =================================================================== RCS file: /cvsroot/pythoncard/PythonCard/samples/life/life.py,v retrieving revision 1.42 retrieving revision 1.43 diff -C2 -d -r1.42 -r1.43 *** life.py 28 Sep 2004 01:45:17 -0000 1.42 --- life.py 28 Sep 2004 02:14:49 -0000 1.43 *************** *** 154,158 **** self.grid = newgrid self.displayGeneration() ! #wx.SafeYield(self) def displayGeneration(self): --- 154,158 ---- self.grid = newgrid self.displayGeneration() ! wx.SafeYield(self) def displayGeneration(self): |
From: Kevin A. <ka...@us...> - 2004-09-28 01:45:35
|
Update of /cvsroot/pythoncard/PythonCard/samples/life In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3519/samples/life Modified Files: life.py Log Message: minor optimization Index: life.py =================================================================== RCS file: /cvsroot/pythoncard/PythonCard/samples/life/life.py,v retrieving revision 1.41 retrieving revision 1.42 diff -C2 -d -r1.41 -r1.42 *** life.py 15 Aug 2004 17:34:56 -0000 1.41 --- life.py 28 Sep 2004 01:45:17 -0000 1.42 *************** *** 154,158 **** self.grid = newgrid self.displayGeneration() ! wx.SafeYield(self) def displayGeneration(self): --- 154,158 ---- self.grid = newgrid self.displayGeneration() ! #wx.SafeYield(self) def displayGeneration(self): *************** *** 176,188 **** if grid[cell]: population += 1 ! points.append((cell[0] * self.scale, cell[1] * self.scale)) canvas.drawPointList(points) else: rects = [] for cell in grid: if grid[cell]: population += 1 ! rects.append((cell[0] * self.scale, cell[1] * self.scale, width, width)) ! #canvas.drawRectangle(cell[0] * self.scale, cell[1] * self.scale, width, width) canvas.drawRectangleList(rects) --- 176,189 ---- if grid[cell]: population += 1 ! points.append((cell[0], cell[1])) canvas.drawPointList(points) else: rects = [] + scale = self.scale for cell in grid: if grid[cell]: population += 1 ! rects.append((cell[0] * scale, cell[1] * scale, width, width)) ! #canvas.drawRectangle(cell[0] * scale, cell[1] * scale, width, width) canvas.drawRectangleList(rects) |
From: Alex T. <ale...@us...> - 2004-09-27 16:56:00
|
Update of /cvsroot/pythoncard/PythonCard/samples/testevents In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23237/samples/testevents Modified Files: testevents.py testevents.rsrc.py Log Message: Added example delayed events for child window opening (CallAfter, FutureCall) Index: testevents.rsrc.py =================================================================== RCS file: /cvsroot/pythoncard/PythonCard/samples/testevents/testevents.rsrc.py,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** testevents.rsrc.py 10 May 2004 05:02:44 -0000 1.5 --- testevents.rsrc.py 27 Sep 2004 16:55:49 -0000 1.6 *************** *** 1,53 **** ! { 'application':{ 'type':'Application', ! 'name':'TestEvents', ! 'backgrounds': ! [ ! { 'type':'Background', ! 'name':'bgMin', ! 'title':'Test Events PythonCard Application', ! 'size':( 300, 250 ), ! 'menubar': ! { ! 'type':'MenuBar', ! 'menus': ! [ ! { 'type':'Menu', ! 'name':'menuFile', ! 'label':'&File', ! 'items': [ ! { 'type':'MenuItem', ! 'name':'menuFileExit', ! 'label':'E&xit\tAlt+X', ! 'command':'exit', } ] } ! ] }, ! 'components': ! [ ! { 'type':'TextField', ! 'name':'fld', ! 'position':(0, 0), ! 'text':'Hello PythonCard' }, ! { 'type':'TextArea', ! 'name':'fldArea', ! 'position':(0, 30), ! 'size':(-1, 100), ! 'text':'The quick brown fox jumped over the lazy dog.' }, ! { 'type':'Button', ! 'name':'btn', ! 'position':(150, 0), ! 'label':'btn' }, ! { 'type':'Button', ! 'name':'cmdBtn', ! 'position':(150, 30), ! 'label':'cmdBtn', ! 'command':'setText' }, ! ] ! } ! ] ! } ! } --- 1,63 ---- + {'application':{'type':'Application', + 'name':'TestEvents', + 'backgrounds': [ + {'type':'Background', + 'name':'bgMin', + 'title':'Test Events PythonCard Application', + 'position':(488, 44), + 'size':(300, 250), ! 'menubar': {'type':'MenuBar', ! 'menus': [ ! {'type':'Menu', ! 'name':'menuFile', ! 'label':'&File', ! 'items': [ ! {'type':'MenuItem', ! 'name':'menuFileExit', ! 'label':'E&xit\tAlt+X', ! 'command':'exit', ! }, ! ] ! }, ! ] ! }, ! 'components': [ ! {'type':'Button', ! 'name':'childBtn', ! 'position':(149, 65), ! 'command':'openChildWindow', ! 'label':'childBtn', ! }, ! {'type':'TextField', ! 'name':'fld', ! 'position':(0, 0), ! 'text':'Hello PythonCard', }, ! {'type':'TextArea', ! 'name':'fldArea', ! 'position':(0, 30), ! 'size':(-1, 100), ! 'text':'The quick brown fox jumped over the lazy dog.', ! }, ! ! {'type':'Button', ! 'name':'btn', ! 'position':(150, 0), ! 'label':'btn', ! }, + {'type':'Button', + 'name':'cmdBtn', + 'position':(150, 30), + 'command':'openChildWindow', + 'label':'cmdBtn', + }, + + ] # end components + } # end background + ] # end backgrounds + } } Index: testevents.py =================================================================== RCS file: /cvsroot/pythoncard/PythonCard/samples/testevents/testevents.py,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** testevents.py 30 Apr 2004 23:02:39 -0000 1.20 --- testevents.py 27 Sep 2004 16:55:49 -0000 1.21 *************** *** 11,14 **** --- 11,24 ---- from PythonCard import model, timer + class MinimalChild(model.Background): + # creates a child window - using same resource file + # same appearance - but buttons and fields are not activated + def on_initialize(self, event): + print "initialize child window" + self.title = "Child Window" + + def callableFunction(self, stringParameter): + print "in child function", stringParameter + class Minimal(model.Background): *************** *** 143,146 **** --- 153,169 ---- event.skip() + def on_openChildWindow_command(self, event): + # delayed events - check the order these 'print's appear + # should be + # openChildWindow command + # leaving openCHildWindow + # initializing child window + # in child function via CallAfter + # in child function 10 ms in future + print "openChildWindow command", event.target.name + win = model.childWindow(self, MinimalChild) + wx.FutureCall(10, win.callableFunction, "10 ms in the Future") + wx.CallAfter(win.callableFunction, "via CallAfter") + print "leaving openChildWindow" if __name__ == '__main__': |
From: Kevin A. <ka...@us...> - 2004-09-26 16:22:42
|
Update of /cvsroot/pythoncard/PythonCard/samples/gravity In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24125 Added Files: imagegravity.py imagegravity.rsrc.py Log Message: gravity done with Image components instead, not done yet --- NEW FILE: imagegravity.py --- #!/usr/bin/python """ __version__ = "$Revision: 1.1 $" __date__ = "$Date: 2004/09/26 16:22:31 $" """ # KEA 2004-09-25 # based on the excellent work by Keith Peters # http://www.bit-101.com/tutorials/gravity.html # I started with the doodle sample, so this sample still # contains some cruft # the big missing item is that I'm not currently doing hit # detection on the individual balls so they go right through each # other. I guess that needs to be part of the move method # with a reference back to the sprites list, but I have # a feeling it will be more complicated because if ball 1 # runs into ball 2, then they both need to react... from PythonCard import clipboard, dialog, graphic, model, util import wx import os import random # helper functions def pointInRect(xy, rect): x, y = xy left, top, right, bottom = rect if x >= left and x <= right and y >= top and y <= bottom: return True else: return False def randomColor(): return (random.randint(0, 255), random.randint(0, 255), random.randint(0, 255)) class Sprite(object): def __init__(self, parent): self.parent = parent class BallSprite(Sprite): def __init__(self, parent, name, x, y, radius, color='red'): Sprite.__init__(self, parent) self.x = x self.y = y self.oldx = x self.oldy = y self.radius = radius self.color = color self.xspeed = random.random() * 30 self.yspeed = random.random() * 30 self.gravity = 2 self.drag = .98 self.bounce = .9 self.dragging = False ## self.canvas = self.parent.components.bufOff self.canvas = self.parent.panel x, y = self.canvas.position self.parent.components[name] = {'type':'Image', 'name':name, 'file':'trash.gif', 'position':(self.x + x, self.y + y)} self.image = self.parent.components[name] def move(self): # this is sort of pointless right now # but maybe the dragging code could be moved # into the class in which case we might need # to know if we're dragging if not self.dragging: self.x += self.xspeed self.y += self.yspeed rightedge, bottomedge = self.canvas.size # bounce when we hit the edge if (self.x - self.radius) < 0: self.x = self.radius self.xspeed = -self.xspeed * self.bounce elif (self.x + self.radius) > rightedge: self.x = rightedge - self.radius self.xspeed = -self.xspeed * self.bounce if (self.y - self.radius) < 0: self.y = self.radius self.yspeed = -self.yspeed * self.bounce elif (self.y + self.radius) > bottomedge: self.y = bottomedge - self.radius self.yspeed = -self.yspeed * self.bounce self.xspeed = self.xspeed * self.drag self.yspeed = self.yspeed * self.drag + self.gravity else: self.xspeed = self.x - self.oldx self.yspeed = self.y - self.oldy self.oldx = self.x self.oldy = self.y #print "speed", self.xspeed, self.yspeed self.draw() def draw(self): #self.canvas.setFillColor(self.color) #self.canvas.foregroundColor = self.color #self.canvas.drawCircle((self.x, self.y), self.radius) ## x, y = self.canvas.position ## self.image.position = (self.x + x, self.y + y) self.image.position = (self.x, self.y) class Gravity(model.Background): def on_initialize(self, event): self.x = 0 self.y = 0 self.dragging = False self.animate = False self.filename = None # leave it black for now #self.components.bufOff.foregroundColor = self.color self.sprites = [] self.initSizers() # go ahead and create one ball to get started self.on_btnNewBall_mouseClick(None) def initSizers(self): sizer1 = wx.BoxSizer(wx.VERTICAL) sizer2 = wx.BoxSizer(wx.HORIZONTAL) comp = self.components flags = wx.LEFT | wx.RIGHT | wx.BOTTOM | wx.ALIGN_BOTTOM # Mac wxButton needs 7 pixels on bottom and right macPadding = 7 sizer2.Add(comp.btnNewBall, 0, flags, macPadding) sizer2.Add(comp.btnAnimate, 0, flags, macPadding) sizer2.Add(comp.btnStop, 0, flags, macPadding) sizer1.Add(sizer2, 0) sizer1.Add(comp.bufOff, 1, wx.EXPAND) sizer1.Fit(self) sizer1.SetSizeHints(self) self.panel.SetSizer(sizer1) self.panel.SetAutoLayout(1) self.panel.Layout() def on_btnNewBall_mouseClick(self, event): ## canvas = self.components.bufOff name = 'ball' + str(len(self.sprites)) self.sprites.append(BallSprite(self, name, 20, 20, 15, randomColor())) if not self.animate: ## canvas.clear() for ball in self.sprites: ball.draw() ## canvas.redraw() def on_btnAnimate_mouseClick(self, event): event.target.enabled = False ## canvas = self.components.bufOff ## canvas.autoRefresh = False self.animate = True avgfps = 0 frame = 0 seconds = util.time() # number of frames to display a second # on faster boxes this will throttle the number # of frames calculated and displayed, but on slower # boxes it won't prevent slowdown fps = 30 # amount of time that should pass before drawing another frame timePerFrame = 1.0 / fps #print timePerFrame # hack to force a difference # between time and startTime # to avoid a division by zero exception on fast machines # aka my Windows box ;-) startTime = util.time() - 0.001 while self.animate: newSeconds = util.time() if newSeconds - seconds >= timePerFrame: seconds = newSeconds ## canvas.clear() for ball in self.sprites: ball.move() ## if wx.Platform == '__WXMAC__': ## canvas.redraw() ## else: ## canvas.refresh() frame += 1 self.statusBar.text = "Average FPS: %.4f Balls: %d" % (frame / (seconds - startTime), len(self.sprites)) # give the user a chance to click Stop wx.Yield() def on_btnStop_mouseClick(self, event): self.animate = False self.components.btnAnimate.enabled = True def on_close(self, event): self.animate = False event.skip() def on_mouseDown(self, event): if event.target.name.startswith('ball'): for b in self.sprites: if b.image is event.target: ball = b self.dragging = ball ball.dragging = True self.dx, self.dy = event.position break else: event.skip() # on a mouseLeave we will no longer # get drag messages, so we could end dragging # at that point, just keep the current behavior def on_mouseDrag(self, event): if event.target.name.startswith('ball'): if self.dragging: mx, my = event.position ball = self.dragging ball.x = ball.x + mx - self.dx ball.y = ball.y + my - self.dy # reraw all the objects ## self.components.bufOff.clear() for ball in self.sprites: ball.move() ## if wx.Platform == '__WXMAC__': ## self.components.bufOff.redraw() ## else: ## self.components.bufOff.refresh() else: event.skip() def on_mouseUp(self, event): if event.target.name.startswith('ball'): if self.dragging: self.dragging.dragging = False self.dragging = None else: event.skip() # older Doodle code # I'm keeping it around in case I need it later def on_bufOff_mouseEnter(self, event): self.x, self.y = event.position ## def on_bufOff_mouseDown(self, event): ## self.x, self.y = event.position ## event.target.drawLine((self.x, self.y), (self.x + 1, self.y + 1)) ## ## def on_bufOff_mouseDrag(self, event): ## x, y = event.position ## event.target.drawLine((self.x, self.y), (x, y)) ## self.x = x ## self.y = y def on_btnColor_mouseClick(self, event): result = dialog.colorDialog(self, color=self.color) if result.accepted: #self.components.bufOff.foregroundColor = result.color event.target.backgroundColor = result.color self.color = result.color def openFile(self): result = dialog.openFileDialog(None, "Import which file?") if result.accepted: path = result.paths[0] os.chdir(os.path.dirname(path)) self.filename = path bmp = graphic.Bitmap(self.filename) self.components.bufOff.drawBitmap(bmp, (0, 0)) 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) result = dialog.saveFileDialog(None, "Save As", path, filename) if result.accepted: path = result.paths[0] fileType = graphic.bitmapType(path) print fileType, 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() if __name__ == '__main__': app = model.Application(Gravity) app.MainLoop() --- NEW FILE: imagegravity.rsrc.py --- { 'application':{ 'type':'Application', 'name':'Doodle', 'backgrounds': [ { 'type':'Background', 'name':'bgDoodle', 'title':'Doodle PythonCard Application', 'size':( 310, 300 ), 'style':['resizeable'], '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', 'command':'exit' } ] }, { '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':'Button', 'name':'btnNewBall', 'position':(5, 5), 'label':'New Ball' }, { 'type':'Button', 'name':'btnAnimate', 'position':(100, 5), 'label':'Animate' }, { 'type':'Button', 'name':'btnStop', 'position':(200, 5), 'label':'Stop' }, { 'type':'BitmapCanvas', 'name':'bufOff', 'position':(0, 30), 'size':(300, 230) }, ] } ] } } |
From: Kevin A. <ka...@us...> - 2004-09-26 16:11:00
|
Update of /cvsroot/pythoncard/PythonCard In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20835 Modified Files: util.py Log Message: updated readAndEvalFile once again Index: util.py =================================================================== RCS file: /cvsroot/pythoncard/PythonCard/util.py,v retrieving revision 1.34 retrieving revision 1.35 diff -C2 -d -r1.34 -r1.35 *** util.py 25 Sep 2004 21:48:58 -0000 1.34 --- util.py 26 Sep 2004 16:10:52 -0000 1.35 *************** *** 42,46 **** # old way commented out #txt = f.read().replace('\r\n','\n') ! txt = '\n'.join(f.readlines()) f.close() return eval(txt, globals()) --- 42,46 ---- # old way commented out #txt = f.read().replace('\r\n','\n') ! txt = '\n'.join(f.read().splitlines()) f.close() return eval(txt, globals()) |
From: Kevin A. <ka...@us...> - 2004-09-26 00:10:55
|
Update of /cvsroot/pythoncard/PythonCard/samples/gravity In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5713 Modified Files: gravity.py gravity.rsrc.py Log Message: a little cleanup Index: gravity.py =================================================================== RCS file: /cvsroot/pythoncard/PythonCard/samples/gravity/gravity.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** gravity.py 25 Sep 2004 21:47:36 -0000 1.3 --- gravity.py 26 Sep 2004 00:10:40 -0000 1.4 *************** *** 11,14 **** --- 11,20 ---- # I started with the doodle sample, so this sample still # contains some cruft + # the big missing item is that I'm not currently doing hit + # detection on the individual balls so they go right through each + # other. I guess that needs to be part of the move method + # with a reference back to the sprites list, but I have + # a feeling it will be more complicated because if ball 1 + # runs into ball 2, then they both need to react... from PythonCard import clipboard, dialog, graphic, model, util *************** *** 18,21 **** --- 24,28 ---- + # helper functions def pointInRect(xy, rect): x, y = xy *************** *** 26,29 **** --- 33,39 ---- return False + def randomColor(): + return (random.randint(0, 255), random.randint(0, 255), random.randint(0, 255)) + class Sprite(object): *************** *** 92,100 **** self.animate = False self.filename = None - self.color = self.components.btnColor.backgroundColor # leave it black for now #self.components.bufOff.foregroundColor = self.color self.sprites = [] self.initSizers() def initSizers(self): --- 102,111 ---- self.animate = False self.filename = None # leave it black for now #self.components.bufOff.foregroundColor = self.color self.sprites = [] self.initSizers() + # go ahead and create one ball to get started + self.on_btnNewBall_mouseClick(None) def initSizers(self): *************** *** 105,109 **** # Mac wxButton needs 7 pixels on bottom and right macPadding = 7 ! sizer2.Add(comp.btnColor, 0, flags, macPadding) sizer2.Add(comp.btnAnimate, 0, flags, macPadding) sizer2.Add(comp.btnStop, 0, flags, macPadding) --- 116,120 ---- # Mac wxButton needs 7 pixels on bottom and right macPadding = 7 ! sizer2.Add(comp.btnNewBall, 0, flags, macPadding) sizer2.Add(comp.btnAnimate, 0, flags, macPadding) sizer2.Add(comp.btnStop, 0, flags, macPadding) *************** *** 118,127 **** def on_btnAnimate_mouseClick(self, event): event.target.enabled = False canvas = self.components.bufOff canvas.autoRefresh = False - self.sprites.append(BallSprite(self.components.bufOff, 20, 20, 14, self.color)) - # use the last ball added self.animate = True avgfps = 0 --- 129,146 ---- + def on_btnNewBall_mouseClick(self, event): + canvas = self.components.bufOff + self.sprites.append(BallSprite(canvas, 20, 20, 15, randomColor())) + if not self.animate: + canvas.clear() + for ball in self.sprites: + ball.draw() + canvas.redraw() + + def on_btnAnimate_mouseClick(self, event): event.target.enabled = False canvas = self.components.bufOff canvas.autoRefresh = False self.animate = True avgfps = 0 *************** *** 136,140 **** # amount of time that should pass before drawing another frame timePerFrame = 1.0 / fps ! print timePerFrame # hack to force a difference --- 155,159 ---- # amount of time that should pass before drawing another frame timePerFrame = 1.0 / fps ! #print timePerFrame # hack to force a difference *************** *** 155,159 **** canvas.refresh() frame += 1 ! self.statusBar.text = "Average FPS: %f" % (frame / (seconds - startTime)) # give the user a chance to click Stop wx.Yield() --- 174,178 ---- canvas.refresh() frame += 1 ! self.statusBar.text = "Average FPS: %.4f Balls: %d" % (frame / (seconds - startTime), len(self.sprites)) # give the user a chance to click Stop wx.Yield() Index: gravity.rsrc.py =================================================================== RCS file: /cvsroot/pythoncard/PythonCard/samples/gravity/gravity.rsrc.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** gravity.rsrc.py 25 Sep 2004 20:45:47 -0000 1.1 --- gravity.rsrc.py 26 Sep 2004 00:10:41 -0000 1.2 *************** *** 54,68 **** [ { 'type':'Button', ! 'name':'btnColor', ! 'position':(0, 0), ! 'label':'Color', ! 'backgroundColor':'blue', }, { 'type':'Button', 'name':'btnAnimate', ! 'position':(100, 0), 'label':'Animate' }, { 'type':'Button', 'name':'btnStop', ! 'position':(200, 0), 'label':'Stop' }, { 'type':'BitmapCanvas', --- 54,67 ---- [ { 'type':'Button', ! 'name':'btnNewBall', ! 'position':(5, 5), ! 'label':'New Ball' }, { 'type':'Button', 'name':'btnAnimate', ! 'position':(100, 5), 'label':'Animate' }, { 'type':'Button', 'name':'btnStop', ! 'position':(200, 5), 'label':'Stop' }, { 'type':'BitmapCanvas', |
From: Kevin A. <ka...@us...> - 2004-09-25 21:49:13
|
Update of /cvsroot/pythoncard/PythonCard In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4449 Modified Files: util.py Log Message: added time alias for time.time() on Windows, time.clock() on *nix Index: util.py =================================================================== RCS file: /cvsroot/pythoncard/PythonCard/util.py,v retrieving revision 1.33 retrieving revision 1.34 diff -C2 -d -r1.33 -r1.34 *** util.py 11 Sep 2004 17:18:44 -0000 1.33 --- util.py 25 Sep 2004 21:48:58 -0000 1.34 *************** *** 4,8 **** """ - from __future__ import generators import os import sys --- 4,7 ---- *************** *** 402,403 **** --- 401,412 ---- path = path[3:] return path + + # platform independent way of getting highest + # resolution for doing timing + if sys.platform[:3] == 'win': + # time.clock has better resolution on Windows + from time import clock + time = clock + else: + # but time.time is better on *nix + from time import time |
From: Kevin A. <ka...@us...> - 2004-09-25 21:49:12
|
Update of /cvsroot/pythoncard/PythonCard/docs In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4449/docs Modified Files: changelog.txt Log Message: added time alias for time.time() on Windows, time.clock() on *nix Index: changelog.txt =================================================================== RCS file: /cvsroot/pythoncard/PythonCard/docs/changelog.txt,v retrieving revision 1.308 retrieving revision 1.309 diff -C2 -d -r1.308 -r1.309 *** changelog.txt 25 Sep 2004 15:37:40 -0000 1.308 --- changelog.txt 25 Sep 2004 21:48:59 -0000 1.309 *************** *** 8,11 **** --- 8,13 ---- Release 0.8.1 2004-10-?? + added time alias to util.py to use time.time() on Windows, time.clock() on *nix + added gravity sample minimum requirement changed to wxPython 2.5.2.8 added passwordTextEntryDialog and multilineTextEntryDialog to dialog.py |
From: Kevin A. <ka...@us...> - 2004-09-25 21:47:50
|
Update of /cvsroot/pythoncard/PythonCard/samples/gravity In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4104 Modified Files: gravity.py Log Message: switched to using new util.time function changed drawing to throttle to a specific number of frames per second Index: gravity.py =================================================================== RCS file: /cvsroot/pythoncard/PythonCard/samples/gravity/gravity.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** gravity.py 25 Sep 2004 21:12:12 -0000 1.2 --- gravity.py 25 Sep 2004 21:47:36 -0000 1.3 *************** *** 12,20 **** # contains some cruft ! from PythonCard import clipboard, dialog, graphic, model import wx import os import random - import time --- 12,19 ---- # contains some cruft ! from PythonCard import clipboard, dialog, graphic, model, util import wx import os import random *************** *** 128,148 **** avgfps = 0 frame = 0 # hack to force a difference ! # between time.time() and startTime # to avoid a division by zero exception on fast machines # aka my Windows box ;-) ! startTime = time.time() - 0.001 while self.animate: ! canvas.clear() ! for ball in self.sprites: ! ball.move() ! if wx.Platform == '__WXMAC__': ! canvas.redraw() ! else: ! canvas.refresh() ! #time.sleep(.01) # give the user a chance to click Stop - frame += 1 - self.statusBar.text = "Average FPS: %f" % (frame / (time.time() - startTime)) wx.Yield() --- 127,160 ---- avgfps = 0 frame = 0 + + seconds = util.time() + # number of frames to display a second + # on faster boxes this will throttle the number + # of frames calculated and displayed, but on slower + # boxes it won't prevent slowdown + fps = 30 + # amount of time that should pass before drawing another frame + timePerFrame = 1.0 / fps + print timePerFrame + # hack to force a difference ! # between time and startTime # to avoid a division by zero exception on fast machines # aka my Windows box ;-) ! startTime = util.time() - 0.001 while self.animate: ! newSeconds = util.time() ! if newSeconds - seconds >= timePerFrame: ! seconds = newSeconds ! canvas.clear() ! for ball in self.sprites: ! ball.move() ! if wx.Platform == '__WXMAC__': ! canvas.redraw() ! else: ! canvas.refresh() ! frame += 1 ! self.statusBar.text = "Average FPS: %f" % (frame / (seconds - startTime)) # give the user a chance to click Stop wx.Yield() |