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: Kevin A. <ka...@us...> - 2004-05-14 18:57:33
|
Update of /cvsroot/pythoncard/PythonCard In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5777 Modified Files: log.py Log Message: put write within try/except block in case of file errors Index: log.py =================================================================== RCS file: /cvsroot/pythoncard/PythonCard/log.py,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** log.py 14 Apr 2004 02:38:47 -0000 1.10 --- log.py 14 May 2004 18:57:18 -0000 1.11 *************** *** 143,147 **** self.enabled = 1 ! # If we this is the first time logging has been enabled, # create a new, empty log file. --- 143,147 ---- self.enabled = 1 ! # If this is the first time logging has been enabled, # create a new, empty log file. *************** *** 218,231 **** if self.enabled : now = time.localtime( time.time() ) ! if self.logToStdout: ! f = sys.stdout ! else: ! f = open( self.fileName, 'a' ) ! f.write( prefix + ': ' + "%s" % time.asctime( now ) + ': ' ) ! for arg in argList : ! f.write( str( arg ) ) ! f.write( '\n' ) ! if not self.logToStdout: ! f.close() log = Log() --- 218,236 ---- if self.enabled : now = time.localtime( time.time() ) ! try: ! if self.logToStdout: ! f = sys.stdout ! else: ! f = open( self.fileName, 'a' ) ! f.write( prefix + ': ' + "%s" % time.asctime( now ) + ': ' ) ! for arg in argList : ! f.write( str( arg ) ) ! f.write( '\n' ) ! if self.logToStdout: ! f = None ! else: ! f.close() ! except: ! pass log = Log() |
From: Kevin A. <ka...@us...> - 2004-05-14 18:22:52
|
Update of /cvsroot/pythoncard/PythonCard/tools/resourceEditor In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30527 Modified Files: resourceEditor.py Log Message: changed initialization order, moved panel event binds Index: resourceEditor.py =================================================================== RCS file: /cvsroot/pythoncard/PythonCard/tools/resourceEditor/resourceEditor.py,v retrieving revision 1.197 retrieving revision 1.198 diff -C2 -d -r1.197 -r1.198 *** resourceEditor.py 13 May 2004 02:40:25 -0000 1.197 --- resourceEditor.py 14 May 2004 18:22:43 -0000 1.198 *************** *** 51,54 **** --- 51,72 ---- def on_initialize(self, event): + self.filename = None + self.documentChanged = False + self.cmdLineArgs = {'debugmenu':0, 'logging':0, 'messagewatcher':0, + 'namespaceviewer':0, 'propertyeditor':0, + 'shell':0} + + self.lastCaptured = None + self.startName = None + self.startPosition = (0, 0) + self.startSize = (0, 0) + self.offset = (0, 0) + self.startToolTip = '' + + try: + self.readme = open('readme.txt').read() + except: + self.readme = '' + # KEA 2002-06-27 # copied from codeEditor.py *************** *** 117,128 **** self.components[sizingHandle] = sizingHandleTemplate - self.lastCaptured = None - self.startName = None - self.startPosition = (0, 0) - self.startSize = (0, 0) - self.offset = (0, 0) - self.startToolTip = '' - self.createDC() - self.propertyEditorWindow = model.childWindow(self, PropertyEditor) --- 135,138 ---- *************** *** 135,155 **** self.rsrc = resource.ResourceFile(path).getResource() ! #self.updateStack(self.rsrc) self.updatePanel(self.rsrc) - self.filename = None - self.documentChanged = 0 - self.cmdLineArgs = {'debugmenu':0, 'logging':0, 'messagewatcher':0, - 'namespaceviewer':0, 'propertyeditor':0, - 'shell':0} - self.configPath = os.path.join(configuration.homedir, 'resourceeditor') self.loadConfig() - try: - self.readme = open('readme.txt').read() - except: - self.readme = '' - """ # KEA 2002-03-03 --- 145,162 ---- self.rsrc = resource.ResourceFile(path).getResource() ! self.createDC() self.updatePanel(self.rsrc) + # KEA 2004-05-14 + # this actually should only occur once for the panel + # so I'm moving it into initialize which should work as long as + # the panel isn't destroyed while editing, opening new files, etc. + # KEA link up events for new dragging code + wx.EVT_LEFT_DOWN(self.panel, self.on_mouseDown) + wx.EVT_LEFT_UP(self.panel, self.on_mouseUp) + wx.EVT_MOTION(self.panel, self.on_mouseDrag) self.configPath = os.path.join(configuration.homedir, 'resourceeditor') self.loadConfig() """ # KEA 2002-03-03 *************** *** 321,325 **** self.components[sizingHandle].backgroundColor = self.resizingHandleColor # overly conservative, but effective ! self.documentChanged = 1 def hideSizingHandles(self): --- 328,332 ---- self.components[sizingHandle].backgroundColor = self.resizingHandleColor # overly conservative, but effective ! self.documentChanged = True def hideSizingHandles(self): *************** *** 741,745 **** self.components[w.name] = w self.rebindEventsForDragging() ! self.documentChanged = 0 # could change the resource and title bar # here to give the user more feedback --- 748,752 ---- self.components[w.name] = w self.rebindEventsForDragging() ! self.documentChanged = False # could change the resource and title bar # here to give the user more feedback *************** *** 755,759 **** f.write(desc) f.close() ! self.documentChanged = 0 self.fileHistory.AddFileToHistory(self.filename) return True --- 762,766 ---- f.write(desc) f.close() ! self.documentChanged = False self.fileHistory.AddFileToHistory(self.filename) return True *************** *** 782,786 **** self.components[w.name] = w self.rebindEventsForDragging() ! self.documentChanged = 0 def getNewFileTemplates(self): --- 789,793 ---- self.components[w.name] = w self.rebindEventsForDragging() ! self.documentChanged = False def getNewFileTemplates(self): *************** *** 889,893 **** f.close() self.filename = path ! self.documentChanged = 0 return True except: --- 896,900 ---- f.close() self.filename = path ! self.documentChanged = False return True except: *************** *** 939,943 **** self.updatePanel(self.rsrc) - #self.updateStack(self.rsrc) # KEA 2002-03-24 --- 946,949 ---- *************** *** 951,955 **** self.rebindEventsForDragging() ! self.documentChanged = 0 self.fileHistory.AddFileToHistory(self.filename) --- 957,961 ---- self.rebindEventsForDragging() ! self.documentChanged = False self.fileHistory.AddFileToHistory(self.filename) *************** *** 1052,1056 **** self.offset = (0, 0) self.showSizingHandles(name) ! self.documentChanged = 1 c = self.components[name] --- 1058,1062 ---- self.offset = (0, 0) self.showSizingHandles(name) ! self.documentChanged = True c = self.components[name] *************** *** 1069,1073 **** self.hideSizingHandles() del self.components[aWidget.name] ! self.documentChanged = 1 def on_componentAdd_command(self, event): --- 1075,1079 ---- self.hideSizingHandles() del self.components[aWidget.name] ! self.documentChanged = True def on_componentAdd_command(self, event): *************** *** 1153,1159 **** self.propertyEditorWindow.visible = not self.propertyEditorWindow.visible - def updateStack(self, rsrc): - pass - def updatePanel(self, rsrc): # KEA 2002-03-24 --- 1159,1162 ---- *************** *** 1220,1231 **** self.panel.Disconnect(-1, -1, wx.wxEVT_ERASE_BACKGROUND) self.panel._bitmap = None - # KEA 2001-12-26 - # can the icon for the titlebar be updated dynamically? - self.documentChanged = True - # KEA link up events for new dragging code - wx.EVT_LEFT_DOWN(self.panel, self.on_mouseDown) - wx.EVT_LEFT_UP(self.panel, self.on_mouseUp) - wx.EVT_MOTION(self.panel, self.on_mouseDrag) self.movingComponent = False self.resizingHandleTarget = None --- 1223,1227 ---- *************** *** 1257,1261 **** if dlg.accepted(): self.rsrc.application.name = dlg.components.fldName.text - #self.updateStack(self.rsrc) self.documentChanged = True dlg.destroy() --- 1253,1256 ---- *************** *** 1307,1310 **** --- 1302,1306 ---- background.icon = None self.updatePanel(self.rsrc) + self.documentChanged = True dlg.destroy() *************** *** 1323,1326 **** --- 1319,1323 ---- background.size = eval(dlg.components.fldSize.text) self.updatePanel(self.rsrc) + self.documentChanged = True dlg.destroy() *************** *** 1338,1342 **** else: self.rsrc.application.backgrounds[0].menubar = menuDialog.menuResourceFromList(dlg.menuList) ! self.documentChanged = 1 dlg.destroy() --- 1335,1339 ---- else: self.rsrc.application.backgrounds[0].menubar = menuDialog.menuResourceFromList(dlg.menuList) ! self.documentChanged = True dlg.destroy() *************** *** 1359,1363 **** else: self.rsrc.application.backgrounds[0].strings = stringDialog.stringResourceFromList(dlg.stringList) ! self.documentChanged = 1 dlg.destroy() --- 1356,1360 ---- else: self.rsrc.application.backgrounds[0].strings = stringDialog.stringResourceFromList(dlg.stringList) ! self.documentChanged = True dlg.destroy() *************** *** 1505,1509 **** self.hideSizingHandles() del self.components[aWidget.name] ! self.documentChanged = 1 def on_menuEditCopy_select(self, event): --- 1502,1506 ---- self.hideSizingHandles() del self.components[aWidget.name] ! self.documentChanged = True def on_menuEditCopy_select(self, event): *************** *** 1551,1555 **** self.offset = (0, 0) self.showSizingHandles(name) ! self.documentChanged = 1 --- 1548,1552 ---- self.offset = (0, 0) self.showSizingHandles(name) ! self.documentChanged = True |
From: Kevin A. <ka...@us...> - 2004-05-14 16:32:46
|
Update of /cvsroot/pythoncard/PythonCard/tools/codeEditor In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5053/tools/codeEditor Modified Files: readme.txt Log Message: version and url updates Index: readme.txt =================================================================== RCS file: /cvsroot/pythoncard/PythonCard/tools/codeEditor/readme.txt,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** readme.txt 8 Apr 2004 21:07:35 -0000 1.5 --- readme.txt 14 May 2004 16:32:36 -0000 1.6 *************** *** 39,45 **** 5a. You should be looking at a "New Action" dialog 6. In the "Action:" field type in a label such as "Edit with PythonCard". This is the label that will show up in the context menu when you right-click on a .py file in the Explorer ! 7. in the "Application used to perform action:" field you need to specify the path to the Python executable as well as the location of the codeEditor.py file. On a Python 2.2.1 installation using the default installer this will look like: ! C:\Python22\pythonw.exe C:\Python22\Lib\site-packages\PythonCard\tools\codeEditor\codeEditor.py "%1" Substitute your own paths for the ones above and put quotes (") around the paths with spaces in them, if any. If you want a console when codeEditor.py runs, then use python.exe instead of pythonw.exe --- 39,45 ---- 5a. You should be looking at a "New Action" dialog 6. In the "Action:" field type in a label such as "Edit with PythonCard". This is the label that will show up in the context menu when you right-click on a .py file in the Explorer ! 7. in the "Application used to perform action:" field you need to specify the path to the Python executable as well as the location of the codeEditor.py file. On a Python 2.3.3 installation using the default installer this will look like: ! C:\Python23\pythonw.exe C:\Python23\Lib\site-packages\PythonCard\tools\codeEditor\codeEditor.py "%1" Substitute your own paths for the ones above and put quotes (") around the paths with spaces in them, if any. If you want a console when codeEditor.py runs, then use python.exe instead of pythonw.exe |
From: Kevin A. <ka...@us...> - 2004-05-14 16:32:45
|
Update of /cvsroot/pythoncard/PythonCard/samples/lsystem In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5053/samples/lsystem Modified Files: readme.txt Log Message: version and url updates Index: readme.txt =================================================================== RCS file: /cvsroot/pythoncard/PythonCard/samples/lsystem/readme.txt,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** readme.txt 10 May 2004 16:45:20 -0000 1.2 --- readme.txt 14 May 2004 16:32:35 -0000 1.3 *************** *** 3,7 **** For more information on Lindenmayer Systems (L-Systems) see: ! http://wwwsv1.u-aizu.ac.jp/~nehaniv/CM/lsys.html Contributed by Arlo Belshee, Kim Wallmark, Ward Cunningham, and Kevin Altis. \ No newline at end of file --- 3,7 ---- For more information on Lindenmayer Systems (L-Systems) see: ! http://www.biologie.uni-hamburg.de/b-online/e28_3/lsys.html Contributed by Arlo Belshee, Kim Wallmark, Ward Cunningham, and Kevin Altis. \ No newline at end of file |
From: Kevin A. <ka...@us...> - 2004-05-13 17:54:09
|
Update of /cvsroot/pythoncard/PythonCard In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1981 Modified Files: model.py Log Message: changed addMethod to use setattr Index: model.py =================================================================== RCS file: /cvsroot/pythoncard/PythonCard/model.py,v retrieving revision 1.173 retrieving revision 1.174 diff -C2 -d -r1.173 -r1.174 *** model.py 13 May 2004 05:21:23 -0000 1.173 --- model.py 13 May 2004 17:53:58 -0000 1.174 *************** *** 479,483 **** #print aMethod.__name__ #print aMethod ! self.__class__.__dict__[aMethod.__name__] = aMethod # now add the method info to our handler lookup dictionary # KEA 2001-11-29 simplified _addHandler --- 479,483 ---- #print aMethod.__name__ #print aMethod ! setattr(self.__class__, aMethod.__name__, aMethod) # now add the method info to our handler lookup dictionary # KEA 2001-11-29 simplified _addHandler *************** *** 485,488 **** --- 485,500 ---- #self._addHandler(aMethod.__name__, handler) self._addHandler(aMethod) + + # KEA 2004-05-13 + # will need to call _bindEvents here to make sure the event handler + # is bound to the right component instances + # trying to figure out all the components as well as the reverse mapping + # from an event name like mouseDown to event.MouseDownEvent is tricky + # at best so we'll probably need to have user-code make explicit calls + # to _bindEvents for each component they want to bind + # the name to event class mapping can be found by iterativing over the + # events defined in the spec for a given component to find a name match + # maybe just calling _bindEvents with a full list of relevant events + # would work, since the boundEvents list will prevent double-binding def findHandler(self, aString): |
From: Kevin A. <ka...@us...> - 2004-05-13 05:21:35
|
Update of /cvsroot/pythoncard/PythonCard In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9158 Modified Files: model.py statusbar.py Log Message: added workaround code for Mac StatusBar Index: statusbar.py =================================================================== RCS file: /cvsroot/pythoncard/PythonCard/statusbar.py,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** statusbar.py 14 Apr 2004 22:41:09 -0000 1.11 --- statusbar.py 13 May 2004 05:21:24 -0000 1.12 *************** *** 20,23 **** else: wx.StatusBar.__init__(self, parent) ! text = property(wx.StatusBar.GetStatusText, wx.StatusBar.SetStatusText, doc="text displayed in the statusBar") --- 20,24 ---- else: wx.StatusBar.__init__(self, parent) ! if wx.Platform == '__WXMAC__': self.SetSize((self.GetSizeTuple()[0], 15)) ! text = property(wx.StatusBar.GetStatusText, wx.StatusBar.SetStatusText, doc="text displayed in the statusBar") Index: model.py =================================================================== RCS file: /cvsroot/pythoncard/PythonCard/model.py,v retrieving revision 1.172 retrieving revision 1.173 diff -C2 -d -r1.172 -r1.173 *** model.py 10 May 2004 17:24:23 -0000 1.172 --- model.py 13 May 2004 05:21:23 -0000 1.173 *************** *** 940,944 **** self.statusBar = self.createStatusBar() self.SetStatusBar(self.statusBar) ! else: if bar is not None: self.SetStatusBar(None) --- 940,945 ---- self.statusBar = self.createStatusBar() self.SetStatusBar(self.statusBar) ! if wx.Platform == '__WXMAC__': #self.statusBar.PositionStatusBar() ! pass else: if bar is not None: self.SetStatusBar(None) |
From: Kevin A. <ka...@us...> - 2004-05-13 02:40:40
|
Update of /cvsroot/pythoncard/PythonCard/components In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14435/components Modified Files: bitmapcanvas.py button.py checkbox.py codeeditor.py grid.py htmlwindow.py iehtmlwindow.py image.py imagebutton.py multicolumnlist.py radiogroup.py staticbox.py staticline.py statictext.py textarea.py textfield.py togglebutton.py tree.py Log Message: refactored resourceEditor to query component spec for default set of attributes in on_componentAdd_command updated all components and Widget class to provide defaults Index: grid.py =================================================================== RCS file: /cvsroot/pythoncard/PythonCard/components/grid.py,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** grid.py 4 May 2004 17:15:42 -0000 1.9 --- grid.py 13 May 2004 02:40:24 -0000 1.10 *************** *** 23,26 **** --- 23,27 ---- """ attributes = { + 'size' : { 'presence' : 'optional', 'default' : [ 50, 50 ] }, #'items' : { 'presence' : 'optional', 'default' : [] }, #'style' : { 'presence' : 'optional', 'default' : [], 'values' : [ 'horizontal', 'vertical' ] }, Index: staticbox.py =================================================================== RCS file: /cvsroot/pythoncard/PythonCard/components/staticbox.py,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** staticbox.py 4 May 2004 17:15:42 -0000 1.11 --- staticbox.py 13 May 2004 02:40:24 -0000 1.12 *************** *** 12,16 **** def __init__(self): attributes = { ! 'label' : { 'presence' : 'optional', 'default' : '' } } widget.WidgetSpec.__init__( self, 'StaticBox', 'Widget', [], attributes ) --- 12,17 ---- def __init__(self): attributes = { ! 'label' : { 'presence' : 'optional', 'default' : '' }, ! 'size' : { 'presence' : 'optional', 'default' : [ 50, 50 ] }, } widget.WidgetSpec.__init__( self, 'StaticBox', 'Widget', [], attributes ) Index: staticline.py =================================================================== RCS file: /cvsroot/pythoncard/PythonCard/components/staticline.py,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** staticline.py 4 May 2004 17:15:42 -0000 1.12 --- staticline.py 13 May 2004 02:40:24 -0000 1.13 *************** *** 12,16 **** def __init__(self): attributes = { ! 'layout' : { 'presence' : 'optional', 'default' : 'horizontal', 'values' : [ 'horizontal', 'vertical' ] } } widget.WidgetSpec.__init__( self, 'StaticLine', 'Widget', [], attributes ) --- 12,17 ---- def __init__(self): attributes = { ! 'layout' : { 'presence' : 'optional', 'default' : 'horizontal', 'values' : [ 'horizontal', 'vertical' ] }, ! 'size' : { 'presence' : 'optional', 'default' : [ 50, -1 ] }, } widget.WidgetSpec.__init__( self, 'StaticLine', 'Widget', [], attributes ) Index: textarea.py =================================================================== RCS file: /cvsroot/pythoncard/PythonCard/components/textarea.py,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -d -r1.24 -r1.25 *** textarea.py 2 May 2004 19:49:57 -0000 1.24 --- textarea.py 13 May 2004 02:40:24 -0000 1.25 *************** *** 10,22 **** class TextAreaSpec(textfield.TextFieldSpec): def __init__(self): ! textfield.TextFieldSpec.__init__( self ) ! self._name = 'TextArea' ! self._parent = 'TextField' ! ! # KEA 2004-04-20 ! # need to update attributes here to override size [-1, 100] ! class TextArea(textfield.TextField): --- 10,28 ---- + # KEA 2004-05-12 + # due to the way Spec inits are called, I had to duplicate the TextField spec + # just so I could add a 'size' attribute, at least I think I needed to. + class TextAreaSpec(textfield.TextFieldSpec): def __init__(self): ! events = list(textfield.TextFieldEvents) ! attributes = { ! 'text' : {'presence' : 'optional', 'default' : ''}, ! 'editable' : {'presence' : 'optional', 'default' : 1}, ! 'alignment' : {'presence' : 'optional', 'default' : 'left', 'values' :['left', 'right', 'center']}, ! 'border' : {'presence' : 'optional', 'default' : '3d', 'values' : ['3d', 'none']}, ! 'size' : { 'presence' : 'optional', 'default' : [ -1, 50 ] }, ! } ! widget.WidgetSpec.__init__( self, 'TextArea', 'TextField' , events, attributes ) class TextArea(textfield.TextField): Index: radiogroup.py =================================================================== RCS file: /cvsroot/pythoncard/PythonCard/components/radiogroup.py,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -d -r1.24 -r1.25 *** radiogroup.py 4 May 2004 17:15:42 -0000 1.24 --- radiogroup.py 13 May 2004 02:40:24 -0000 1.25 *************** *** 21,26 **** attributes = { 'label' : { 'presence' : 'optional', 'default' : '' }, ! 'items' : { 'presence' : 'optional', 'default' : [] }, ! 'stringSelection' : { 'presence' : 'optional', 'default' : None }, 'layout' : { 'presence' : 'optional', 'default' : 'vertical', 'values' : [ 'horizontal', 'vertical' ] }, 'max' : { 'presence' : 'optional', 'default' : 1 } --- 21,26 ---- attributes = { 'label' : { 'presence' : 'optional', 'default' : '' }, ! 'items' : { 'presence' : 'optional', 'default' : ['one'] }, ! 'stringSelection' : { 'presence' : 'optional', 'default' : 'one' }, 'layout' : { 'presence' : 'optional', 'default' : 'vertical', 'values' : [ 'horizontal', 'vertical' ] }, 'max' : { 'presence' : 'optional', 'default' : 1 } Index: tree.py =================================================================== RCS file: /cvsroot/pythoncard/PythonCard/components/tree.py,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** tree.py 3 May 2004 16:13:41 -0000 1.14 --- tree.py 13 May 2004 02:40:25 -0000 1.15 *************** *** 106,109 **** --- 106,110 ---- #'items' : { 'presence' : 'optional', 'default' : [] }, #'style' : { 'presence' : 'optional', 'default' : [], 'values' : [ 'horizontal', 'vertical' ] }, + 'size' : { 'presence' : 'optional', 'default' : [ 50, 50 ] }, } widget.WidgetSpec.__init__( self, 'Tree', 'Widget', events, attributes ) Index: textfield.py =================================================================== RCS file: /cvsroot/pythoncard/PythonCard/components/textfield.py,v retrieving revision 1.28 retrieving revision 1.29 diff -C2 -d -r1.28 -r1.29 *** textfield.py 2 May 2004 19:56:17 -0000 1.28 --- textfield.py 13 May 2004 02:40:24 -0000 1.29 *************** *** 34,45 **** class TextFieldSpec(widget.WidgetSpec): def __init__( self ) : ! events = [ ! event.KeyPressEvent, ! event.KeyDownEvent, ! event.KeyUpEvent, ! #event.TextEnterEvent, ! event.TextUpdateEvent, ! CloseFieldEvent ! ] attributes = { 'text' : {'presence' : 'optional', 'default' : ''}, --- 34,38 ---- class TextFieldSpec(widget.WidgetSpec): def __init__( self ) : ! events = list(TextFieldEvents) attributes = { 'text' : {'presence' : 'optional', 'default' : ''}, Index: iehtmlwindow.py =================================================================== RCS file: /cvsroot/pythoncard/PythonCard/components/iehtmlwindow.py,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** iehtmlwindow.py 10 May 2004 00:45:17 -0000 1.18 --- iehtmlwindow.py 13 May 2004 02:40:24 -0000 1.19 *************** *** 56,59 **** --- 56,60 ---- ## ] attributes = { + 'size' : { 'presence' : 'optional', 'default' : [ 50, 50 ] }, 'text' : { 'presence' : 'optional', 'default' : '' }, } Index: codeeditor.py =================================================================== RCS file: /cvsroot/pythoncard/PythonCard/components/codeeditor.py,v retrieving revision 1.35 retrieving revision 1.36 diff -C2 -d -r1.35 -r1.36 *** codeeditor.py 3 May 2004 16:12:23 -0000 1.35 --- codeeditor.py 13 May 2004 02:40:24 -0000 1.36 *************** *** 30,33 **** --- 30,34 ---- ] attributes = { + 'size' : { 'presence' : 'optional', 'default' : [ 50, 50 ] }, 'text' : { 'presence' : 'optional', 'default' : '' }, 'editable' : { 'presence' : 'optional', 'default' : 1 }, Index: htmlwindow.py =================================================================== RCS file: /cvsroot/pythoncard/PythonCard/components/htmlwindow.py,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** htmlwindow.py 4 May 2004 17:15:42 -0000 1.16 --- htmlwindow.py 13 May 2004 02:40:24 -0000 1.17 *************** *** 13,16 **** --- 13,17 ---- events = [] attributes = { + 'size' : { 'presence' : 'optional', 'default' : [ 50, 50 ] }, 'text' : { 'presence' : 'optional', 'default' : '' }, } Index: togglebutton.py =================================================================== RCS file: /cvsroot/pythoncard/PythonCard/components/togglebutton.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** togglebutton.py 6 May 2004 20:13:27 -0000 1.1 --- togglebutton.py 13 May 2004 02:40:24 -0000 1.2 *************** *** 21,25 **** events = list(ToggleButtonEvents) attributes = { ! 'label' : { 'presence' : 'mandatory' }, 'checked' : { 'presence' : 'optional', 'default' : 0 } } widget.WidgetSpec.__init__(self, 'ToggleButton', 'Widget', events, attributes ) --- 21,25 ---- events = list(ToggleButtonEvents) attributes = { ! 'label' : { 'presence' : 'optional', 'default':'ToggleButton' }, 'checked' : { 'presence' : 'optional', 'default' : 0 } } widget.WidgetSpec.__init__(self, 'ToggleButton', 'Widget', events, attributes ) Index: multicolumnlist.py =================================================================== RCS file: /cvsroot/pythoncard/PythonCard/components/multicolumnlist.py,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -d -r1.25 -r1.26 *** multicolumnlist.py 4 May 2004 04:24:09 -0000 1.25 --- multicolumnlist.py 13 May 2004 02:40:24 -0000 1.26 *************** *** 76,79 **** --- 76,80 ---- 'rules' : { 'presence' : 'optional', 'default' : 1 }, #'style' : { 'presence' : 'optional', 'default' : [], 'values' : [ 'horizontal', 'vertical' ] }, + 'size' : { 'presence' : 'optional', 'default' : [ 50, 50 ] }, } widget.WidgetSpec.__init__( self, 'MultiColumnList', 'Widget', events, attributes ) Index: bitmapcanvas.py =================================================================== RCS file: /cvsroot/pythoncard/PythonCard/components/bitmapcanvas.py,v retrieving revision 1.41 retrieving revision 1.42 diff -C2 -d -r1.41 -r1.42 *** bitmapcanvas.py 4 May 2004 20:49:11 -0000 1.41 --- bitmapcanvas.py 13 May 2004 02:40:24 -0000 1.42 *************** *** 25,29 **** class BitmapCanvasSpec(widget.WidgetSpec): def __init__(self): ! widget.WidgetSpec.__init__( self, 'BitmapCanvas', 'Widget', [], {} ) --- 25,32 ---- class BitmapCanvasSpec(widget.WidgetSpec): def __init__(self): ! attributes = { ! 'size' : { 'presence' : 'optional', 'default' : [ 50, 50 ] }, ! } ! widget.WidgetSpec.__init__( self, 'BitmapCanvas', 'Widget', [], attributes ) Index: statictext.py =================================================================== RCS file: /cvsroot/pythoncard/PythonCard/components/statictext.py,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** statictext.py 4 May 2004 17:15:42 -0000 1.16 --- statictext.py 13 May 2004 02:40:24 -0000 1.17 *************** *** 11,15 **** def __init__(self): attributes = { ! 'text' : { 'presence' : 'optional', 'default' : '' }, 'alignment' : { 'presence' : 'optional', 'default' : 'left', 'values' :[ 'left', 'right', 'center' ] } } --- 11,15 ---- def __init__(self): attributes = { ! 'text' : { 'presence' : 'optional', 'default' : 'StaticText' }, 'alignment' : { 'presence' : 'optional', 'default' : 'left', 'values' :[ 'left', 'right', 'center' ] } } Index: imagebutton.py =================================================================== RCS file: /cvsroot/pythoncard/PythonCard/components/imagebutton.py,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** imagebutton.py 2 May 2004 23:20:40 -0000 1.16 --- imagebutton.py 13 May 2004 02:40:24 -0000 1.17 *************** *** 17,21 **** #events = [ event.MouseClickEvent ] attributes = { ! 'file' : { 'presence' : 'mandatory' }, # KEA shouldn't there be a 'file' attribute here # could call it 'image' to match background above --- 17,21 ---- #events = [ event.MouseClickEvent ] attributes = { ! 'file' : { 'presence' : 'optional', 'default':'' }, # KEA shouldn't there be a 'file' attribute here # could call it 'image' to match background above *************** *** 25,29 **** # use ImageButton if you want images with transparent border # KEA since 3d is Windows specific, make transparent the default ! 'border' : { 'presence' : 'optional', 'default' : 'transparent', 'values' : [ '3d', 'transparent', 'none' ] } } widget.WidgetSpec.__init__( self, 'ImageButton', 'Image', events, attributes ) --- 25,30 ---- # use ImageButton if you want images with transparent border # KEA since 3d is Windows specific, make transparent the default ! 'border' : { 'presence' : 'optional', 'default' : 'transparent', 'values' : [ '3d', 'transparent', 'none' ] }, ! 'size' : { 'presence' : 'optional', 'default' : [ 50, 50 ] }, } widget.WidgetSpec.__init__( self, 'ImageButton', 'Image', events, attributes ) Index: image.py =================================================================== RCS file: /cvsroot/pythoncard/PythonCard/components/image.py,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** image.py 4 May 2004 17:15:42 -0000 1.20 --- image.py 13 May 2004 02:40:24 -0000 1.21 *************** *** 12,16 **** events = [] attributes = { ! 'file' : { 'presence' : 'mandatory' }, # KEA shouldn't there be a 'file' attribute here # could call it 'image' to match background above --- 12,16 ---- events = [] attributes = { ! 'file' : { 'presence' : 'optional', 'default':'' }, # KEA shouldn't there be a 'file' attribute here # could call it 'image' to match background above *************** *** 19,23 **** # KEA kill border for now, until variations of what is possible are worked out # use ImageButton if you want images with transparent border ! #'border' : { 'presence' : 'optional', 'default' : '3d', 'values' : [ '3d', 'transparent', 'none' ] } } widget.WidgetSpec.__init__( self, 'Image', 'Widget', events, attributes ) --- 19,24 ---- # KEA kill border for now, until variations of what is possible are worked out # use ImageButton if you want images with transparent border ! #'border' : { 'presence' : 'optional', 'default' : '3d', 'values' : [ '3d', 'transparent', 'none' ] }, ! 'size' : { 'presence' : 'optional', 'default' : [ 50, 50 ] }, } widget.WidgetSpec.__init__( self, 'Image', 'Widget', events, attributes ) Index: button.py =================================================================== RCS file: /cvsroot/pythoncard/PythonCard/components/button.py,v retrieving revision 1.30 retrieving revision 1.31 diff -C2 -d -r1.30 -r1.31 *** button.py 4 May 2004 17:15:41 -0000 1.30 --- button.py 13 May 2004 02:40:24 -0000 1.31 *************** *** 23,27 **** ## events = [event.MouseClickEvent] attributes = { ! 'label':{'presence':'mandatory'}, # KEA don't need style for Button unless we are going to support # Win32-specific attributes --- 23,27 ---- ## events = [event.MouseClickEvent] attributes = { ! 'label' : { 'presence' : 'optional', 'default':'Button' }, # KEA don't need style for Button unless we are going to support # Win32-specific attributes *************** *** 29,33 **** 'default':{'presence':'optional', 'default':0} } widget.WidgetSpec.__init__(self, 'Button', 'Widget', events, attributes ) ! class Button(widget.Widget, wx.Button): --- 29,42 ---- 'default':{'presence':'optional', 'default':0} } widget.WidgetSpec.__init__(self, 'Button', 'Widget', events, attributes ) ! ! # KEA 2004-05-12 ! # this is here just so I have an example of a subclass ! # using getMinimalResourceDict ! ! def getMinimalResourceDict(self, name): ! d = widget.WidgetSpec.getMinimalResourceDict(self, name) ! d['label'] = d['name'] ! return d ! class Button(widget.Widget, wx.Button): Index: checkbox.py =================================================================== RCS file: /cvsroot/pythoncard/PythonCard/components/checkbox.py,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** checkbox.py 4 May 2004 17:15:42 -0000 1.18 --- checkbox.py 13 May 2004 02:40:24 -0000 1.19 *************** *** 19,23 **** events = list(CheckBoxEvents) attributes = { ! 'label' : { 'presence' : 'mandatory' }, 'checked' : { 'presence' : 'optional', 'default' : 0 } } widget.WidgetSpec.__init__(self, 'CheckBox', 'Widget', events, attributes ) --- 19,23 ---- events = list(CheckBoxEvents) attributes = { ! 'label' : { 'presence' : 'optional', 'default':'CheckBox' }, 'checked' : { 'presence' : 'optional', 'default' : 0 } } widget.WidgetSpec.__init__(self, 'CheckBox', 'Widget', events, attributes ) |
From: Kevin A. <ka...@us...> - 2004-05-13 02:40:35
|
Update of /cvsroot/pythoncard/PythonCard/tools/resourceEditor In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14435/tools/resourceEditor Modified Files: resourceEditor.py Log Message: refactored resourceEditor to query component spec for default set of attributes in on_componentAdd_command updated all components and Widget class to provide defaults Index: resourceEditor.py =================================================================== RCS file: /cvsroot/pythoncard/PythonCard/tools/resourceEditor/resourceEditor.py,v retrieving revision 1.196 retrieving revision 1.197 diff -C2 -d -r1.196 -r1.197 *** resourceEditor.py 12 May 2004 22:02:10 -0000 1.196 --- resourceEditor.py 13 May 2004 02:40:25 -0000 1.197 *************** *** 253,256 **** --- 253,257 ---- # conditionally preventing them from being loaded here until I figure # out how to deal with them + # Container is another one that isn't applicable yet if True: try: *************** *** 263,266 **** --- 264,272 ---- except ValueError: pass + if True: + try: + moduleNames.remove('container') + except ValueError: + pass # need to force an import of all of the modules in components *************** *** 1066,1226 **** def on_componentAdd_command(self, event): className = event.target.name[16:] - #baseDesc = "{'type':'" + className + "', 'name':'genericName', 'position':(10, 10), 'size':(-1, -1), " - # KEA 2002-02-23 - #dBgC = self.components.topLeft.backgroundColor.asTuple() - #defaultBgColor = "'backgroundColor':" + str(dBgC) + ", " - #print defaultBgColor - baseDesc = "'position':(10, 10), 'size':(-1, -1), " - if className == 'BitmapCanvas': - desc = baseDesc + "}" - elif className == 'Button': - desc = baseDesc + "'label':'Button n'}" - #desc = baseDesc + defaultBgColor + "'label':'Button n'}" - elif className == 'Calendar': - desc = baseDesc + "}" - elif className == 'CheckBox': - desc = baseDesc + "'label':'CheckBox n', 'checked':0}" - elif className == 'Choice': - desc = baseDesc + "'items':[], 'stringSelection':''}" - elif className == 'CodeEditor': - desc = baseDesc + "}" - elif className == 'ComboBox': - desc = baseDesc + "'items':[], 'stringSelection':''}" - elif className == 'Gauge': - desc = baseDesc + "'max':100, 'value':0, 'layout':'horizontal'}" - elif className == 'Grid': - desc = baseDesc + "}" - elif className == 'HtmlWindow': - desc = baseDesc + "'text':''}" - elif className == 'IEHtmlWindow': - desc = baseDesc + "'text':''}" - elif className == 'Image': - desc = baseDesc + "'file':''}" - elif className == 'ImageButton': - desc = baseDesc + "'file':''}" - elif className == 'List': - desc = baseDesc + "'items':[], 'stringSelection':''}" - elif className == 'MultiColumnList': - desc = baseDesc + "'columns':2}" - elif className == 'PasswordField': - desc = baseDesc + "'text':''}" - elif className == 'RadioGroup': - desc = baseDesc + "'label':'RadioBox n', 'items':['one'], 'stringSelection':'', 'layout':'vertical'}" - elif className == 'Slider': - desc = baseDesc + "'min':1, 'max':100, 'value':1, 'layout':'horizontal'}" - elif className == 'Spinner': - desc = baseDesc + "'min':1, 'max':100, 'value':1}" - elif className == 'StaticBox': - desc = baseDesc + "}" - elif className == 'StaticLine': - desc = baseDesc + "'layout':'horizontal'}" - elif className == 'StaticText': - desc = baseDesc + "'text':''}" - elif className == 'TextArea': - desc = baseDesc + "'text':''}" - elif className == 'TextField': - desc = baseDesc + "'text':''}" - elif className == 'ToggleButton': - desc = baseDesc + "'label':'ToggleButton n', 'checked':0}" - elif className == 'Tree': - desc = baseDesc + "}" - else: - return - # KEA 2002-02-23 # find a unique name i = 1 ! while 1: if className + str(i) not in self.components: ! desc = "{'type':'" + className + "', 'name':'" + className + str(i) + "', " + desc break i += 1 ! # KEA 2002-02-23 ! # just create the widget and update via the propertyEditorWindow ! # to streamline the editing process ! d = eval(desc) ! name = d['name'] ! if name in self.components: ! # this shouldn't ever happen given the while loop above, but leave it in for now ! dialog.alertDialog(self, name + " already exists", 'Error: Unable to add widget') ! else: ! if className == 'BitmapCanvas': ! d['size'] = (50, 50) ! elif className == 'Button': ! d['label'] = d['name'] ! elif className == 'Calendar': ! pass ! elif className == 'CheckBox': ! d['label'] = d['name'] ! elif className == 'Choice': ! pass ! elif className == 'CodeEditor': ! d['size'] = (50, 50) ! elif className == 'ComboBox': ! pass ! elif className == 'Gauge': ! pass ! elif className == 'Grid': ! d['size'] = (50, 50) ! elif className == 'HtmlWindow': ! d['size'] = (50, 50) ! elif className == 'IEHtmlWindow': ! d['size'] = (50, 50) ! elif className == 'Image': ! d['size'] = (50, 50) ! d['backgroundColor']='white' ! elif className == 'ImageButton': ! d['size'] = (50, 50) ! d['backgroundColor']='white' ! elif className == 'List': ! pass ! elif className == 'MultiColumnList': ! d['size'] = (50, 50) ! elif className == 'PasswordField': ! pass ! elif className == 'RadioGroup': ! d['label'] = d['name'] ! elif className == 'Slider': ! pass ! elif className == 'Spinner': ! pass ! elif className == 'StaticBox': ! pass#d['size'] = (50, -1) ! elif className == 'StaticLine': ! d['size'] = (50, -1) ! elif className == 'StaticText': ! d['text'] = d['name'] ! elif className == 'TextArea': ! d['size'] = (50, 50) ! elif className == 'TextField': ! pass ! elif className == 'ToggleButton': ! d['label'] = d['name'] ! elif className == 'Tree': ! d['size'] = (50, 50) ! ! self.components[name] = d ! # KEA 2001-12-20 ! # hack to insert component so that it is the first one ! # in the list ! # a similar trick will be needed for re-ordering widgets ! self.components.order.remove(name) ! self.components.order.insert(NUM_SIZING_HANDLES, name) ! self.fixComponentOrder(name) ! self.startName = name ! self.startPosition = self.components[self.startName].position ! self.startSize = self.components[self.startName].size ! self.offset = (0, 0) ! self.showSizingHandles(name) ! self.documentChanged = 1 ! c = self.components[self.startName] ! wx.EVT_LEFT_DOWN(c, self.on_mouseDown) ! wx.EVT_LEFT_UP(c, self.on_mouseUp) ! wx.EVT_MOTION(c, self.on_mouseDrag) def on_componentSendBack_command(self, event): --- 1072,1111 ---- def on_componentAdd_command(self, event): + # event.target.name will be something like + # menuComponentAddButton, so the first 16 characters + # can be thrown away to get the component name className = event.target.name[16:] # find a unique name i = 1 ! while True: if className + str(i) not in self.components: ! desc = registry.Registry.getInstance().components[className]._spec.getMinimalResourceDict(className + str(i)) break i += 1 + desc['position'] = (10, 10) ! name = desc['name'] ! self.components[name] = desc ! # KEA 2001-12-20 ! # hack to insert component so that it is the first one ! # in the list ! # a similar trick will be needed for re-ordering widgets ! self.components.order.remove(name) ! self.components.order.insert(NUM_SIZING_HANDLES, name) ! self.fixComponentOrder(name) ! self.startName = name ! self.startPosition = self.components[self.startName].position ! self.startSize = self.components[self.startName].size ! self.offset = (0, 0) ! self.showSizingHandles(name) ! self.documentChanged = True ! c = self.components[self.startName] ! wx.EVT_LEFT_DOWN(c, self.on_mouseDown) ! wx.EVT_LEFT_UP(c, self.on_mouseUp) ! wx.EVT_MOTION(c, self.on_mouseDrag) def on_componentSendBack_command(self, event): |
From: Kevin A. <ka...@us...> - 2004-05-13 02:40:35
|
Update of /cvsroot/pythoncard/PythonCard/docs In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14435/docs Modified Files: changelog.txt Log Message: refactored resourceEditor to query component spec for default set of attributes in on_componentAdd_command updated all components and Widget class to provide defaults Index: changelog.txt =================================================================== RCS file: /cvsroot/pythoncard/PythonCard/docs/changelog.txt,v retrieving revision 1.290 retrieving revision 1.291 diff -C2 -d -r1.290 -r1.291 *** changelog.txt 12 May 2004 22:02:01 -0000 1.290 --- changelog.txt 13 May 2004 02:40:25 -0000 1.291 *************** *** 3,7 **** Release 0.8 2004-05-?? ! changed resourceEditor to dynamically build list of Components converted turtle sample to use Python modules for the script examples --- 3,10 ---- Release 0.8 2004-05-?? ! refactored resourceEditor to query component spec for default ! set of attributes in on_componentAdd_command ! refactored resourceEditor to dynamically build list of ! available Components instead of using static list converted turtle sample to use Python modules for the script examples |
From: Kevin A. <ka...@us...> - 2004-05-13 02:40:32
|
Update of /cvsroot/pythoncard/PythonCard In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14435 Modified Files: widget.py Log Message: refactored resourceEditor to query component spec for default set of attributes in on_componentAdd_command updated all components and Widget class to provide defaults Index: widget.py =================================================================== RCS file: /cvsroot/pythoncard/PythonCard/widget.py,v retrieving revision 1.131 retrieving revision 1.132 diff -C2 -d -r1.131 -r1.132 *** widget.py 12 May 2004 20:41:35 -0000 1.131 --- widget.py 13 May 2004 02:40:23 -0000 1.132 *************** *** 38,41 **** --- 38,48 ---- attributes.update(subclassAttributes) component.ComponentSpec.__init__( self, name, parent, events, attributes ) + + def getMinimalResourceDict(self, name): + """ + Class method that returns the minimal resource dictionary needed to create a component. + The spec will provide the optional attributes when the Resource is created. + """ + return {'type':self.getName(), 'name':name} |
From: Kevin A. <ka...@us...> - 2004-05-12 23:23:58
|
Update of /cvsroot/pythoncard/PythonCard/tools/findfiles In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9688/tools/findfiles Modified Files: findfiles.py Log Message: only saving last 100 searches Index: findfiles.py =================================================================== RCS file: /cvsroot/pythoncard/PythonCard/tools/findfiles/findfiles.py,v retrieving revision 1.77 retrieving revision 1.78 diff -C2 -d -r1.77 -r1.78 *** findfiles.py 10 May 2004 19:00:47 -0000 1.77 --- findfiles.py 12 May 2004 23:23:49 -0000 1.78 *************** *** 151,155 **** for i in range(self.fileHistory.GetCount()): history.append(self.fileHistory.GetHistoryFile(i)) ! self.config['searches'] = self.components.fldSearchPattern.items self.config['history'] = history try: --- 151,157 ---- for i in range(self.fileHistory.GetCount()): history.append(self.fileHistory.GetHistoryFile(i)) ! # the limitation on the number of items to save is obviously ! # arbitrary, so I guess this could be made a setting as well ! self.config['searches'] = self.components.fldSearchPattern.items[:100] self.config['history'] = history try: |
From: Kevin A. <ka...@us...> - 2004-05-12 23:23:21
|
Update of /cvsroot/pythoncard/PythonCard In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9612 Modified Files: LICENSE.txt Log Message: updated developers and contributors Index: LICENSE.txt =================================================================== RCS file: /cvsroot/pythoncard/PythonCard/LICENSE.txt,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** LICENSE.txt 6 Sep 2003 16:22:42 -0000 1.2 --- LICENSE.txt 12 May 2004 23:23:11 -0000 1.3 *************** *** 1,3 **** ! Copyright (c) 2001-2003 PythonCard developers All rights reserved. --- 1,3 ---- ! Copyright (c) 2001-2004 PythonCard developers All rights reserved. *************** *** 16,40 **** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ! The PythonCard developers are; ! Kevin Altis (al...@se...) ! Rowland Smith ! Patrick K O'Brien (po...@or...) ! Neil Hodgson (ne...@sc...) ! Robin Dunn (ro...@al...) ! Dan Winkler ! Andy Todd (an...@ha...) ! Simon Kittle ! Juergen Rauch Richard Wolff ! Dan Shafer ! Randy Lea ! Riaan Booysen ! David Primmer ! Fred Pacquier ! Gene Cash ! Thomas Heller ! Phil Edwards (ph...@li...) ! David McNab ! Jon Dyte (jo...@to...) ! Roman Suzi (rn...@on...) ! William Volkman --- 16,47 ---- IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ! The PythonCard developers and contributors are; ! Kevin Altis - developer, project lead, <al...@se...> ! Rowland Smith - developer ! Patrick K O'Brien - developer, PyCrust, <po...@or...> ! Neil Hodgson - developer, wxStyledTextCtrl (Scintilla), <ne...@sc...> ! Robin Dunn - developer, wxPython, <ro...@al...> ! Andy Todd - developer, dbBrowser sample, gadflyDatabase.py, documentation, <an...@ha...> ! Arlo Belshee - developer, lsystem sample ! Kim Wallmark - developer, lsystem sample ! Phil Edwards - developer, documentation, pysshed sample, Linux RPMs, <ph...@li...> ! Dan Winkler - developer, textIndexer sample, co-Godfather ;-) ! Kenneth Pronovici - Debian builds ! Dan Shafer - documentation, counter sample ! Thomas Heller - py2exe scripts, Windows distutils script ! Simon Kittle - textRouter sample ! Juergen Rauch - custdb sample Richard Wolff ! Randy Lea - rpn sample ! Riaan Booysen - STCStyleEditor.py ! David McNab - documentation ! David Primmer - documentation ! Fred Pacquier - fpop sample ! Gene Cash - EXIF.py ! Jon Dyte ! Roman Suzi ! William Volkman - multicolumnexample sample ! Bruce Eckel - moderator sample ! Tom Jacobs - montyhall sample ! Stephen Waterbury - twistedEchoClient sample ! Ward Cunningham - lsystem sample |
From: Kevin A. <ka...@us...> - 2004-05-12 22:02:39
|
Update of /cvsroot/pythoncard/PythonCard In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25028 Modified Files: registry.py Log Message: resourceEditor now dynamically builds its list of Components Index: registry.py =================================================================== RCS file: /cvsroot/pythoncard/PythonCard/registry.py,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** registry.py 20 Apr 2004 14:39:21 -0000 1.7 --- registry.py 12 May 2004 22:01:59 -0000 1.8 *************** *** 16,26 **** def __init__( self ) : self.components = {} ! self._findBuiltInComponents() ! def _findBuiltInComponents( self ) : ! path = PythonCard.components.__path__[ 0 ] ! names = glob.glob( os.path.join( path, '*.py' ) ) #for name in names : # print 'found component: ', name def register( self, componentClass ) : --- 16,38 ---- def __init__( self ) : self.components = {} ! #self._moduleNames = self.findBuiltInComponents() ! def findBuiltInComponents(self): ! """ ! Return a list of the built-in module names that is suitable ! for subsequent calls to resource.loadComponentModule. ! """ ! ! path = PythonCard.components.__path__[0] ! paths = glob.glob(os.path.join(path, '*.py')) ! names = [] ! for path in paths: ! filename = os.path.split(path)[1] ! # don't return package file ! if filename != '__init__.py': ! names.append(os.path.splitext(filename)[0]) #for name in names : # print 'found component: ', name + return names def register( self, componentClass ) : |
From: Kevin A. <ka...@us...> - 2004-05-12 22:02:21
|
Update of /cvsroot/pythoncard/PythonCard/tools/resourceEditor In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25028/tools/resourceEditor Modified Files: resourceEditor.py resourceEditor.rsrc.py Log Message: resourceEditor now dynamically builds its list of Components Index: resourceEditor.py =================================================================== RCS file: /cvsroot/pythoncard/PythonCard/tools/resourceEditor/resourceEditor.py,v retrieving revision 1.195 retrieving revision 1.196 diff -C2 -d -r1.195 -r1.196 *** resourceEditor.py 11 May 2004 11:46:11 -0000 1.195 --- resourceEditor.py 12 May 2004 22:02:10 -0000 1.196 *************** *** 8,14 **** # TODO: Start using exceptions! ! from PythonCard import about, clipboard, configuration, dialog, graphic, log, model, resource, util import wx ! import os, sys, pprint from modules.backgroundInfoDialog import BackgroundInfoDialog --- 8,19 ---- # TODO: Start using exceptions! ! import os, sys ! import pprint ! import webbrowser ! import wx ! ! from PythonCard import about, clipboard, configuration, dialog, graphic, log ! from PythonCard import menu, model, registry, resource, util from modules.backgroundInfoDialog import BackgroundInfoDialog *************** *** 20,24 **** from modules.propertyEditor import PropertyEditor from modules import resourceOutput - import webbrowser SIZING_HANDLE_SIZE = 7 --- 25,28 ---- *************** *** 60,63 **** --- 64,69 ---- wx.EVT_MENU_RANGE(self, wx.ID_FILE1, wx.ID_FILE9, self.OnFileHistory) + self.buildComponentsMenu() + self.cursors = {} self.cursors['topRight'] = wx.StockCursor(wx.CURSOR_SIZENESW) *************** *** 215,218 **** --- 221,285 ---- self.openFile(path) + # KEA 2004-05-12 + # transition to dynamic component menu + # and component addition + + def buildComponentsMenu(self): + """ + Dynamically build the menu for the components supported by the + resourceEditor. Eventually this will be a list or some form of palette + instead of a menu. + """ + + # only built-in components are handled currently, so an appcomponents + # directory or fully-qualified component paths are handled + # theoretically when the user loads a resource file the menu should + # be updated, but this is all highly dependent on how imports are + # handled, registry updated, etc. + # One idea would be for the resourceEditor to register itself as + # a change listener and have the registry subclass Changeable so it could + # notify the resourceEditor. In that case, the algorithm below would + # have to be modified since each menu item would be added as it receives + # a change notice from the registry and would need to check the existing + # menu to prevent duplicates as well as insert into the menu in the correct + # order. Or perhaps, the menu items could be wiped out and recreated which + # is probably simpler. + + # get a list of all the modules in components + moduleNames = registry.Registry.getInstance().findBuiltInComponents() + # KEA 2004-05-12 + # I know that IEHtmlWindow is platform specific and has problems + # in the resourceEditor and Grid doesn't work right either so I'm + # conditionally preventing them from being loaded here until I figure + # out how to deal with them + if True: + try: + moduleNames.remove('iehtmlwindow') + except ValueError: + pass + if True: + try: + moduleNames.remove('grid') + except ValueError: + pass + + # need to force an import of all of the modules in components + for name in moduleNames: + resource.loadComponentModule(name) + + # should match based on name instead + # name to object or id like menubar helpers? + m = self.menuBar.menus[2] + + names = registry.Registry.getInstance().components.keys() + names.sort() + for key in names: + rsrc = resource.Resource({'type':'MenuItem', + 'name': 'menuComponentAdd' + key, + 'label': key, + 'command':'componentAdd'}) + mi = menu.MenuItem(self, m, rsrc) + m.appendMenuItem(mi) + def clearWidgets(self): for w in self.components.keys(): Index: resourceEditor.rsrc.py =================================================================== RCS file: /cvsroot/pythoncard/PythonCard/tools/resourceEditor/resourceEditor.rsrc.py,v retrieving revision 1.51 retrieving revision 1.52 diff -C2 -d -r1.51 -r1.52 *** resourceEditor.rsrc.py 10 May 2004 05:02:49 -0000 1.51 --- resourceEditor.rsrc.py 12 May 2004 22:02:10 -0000 1.52 *************** *** 128,258 **** 'name':'menuComponent', 'label':'&Component', ! 'items': [ ! {'type':'MenuItem', ! 'name':'menuComponentAddBitmapCanvas', ! 'label':'BitmapCan&vas', ! 'command':'componentAdd', ! }, ! {'type':'MenuItem', ! 'name':'menuComponentAddButton', ! 'label':'&Button', ! 'command':'componentAdd', ! }, ! {'type':'MenuItem', ! 'name':'menuComponentAddCalendar', ! 'label':'Calendar', ! 'command':'componentAdd', ! }, ! {'type':'MenuItem', ! 'name':'menuComponentAddCheckBox', ! 'label':'&CheckBox', ! 'command':'componentAdd', ! }, ! {'type':'MenuItem', ! 'name':'menuComponentAddChoice', ! 'label':'Ch&oice', ! 'command':'componentAdd', ! }, ! {'type':'MenuItem', ! 'name':'menuComponentAddCodeEditor', ! 'label':'CodeEditor', ! 'command':'componentAdd', ! }, ! {'type':'MenuItem', ! 'name':'menuComponentAddComboBox', ! 'label':'ComboBox', ! 'command':'componentAdd', ! }, ! {'type':'MenuItem', ! 'name':'menuComponentAddGauge', ! 'label':'Gauge', ! 'command':'componentAdd', ! }, ! ## {'type':'MenuItem', ! ## 'name':'menuComponentAddGrid', ! ## 'label':'Grid', ! ## 'command':'componentAdd', ! ## }, ! {'type':'MenuItem', ! 'name':'menuComponentAddHtmlWindow', ! 'label':'&HtmlWindow', ! 'command':'componentAdd', ! }, ! {'type':'MenuItem', ! 'name':'menuComponentAddImage', ! 'label':'&Image', ! 'command':'componentAdd', ! }, ! {'type':'MenuItem', ! 'name':'menuComponentAddImageButton', ! 'label':'I&mageButton', ! 'command':'componentAdd', ! }, ! {'type':'MenuItem', ! 'name':'menuComponentAddList', ! 'label':'&List', ! 'command':'componentAdd', ! }, ! {'type':'MenuItem', ! 'name':'menuComponentAddMultiColumnList', ! 'label':'MultiColumnList', ! 'command':'componentAdd', ! }, ! {'type':'MenuItem', ! 'name':'menuComponentAddPasswordField', ! 'label':'&PasswordField', ! 'command':'componentAdd', ! }, ! {'type':'MenuItem', ! 'name':'menuComponentAddRadioGroup', ! 'label':'&RadioGroup', ! 'command':'componentAdd', ! }, ! {'type':'MenuItem', ! 'name':'menuComponentAddSlider', ! 'label':'&Slider', ! 'command':'componentAdd', ! }, ! {'type':'MenuItem', ! 'name':'menuComponentAddSpinner', ! 'label':'Spinner', ! 'command':'componentAdd', ! }, ! {'type':'MenuItem', ! 'name':'menuComponentAddStaticBox', ! 'label':'StaticBox', ! 'command':'componentAdd', ! }, ! {'type':'MenuItem', ! 'name':'menuComponentAddStaticLine', ! 'label':'St&aticLine', ! 'command':'componentAdd', ! }, ! {'type':'MenuItem', ! 'name':'menuComponentAddStaticText', ! 'label':'StaticT&ext', ! 'command':'componentAdd', ! }, ! {'type':'MenuItem', ! 'name':'menuComponentAddTextArea', ! 'label':'&TextArea', ! 'command':'componentAdd', ! }, ! {'type':'MenuItem', ! 'name':'menuComponentAddTextField', ! 'label':'Te&xtField', ! 'command':'componentAdd', ! }, ! {'type':'MenuItem', ! 'name':'menuComponentAddToggleButton', ! 'label':'ToggleButton', ! 'command':'componentAdd', ! }, ! {'type':'MenuItem', ! 'name':'menuComponentAddTree', ! 'label':'Tree', ! 'command':'componentAdd', ! }, ! ] }, {'type':'Menu', --- 128,132 ---- 'name':'menuComponent', 'label':'&Component', ! 'items': [] }, {'type':'Menu', *************** *** 309,318 **** 'label':'-', }, - #{'type':'MenuItem', - # 'name':'menuViewPositionSize', - # 'label':'Position and Size', - # 'checkable':1, - # 'checked':1, - #}, {'type':'MenuItem', 'name':'menuViewPropertyEditor', --- 183,186 ---- |
From: Kevin A. <ka...@us...> - 2004-05-12 22:02:20
|
Update of /cvsroot/pythoncard/PythonCard/docs In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25028/docs Modified Files: changelog.txt Log Message: resourceEditor now dynamically builds its list of Components Index: changelog.txt =================================================================== RCS file: /cvsroot/pythoncard/PythonCard/docs/changelog.txt,v retrieving revision 1.289 retrieving revision 1.290 diff -C2 -d -r1.289 -r1.290 *** changelog.txt 11 May 2004 01:24:31 -0000 1.289 --- changelog.txt 12 May 2004 22:02:01 -0000 1.290 *************** *** 3,6 **** --- 3,7 ---- Release 0.8 2004-05-?? + changed resourceEditor to dynamically build list of Components converted turtle sample to use Python modules for the script examples |
From: Kevin A. <ka...@us...> - 2004-05-12 20:41:45
|
Update of /cvsroot/pythoncard/PythonCard In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6086 Modified Files: widget.py Log Message: added position and size attributes to Panel Index: widget.py =================================================================== RCS file: /cvsroot/pythoncard/PythonCard/widget.py,v retrieving revision 1.130 retrieving revision 1.131 diff -C2 -d -r1.130 -r1.131 *** widget.py 10 May 2004 19:52:51 -0000 1.130 --- widget.py 12 May 2004 20:41:35 -0000 1.131 *************** *** 493,494 **** --- 493,496 ---- deviceContext.DrawBitmapPoint(self._bitmap.getBits(), (0, 0)) + position = property(wx.Panel.GetPositionTuple, wx.Panel.SetPosition, doc="position of the panel") + size = property(wx.Panel.GetSizeTuple, wx.Panel.SetSize, doc="size of the panel") |
From: Kevin A. <ka...@us...> - 2004-05-11 14:35:26
|
Update of /cvsroot/pythoncard/PythonCard In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10470 Modified Files: turtle.py Log Message: renamed saveState and restoreState to save and restore Index: turtle.py =================================================================== RCS file: /cvsroot/pythoncard/PythonCard/turtle.py,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** turtle.py 11 May 2004 13:03:56 -0000 1.19 --- turtle.py 11 May 2004 14:35:16 -0000 1.20 *************** *** 312,316 **** self._position = self._origin self._angle = 0.0 ! # used for saveState and restoreState methods self._savePosition = self._position self._saveAngle = self._angle --- 312,316 ---- self._position = self._origin self._angle = 0.0 ! # used for save and restore methods self._savePosition = self._position self._saveAngle = self._angle *************** *** 365,374 **** # perhaps the turtle color, whether it is shown or not? ! def saveState(self): """save the current turtle position and heading""" self._savePosition = self._position self._saveAngle = self._angle ! def restoreState(self): """restore the turtle position and heading to the last saved state""" self.moveTo(self._savePosition[0], self._savePosition[1]) --- 365,374 ---- # perhaps the turtle color, whether it is shown or not? ! def save(self): """save the current turtle position and heading""" self._savePosition = self._position self._saveAngle = self._angle ! def restore(self): """restore the turtle position and heading to the last saved state""" self.moveTo(self._savePosition[0], self._savePosition[1]) |
From: Kevin A. <ka...@us...> - 2004-05-11 13:07:17
|
Update of /cvsroot/pythoncard/PythonCard/samples/lsystem In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21653/samples/lsystem Modified Files: lsystem.py Log Message: switched to push and pop Index: lsystem.py =================================================================== RCS file: /cvsroot/pythoncard/PythonCard/samples/lsystem/lsystem.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** lsystem.py 11 May 2004 12:06:19 -0000 1.2 --- lsystem.py 11 May 2004 13:07:08 -0000 1.3 *************** *** 88,94 **** t.bk(legLength) elif char=='[': ! t.saveState() elif char==']': ! t.restoreState() return bounds --- 88,94 ---- t.bk(legLength) elif char=='[': ! t.push() elif char==']': ! t.pop() return bounds *************** *** 115,121 **** t.bk(legLength) elif char=='[': ! t.saveState() elif char==']': ! t.restoreState() ## return bounds --- 115,121 ---- t.bk(legLength) elif char=='[': ! t.push() elif char==']': ! t.pop() ## return bounds |
From: Kevin A. <ka...@us...> - 2004-05-11 13:04:06
|
Update of /cvsroot/pythoncard/PythonCard In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21191 Modified Files: turtle.py Log Message: added push and pop Index: turtle.py =================================================================== RCS file: /cvsroot/pythoncard/PythonCard/turtle.py,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** turtle.py 9 May 2004 19:46:05 -0000 1.18 --- turtle.py 11 May 2004 13:03:56 -0000 1.19 *************** *** 315,318 **** --- 315,320 ---- self._savePosition = self._position self._saveAngle = self._angle + # used for LIFO stack of turtle state + self._turtleStack = [] self._odometer = 0.0 # don't waste time tracking unless requested *************** *** 360,371 **** --- 362,391 ---- self._position = (float(x1), float(y1)) + # could save more than position and heading below + # perhaps the turtle color, whether it is shown or not? + def saveState(self): + """save the current turtle position and heading""" self._savePosition = self._position self._saveAngle = self._angle def restoreState(self): + """restore the turtle position and heading to the last saved state""" self.moveTo(self._savePosition[0], self._savePosition[1]) self.setHeading(self._saveAngle) + def push(self): + """push the current turtle position and heading onto a LIFO stack""" + self._turtleStack.append((self._position, self._angle)) + + def pop(self): + """set the turtle position and heading to the state popped from a LIFO stack""" + try: + position, angle = self._turtleStack.pop() + self.moveTo(position[0], position[1]) + self.setHeading(angle) + except IndexError: + pass + class BitmapTurtle(AbstractTurtle): |
From: Kevin A. <ka...@us...> - 2004-05-11 12:49:30
|
Update of /cvsroot/pythoncard/PythonCard/samples/reversi In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17280 Modified Files: reversi.py Log Message: force redraw so window is updated on Mac OS X Index: reversi.py =================================================================== RCS file: /cvsroot/pythoncard/PythonCard/samples/reversi/reversi.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** reversi.py 2 May 2004 02:40:43 -0000 1.1 --- reversi.py 11 May 2004 12:49:20 -0000 1.2 *************** *** 254,257 **** --- 254,258 ---- view.autoRefresh = True view.refresh() + view.redraw() def updateStatus(self): |
From: Kevin A. <ka...@us...> - 2004-05-11 12:06:33
|
Update of /cvsroot/pythoncard/PythonCard/samples/lsystem In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7540/samples/lsystem Modified Files: lsystem.py lsystem.rsrc.py Log Message: added AbstractTurtle optimization removed mouse draw handlers fixed copy and paste for fields added statusBar and time calculation Index: lsystem.py =================================================================== RCS file: /cvsroot/pythoncard/PythonCard/samples/lsystem/lsystem.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** lsystem.py 9 May 2004 00:50:53 -0000 1.1 --- lsystem.py 11 May 2004 12:06:19 -0000 1.2 *************** *** 7,19 **** from PythonCard import clipboard, dialog, graphic, model ! from PythonCard.turtle import BitmapTurtle import wx import os class LSystem(model.Background): def on_initialize(self, event): - self.x = 0 - self.y = 0 self.filename = None self.on_iterations_select(None) --- 7,18 ---- from PythonCard import clipboard, dialog, graphic, model ! from PythonCard.turtle import AbstractTurtle, BitmapTurtle import wx import os + import time class LSystem(model.Background): def on_initialize(self, event): self.filename = None self.on_iterations_select(None) *************** *** 33,36 **** --- 32,38 ---- def on_Render_command(self, event): + self.statusBar.text = "Drawing, please wait..." + starttime = time.time() + fractalString = self.expand( self.components.scriptField.text, *************** *** 39,43 **** angle = self.components.angle.value self.components.bufOff.autoRefresh = False ! bounds = self.drawFractal( fractalString, 'blue', --- 41,46 ---- angle = self.components.angle.value self.components.bufOff.autoRefresh = False ! ## bounds = self.drawFractal( ! bounds = self.drawAbstractFractal( fractalString, 'blue', *************** *** 58,62 **** --- 61,96 ---- angle, startPos) + + stoptime = time.time() + self.statusBar.text = "Draw time: %.2f seconds" % (stoptime - starttime) + + # KEA 2004-05-08 + # premature optimization <wink> + def drawAbstractFractal(self, aFractalString, color, legLength, angle, startPos): + t = AbstractTurtle(self.components.bufOff.size) + t.lt(90) + t.moveTo(startPos[0], startPos[1]) + bounds = list(startPos + startPos) + for char in aFractalString: + if char=='F': + t.fd(legLength) + x, y = t.getXY() + bounds[0] = min(bounds[0], x) + bounds[1] = min(bounds[1], y) + bounds[2] = max(bounds[2], x) + bounds[3] = max(bounds[3], y) + elif char=='+': + t.rt(angle) + elif char=='-': + t.lt(angle) + elif char=='B': + t.bk(legLength) + elif char=='[': + t.saveState() + elif char==']': + t.restoreState() + return bounds + def drawFractal(self, aFractalString, color, legLength, angle, startPos): self.components.bufOff.clear() *************** *** 65,82 **** t.lt(90) t.moveTo(startPos[0], startPos[1]) ! bounds = list(startPos + startPos) for char in aFractalString: if char=='F': t.fd(legLength) curPos = t.getXY() ! bounds[0] = min(bounds[0], curPos[0]) ! bounds[1] = min(bounds[1], curPos[1]) ! bounds[2] = max(bounds[2], curPos[0]) ! bounds[3] = max(bounds[3], curPos[1]) elif char=='+': t.rt(angle) elif char=='-': t.lt(angle) ! return bounds def expand(self, fractalRules, iterations): --- 99,122 ---- t.lt(90) t.moveTo(startPos[0], startPos[1]) ! ## bounds = list(startPos + startPos) for char in aFractalString: if char=='F': t.fd(legLength) curPos = t.getXY() ! ## bounds[0] = min(bounds[0], curPos[0]) ! ## bounds[1] = min(bounds[1], curPos[1]) ! ## bounds[2] = max(bounds[2], curPos[0]) ! ## bounds[3] = max(bounds[3], curPos[1]) elif char=='+': t.rt(angle) elif char=='-': t.lt(angle) ! elif char=='B': ! t.bk(legLength) ! elif char=='[': ! t.saveState() ! elif char==']': ! t.restoreState() ! ## return bounds def expand(self, fractalRules, iterations): *************** *** 112,128 **** 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) --- 152,155 ---- *************** *** 164,173 **** 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): --- 191,208 ---- def on_menuEditCopy_select(self, event): ! widget = self.findFocus() ! if hasattr(widget, 'editable') and widget.canCopy(): ! widget.copy() ! else: ! clipboard.setClipboard(self.components.bufOff.getBitmap()) def on_menuEditPaste_select(self, event): ! widget = self.findFocus() ! if hasattr(widget, 'editable') and widget.canPaste(): ! widget.paste() ! else: ! bmp = clipboard.getClipboard() ! if isinstance(bmp, wx.Bitmap): ! self.components.bufOff.drawBitmap(bmp) def on_editClear_command(self, event): Index: lsystem.rsrc.py =================================================================== RCS file: /cvsroot/pythoncard/PythonCard/samples/lsystem/lsystem.rsrc.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** lsystem.rsrc.py 10 May 2004 05:02:16 -0000 1.2 --- lsystem.rsrc.py 11 May 2004 12:06:20 -0000 1.3 *************** *** 3,10 **** 'backgrounds': [ {'type':'Background', ! 'name':'bgDoodle', ! 'title':'Doodle PythonCard Application', ! 'position':(603, 190), ! 'size':(579, 529), 'style':['resizeable'], --- 3,11 ---- 'backgrounds': [ {'type':'Background', ! 'name':'bgLSystem', ! 'title':'L-System PythonCard Application', ! 'position':(59, 74), ! 'size':(579, 550), ! 'statusBar':1, 'style':['resizeable'], *************** *** 88,94 **** --- 89,98 ---- 'position':(367, 54), 'size':(200, 20), + 'labels':False, 'layout':'horizontal', 'max':360, 'min':0, + 'tickFrequency':0, + 'ticks':False, 'value':45, }, *************** *** 109,115 **** --- 113,122 ---- 'position':(364, 98), 'size':(200, 20), + 'labels':False, 'layout':'horizontal', 'max':10, 'min':1, + 'tickFrequency':0, + 'ticks':False, 'value':3, }, |
From: Kevin A. <ka...@us...> - 2004-05-11 11:46:35
|
Update of /cvsroot/pythoncard/PythonCard/tools/resourceEditor In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3687 Modified Files: resourceEditor.py Log Message: fixed background dialog enable Index: resourceEditor.py =================================================================== RCS file: /cvsroot/pythoncard/PythonCard/tools/resourceEditor/resourceEditor.py,v retrieving revision 1.194 retrieving revision 1.195 diff -C2 -d -r1.194 -r1.195 *** resourceEditor.py 10 May 2004 05:02:49 -0000 1.194 --- resourceEditor.py 11 May 2004 11:46:11 -0000 1.195 *************** *** 1241,1245 **** self.menuBar.setEnabled('menuFileRunWithInterpreter', True) self.menuBar.setEnabled('menuFilePreviewDialog', False) ! self.menuBar.setEnabled('menuEditBackgroundInfo', False) self.menuBar.setEnabled('menuEditMenubar', True) self.menuBar.setEnabled('menuEditDialogInfo', False) --- 1241,1245 ---- self.menuBar.setEnabled('menuFileRunWithInterpreter', True) self.menuBar.setEnabled('menuFilePreviewDialog', False) ! self.menuBar.setEnabled('menuEditBackgroundInfo', True) self.menuBar.setEnabled('menuEditMenubar', True) self.menuBar.setEnabled('menuEditDialogInfo', False) |
From: Kevin A. <ka...@us...> - 2004-05-11 11:45:44
|
Update of /cvsroot/pythoncard/PythonCard/samples/hopalong In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3464 Modified Files: hopalong.py Log Message: changed 0 and 1 to False and True; removed from __future__ import Index: hopalong.py =================================================================== RCS file: /cvsroot/pythoncard/PythonCard/samples/hopalong/hopalong.py,v retrieving revision 1.26 retrieving revision 1.27 diff -C2 -d -r1.26 -r1.27 *** hopalong.py 5 May 2004 16:53:26 -0000 1.26 --- hopalong.py 11 May 2004 11:45:31 -0000 1.27 *************** *** 6,11 **** """ - from __future__ import generators - from PythonCard import model import math --- 6,9 ---- *************** *** 29,35 **** def on_initialize(self, event): ! self.x = 0 ! self.y = 0 ! self.drawing = 0 self.components.bufOff.backgroundColor = 'black' self.components.bufOff.clear() --- 27,31 ---- def on_initialize(self, event): ! self.drawing = False self.components.bufOff.backgroundColor = 'black' self.components.bufOff.clear() *************** *** 124,139 **** elapsed = stoptime - starttime self.statusBar.text = "hopalong time: %f seconds (%d points drawn)" % (elapsed, totalPointsDrawn) ! self.drawing = 0 ! self.components.btnDraw.enabled = 1 ! self.components.btnCancel.enabled = 0 def on_btnDraw_mouseClick(self, event): self.drawing = not self.drawing ! event.target.enabled = 0 ! self.components.btnCancel.enabled = 1 self.doHopalong() def on_btnCancel_mouseClick(self, event): ! self.drawing = 0 def on_editClear_command(self, event): --- 120,135 ---- elapsed = stoptime - starttime self.statusBar.text = "hopalong time: %f seconds (%d points drawn)" % (elapsed, totalPointsDrawn) ! self.drawing = False ! self.components.btnDraw.enabled = True ! self.components.btnCancel.enabled = False def on_btnDraw_mouseClick(self, event): self.drawing = not self.drawing ! event.target.enabled = False ! self.components.btnCancel.enabled = True self.doHopalong() def on_btnCancel_mouseClick(self, event): ! self.drawing = False def on_editClear_command(self, event): *************** *** 141,145 **** def on_close(self, event): ! self.drawing = 0 event.skip() --- 137,141 ---- def on_close(self, event): ! self.drawing = False event.skip() |
From: Kevin A. <ka...@us...> - 2004-05-11 01:24:42
|
Update of /cvsroot/pythoncard/PythonCard/docs In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25672/docs Modified Files: changelog.txt Log Message: turtle sample note Index: changelog.txt =================================================================== RCS file: /cvsroot/pythoncard/PythonCard/docs/changelog.txt,v retrieving revision 1.288 retrieving revision 1.289 diff -C2 -d -r1.288 -r1.289 *** changelog.txt 10 May 2004 18:24:40 -0000 1.288 --- changelog.txt 11 May 2004 01:24:31 -0000 1.289 *************** *** 3,6 **** --- 3,8 ---- Release 0.8 2004-05-?? + converted turtle sample to use Python modules for the script + examples fixed resourceEditor so it saves on Run and validates component names |
Update of /cvsroot/pythoncard/PythonCard/samples/turtle/scripts In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23170/scripts Added Files: .cvsignore automata.py byteDesign.py chaosScript1.py chaosScript1Fastest.py chaosScript2.py coordinates.py distance.py firstTests.py fourBugs.py generalPlot.py helloTurtle.py hilbert.py kochCurves.py madness.py pentests.py raceturtles.py spingon.py sun.py template.py threeTurtles.py toitles.py trees.py wrappers.py Removed Files: 3Turtles.txt 4bugs.txt ChaosScript1.txt ChaosScript1Direct.txt ChaosScript1Fastest.txt ChaosScript2and3.txt HelloTurtle.txt TurtleScript.txt TurtleScript2.txt TurtleScriptFirst.txt automata.txt bytedesign.txt coordinates.txt distance.txt generalPlot.txt hilbert.txt hopalong.txt kochCurves.txt madness.txt originalbytedesign.txt pentests.txt raceturtles.txt spingon.txt sun.txt template.txt toitles.txt trees.txt Log Message: changed turtle script to Python modules changed how modules are run by using __import__ refactored the turtle wrappers removed redundant examples --- NEW FILE: template.py --- from wrappers import Turtle def draw(canvas): t = Turtle(canvas) t.cls() --- NEW FILE: chaosScript2.py --- # another example that doesn't actually use the turtle for drawing import math import sys from wrappers import Turtle class ChaosTurtle(Turtle): def chaos(self, a=1.5732, xOrig=0.0, yOrig=0.0, endRange=38, xOffset=250, yOffset=250, scale=200.0): mult = 1.2 / endRange tempAutoRefresh = self.canvas.autoRefresh self.canvas.autoRefresh = False for j in range(1, endRange + 1): x = xOrig + mult * j y = yOrig + mult * j for i in range(1000): temp = x * math.cos(a) - (y - (x * x)) * math.sin(a) y = x * math.sin(a) + (y - (x * x)) * math.cos(a) x = temp try: self.canvas.drawPoint((xOffset + scale * x, yOffset + scale * y)) except OverflowError: pass self.canvas.refresh() self.canvas.autoRefresh = tempAutoRefresh # this is an alternate implementation of the method above, # but it uses drawPointList instead. in order to avoid # an OverflowError exception in drawPointList an explicit # check that x1 and y1 are in the maxint conversion range # must be done. at least on my machine the need to create # the temporary variables x1, y1 and the conversion check # ends up making this method slower that the method above def chaosWithList(self, a=1.5732, xOrig=0.0, yOrig=0.0, endRange=38, xOffset=250, yOffset=250, scale=200.0): mult = 1.2 / endRange points = [] maxint = sys.maxint for j in range(1, endRange + 1): x = xOrig + mult * j y = yOrig + mult * j for i in range(1000): temp = x * math.cos(a) - (y - (x * x)) * math.sin(a) y = x * math.sin(a) + (y - (x * x)) * math.cos(a) x = temp x1 = xOffset + scale * x y1 = yOffset + scale * y if x1 > -maxint and x1 < maxint and y1 > -maxint and y1 < maxint: points.append((x1, y1)) self.canvas.drawPointList(points) def draw(canvas): t = ChaosTurtle(canvas) t.cls() #t.chaos(1.5732, 0.0, 0.0, 38, 250, 250, 200) t.chaos(1.1111, 0.0, 0.0, 38, 250, 250, 200) # zoom in on one section of the same set as above #t.chaos(1.1111, 0.74, 0.27, 500, 0, 0, 500) --- madness.txt DELETED --- --- bytedesign.txt DELETED --- --- pentests.txt DELETED --- --- NEW FILE: kochCurves.py --- # examples derived from # Visual Modeling with Logo: A Structural Approach to Seeing # by James Clayson # p. 146 # and # Turtle Geometry: The Computer as a Medium for Exploring Mathematics # by Harold Abelson and Andrea diSessa # p. 91 # see http://physics.hallym.ac.kr/education/chaos/ncsa/Fgeom.html # for some more explanation of fractals from wrappers import CurvesTurtle def draw(canvas): t = CurvesTurtle(canvas) t.cls() t.pu() t.lt(90) t.fd(50) t.rt(90) t.pd() # VM p. 146 t.fractalgon(3, 200, 4, -1) t.fractalgon(3, 250, 4, 1) # if you turn on the odometer you should see the total distance # the turle has gone, so you can compare a level 1 curve to # level 2, 3, etc. # but you will need to subtract the radius (rad) distance * 2 # to compensate for the forward() and back() calls in fractalgon # the same distance measurements can be done with other curves: # cCurves, dragon, hilbert, or any drawing commands # for example as the number of sides increases in a polygon # the distance traveled will approach the 2 * pi * r (the radius) # (circumference) of the circle bounded by the polygon # # odometer commands # t.getOdometer() # t.resumeOdometer() # t.resetOdometer() # t.suspendOdometer() --- automata.txt DELETED --- --- NEW FILE: byteDesign.py --- # example based on article in BYTE magazine # Problem Solving with Logo: Using Turtle Graphics to Redraw a Design # November 1982 # p. 118 - 134 from wrappers import Turtle class ByteTurtle(Turtle): def design(self, homePos, scale): self.pu() for i in range(5): self.fd(64.65 * scale) self.pd() self.wheel(self.getXY(), scale) self.pu() self.bk(64.65 * scale) self.rt(72) self.pu(); self.setXY(homePos); self.rt(36); self.fd(24.5 * scale); self.rt(198); self.pd() self.centerpiece(46 * scale, 143.4, scale) def wheel(self, initpos, scale): self.rt(54) for i in range(4): self.pentpiece(initpos, scale) self.pd(); self.lt(36) for i in range(5): self.tripiece(initpos, scale) self.lt(36) for i in range(5): self.pd() self.rt(72) self.fd(28 * scale) self.pu() self.bk(28 * scale) self.lt(54) def tripiece(self, initpos, scale): oldh = self.getHeading() self.pd(); self.bk(2.5 * scale) self.tripolyr(31.5 * scale, scale) self.pu(); self.setXY(initpos); self.setHeading(oldh) self.pd(); self.bk(2.5 * scale) self.tripolyl(31.5 * scale, scale) self.pu(); self.setXY(initpos); self.setHeading(oldh) self.lt(72) def pentpiece(self, initpos, scale): oldh = self.getHeading() self.pu(); self.fd(29 * scale); self.pd() for i in range(5): self.fd(18 * scale) self.rt(72) self.pentr(18 * scale, 75, scale) self.pu(); self.setXY(initpos); self.setHeading(oldh) self.fd(29 * scale); self.pd() for i in range(5): self.fd(18 * scale) self.rt(72) self.pentl(18 * scale, 75, scale) self.pu(); self.setXY(initpos); self.setHeading(oldh) self.lt(72) def pentl(self, side, ang, scale): if side < (2 * scale): return self.fd(side) self.lt(ang) self.pentl(side - (.38 * scale), ang, scale) def pentr(self, side, ang, scale): if side < (2 * scale): return self.fd(side) self.rt(ang) self.pentr(side - (.38 * scale), ang, scale) def tripolyr(self, side, scale): if side < (4 * scale): return self.fd(side) self.rt(111) self.fd(side / 1.78) self.rt(111) self.fd(side / 1.3) self.rt(146) self.tripolyr(side * .75, scale) def tripolyl(self, side, scale): if side < (4 * scale): return self.fd(side) self.lt(111) self.fd(side / 1.78) self.lt(111) self.fd(side / 1.3) self.lt(146) self.tripolyl(side * .75, scale) def centerpiece(self, s, a, scale): self.fd(s); self.lt(a) if s < (7.5 * scale): return self.centerpiece(s - (1.2 * scale), a, scale) def draw(canvas): t = ByteTurtle(canvas) t.cls() """ t.pu() t.lt(90) t.fd(30) t.rt(90) t.pd() """ t.design(t.getXY(), 2.3) --- template.txt DELETED --- --- generalPlot.txt DELETED --- --- NEW FILE: threeTurtles.py --- from wrappers import CurvesTurtle def draw(canvas): # top left corner is 0,0 and bottom right is some positive x and positive y # so the coordinate space is not like a Logo turtle where 0,0 is the center # of the screen t1 = CurvesTurtle(canvas) t1.color('red') # show turtle #t1.st() # get rid of any previous drawing t1.cls() t2 = CurvesTurtle(canvas) t2.color('green') #t2.st() t2.left(120) t3 = CurvesTurtle(canvas) t3.color('blue') #t3.st() t3.left(240) tList = [t1, t2, t3] for t in tList: t.pu() t.forward(50) t.pd() ## for i in range(6): ## [t.fd(80) for t in tList] ## [t.rt(60) for t in tList] #[t.cCurve(4, 10) for t in tList] [t.rDragon(4, 11) for t in tList] #[t.lDragon(4, 11) for t in tList] --- toitles.txt DELETED --- --- NEW FILE: automata.py --- # 1-dimensional binary cellular automata example # this is not done for maximum efficiency # the line is a simple list with a simulated wrap-around if desired # each bit and the bit to the left and right of it # on the line is treated as a binary number # 001 is 1 decimal and 111 is 7 decimal # so a rule can be tested simply by seeing the sum # of the bits # and the rule itself is just a list of numbers to match # [0, 7] for example means if the sum of the bits is 0 or 7 # then turn the bit on in the next iteration # http://psoup.math.wisc.edu/mcell/rullex_1dbi.html # http://psoup.math.wisc.edu/mcell/ca_rules.html # http://psoup.math.wisc.edu/mcell/ca_gallery.html # http://psoup.math.wisc.edu/mcell/rullex_1dto.html from wrappers import Turtle from random import randint # wrapper for any additional drawing routines # that need to know about each other class WolframTurtle(Turtle): def wolframRule(self, str): """convert hex str to list of numbers""" hex = {'F':[1,1,1,1],'E':[1,1,1,0],'D':[1,1,0,1],'C':[1,1,0,0], 'B':[1,0,1,1],'A':[1,0,1,0],'9':[1,0,0,1],'8':[1,0,0,0], '7':[0,1,1,1],'6':[0,1,1,0],'5':[0,1,0,1],'4':[0,1,0,0], '3':[0,0,1,1],'2':[0,0,1,0],'1':[0,0,0,1],'0':[0,0,0,0]} # first create a binary list str = str.upper() bList = [] for c in str: bList += hex[c] # multiply each item in the list by its position # only return the non-zero items bList.reverse() nList = [] for i in range(len(bList)): if bList[i]: nList.append(i) #print str, nList, bList return nList def drawLine(self, line, x, y): points = [] for i in range(len(line)): if line[i]: # KEA 2004-05-10 # it is faster to just draw on the BitmapCanvas directly # and even faster to use the drawPointList method # in fact this whole example doesn't have anything to # do with turtle graphics :) #self.plot(x + i, y) #self.canvas.drawPoint((x + i, y)) points.append((x + i, y)) self.canvas.drawPointList(points) def randomLine(self, n): r = [] for i in range(n): r.append(randint(0, 1)) return r def draw(canvas): t = WolframTurtle(canvas) t.cls() # change wrap, ruleWidth, and r to get different patterns wrap = 1 # if 0, each side is padded with zeros ruleWidth = 2 # 1 or 2 - number of bits to check to the left or right r = t.randomLine(100) #r = [0] * 50 + [1] + [0] * 50 # a line with only one bit on in the center #r = [1] + [0] * 100 #r = [1,0] * 9 + [1,1,1,1,0] + [1,1,0] * 20 + [0] * 20 + [1,0,0,1,0,1,1,1,1,0,0,0,1] print r pad = [0] * ruleWidth lpad = len(pad) if wrap: a = r[-lpad:] + r[:] + r[:lpad] # wrap line else: a = pad + r[:] + pad # wrap line """ rule1 = [0, 7] rule2 = [1, 2, 3, 4, 5, 6] # opposite of rule 1 rule3 = [0, 5, 6, 7] rule4 = [0, 3, 5, 6, 7] rule5 = [1, 2, 4] # opposite of rule 4 rule6 = [1, 2, 4, 5, 6] #rule7 = [0, 3, 7] # opposite of rule 6 rule7 = [6,5,3,2,1] # R1,W6E rule8 = [5,4,2,1] # R1,W36 rule9 = [31,29,27,26,24,23,20,19,18,14,13,12,9,5,4,1] # chaotic gliders rule10 = [29,27,26,25,24,23,19,17,12,11,6,4,3] # solitons D1 """ """ rules.append(rule1) rules.append(rule2) rules.append(rule3) rules.append(rule4) rules.append(rule5) rules.append(rule6) rules.append(rule7) rules.append(rule8) """ # create a method to turn rule notation like R1,W6E into # the search width (R1 is 1 cell to the left and 1 cell to # the right) and a list of numbers (W36 is [5,4,2,1] # create another method to handle this syntax # R2,C10,M1,S0,S1,B0,B3 # from http://psoup.math.wisc.edu/mcell/rullex_1dto.html # 1D CA at http://psoup.math.wisc.edu/mcell/rullex_1dbi.html rules = [] # now create a list of rules if ruleWidth == 1: rules.append(t.wolframRule("36")) # brownian motion rules.append(t.wolframRule("6E")) # fishing-net rules.append(t.wolframRule("16")) # heavy triangles rules.append(t.wolframRule("5A")) # linear a rules.append(t.wolframRule("96")) # linear b rules.append(t.wolframRule("12")) # pascal's triangle (use just a single bit in the center) else: rules.append(t.wolframRule("BC82271C")) # bermuda triangle rules.append(t.wolframRule("AD9C7232")) # chaotic gliders rules.append(t.wolframRule("89ED7106")) # compound gliders rules.append(t.wolframRule("1C2A4798")) # fliform gliders 1 rules.append(t.wolframRule("5C6A4D98")) # fliform gliders 2 rules.append(t.wolframRule("5F0C9AD8")) # fish bones rules.append(t.wolframRule("B51E9CE8")) # glider p106 W4668ED14 rules.append(t.wolframRule("4668ED14")) # raindrops x = 10 original = a[:] lena = len(a) - (2 * lpad) for rule in rules: # R2 rules are too long to write on the screen # but this works fine for R1 rules if ruleWidth == 1: t.moveTo(x, 0) t.write(str(rule)) #print a[lpad:-lpad] #print a t.drawLine(a[lpad:-lpad], x, 19) for i in range(500): b = [0] * lena # a[lpad:-lpad] for j in range(lena): # generalize this to check an arbitrary number of # cells to the left and right if ruleWidth == 1: sum = a[j + lpad - 1] * 4 + a[j + lpad] * 2 + a[j + lpad + 1] else: sum = a[j + lpad - 2] * 16 + a[j + lpad - 1] * 8 + a[j + lpad] * 4 + a[j + lpad + 1] * 2 + a[j + lpad + 2] if sum in rule: b[j] = 1 else: b[j] = 0 t.drawLine(b, x, 20 + i) if wrap: a = b[-lpad:] + b[:] + b[:lpad] else: a = pad + b[:] + pad x += lena + 10 a = original[:] --- TurtleScript.txt DELETED --- --- 3Turtles.txt DELETED --- --- raceturtles.txt DELETED --- --- ChaosScript1Direct.txt DELETED --- --- NEW FILE: coordinates.py --- # test coordinate system from wrappers import Turtle class CoordinatesTurtle(Turtle): def doTick(self, n): self.right(90) self.forward(5) self.write("%d" % n) self.back(10) self.forward(5) self.left(90) def draw(canvas): t = CoordinatesTurtle(canvas) t.cls t.plot() # "0, 0" in Logo space, but "windowWidth / 2, windowHeight / 2" in Guido space # in Guido space (turtle.py from Python standard library) t.color('green') for i in range(4): t.fd(250) t.doTick(250) t.fd(250) t.bk(500) t.lt(90) # note that the lines are not perfectly straight above which indicates a truncation or # rounding bug. since i have yet to mess with the coordinate system or keeping a high-precision # virtual turtle that is only converted to integer coordinates when drawing i haven't # traced out the problem """ t.plot(10, 10) t.plot(10, 500) t.plot(500, 500) t.plot(500, 10) """ t.color('gray') for i in (10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180): t.lt(i) t.fd(i * 2) #print t._angle # change this to write on screen, DrawText or something t.write("%d" % t._angle) t.bk(i * 2) t.rt(i) --- sun.txt DELETED --- --- NEW FILE: pentests.py --- from wrappers import Turtle def draw(canvas): # top left corner is 0,0 and bottom right is some positive x and positive y # so the coordinate space is not like a Logo turtle where 0,0 is the center # of the screen # these are returning the screen dimensions, not the width of the dc #print dc_local.GetSize() #print dc_local.GetSizeTuple() #print dc_local.GetClippingBox() t1 = Turtle(canvas) t1.setBackColor('black') # background is shared among all turtles t1.color('red') t1.showTurtle() t1.turtleDelay(1) t1.cls() # get rid of any previous drawing t2 = Turtle(canvas) t2.color('green') t2.showTurtle() t2.width(2) t2.left(120) t3 = Turtle(canvas) t3.color('blue') #t3.showTurtle() t3.width(3) t3.left(240) t1.forward(50) t2.forward(50) t3.forward(50) # for loop below is equivelant, need a better way of doing # index range though nList = ['1', '2', '3'] for i in nList: eval('t' + i + '.pu()') eval('t' + i + '.forward(50)') eval('t' + i + '.pd()') tList = [t1, t2, t3] for i in range(6): [t.fd(80) for t in tList] #for j in range(1000000): pass # huge delay so we can see the turtle [t.rt(60) for t in tList] #for j in range(1000000): pass # huge delay so we can see the turtle --- distance.txt DELETED --- --- ChaosScript1Fastest.txt DELETED --- --- NEW FILE: madness.py --- """ based on the "madness" algorithm by Stanley S. Miller presented in the May 1988 Scientific American Computer Recreations column by A. K. Dewdney algorithm starts on page 121 """ import math from math import cos, sin from wrappers import Turtle class MadnessTurtle(Turtle): def madness(self, xOffset, yOffset, scale, n, stepSize): # in the article, the equations were # x = sin(.99 * t) - .7 * cos(3.01 * t) # y = cos(1.01 * t) + .1 * sin(15.03 * t) # the units of t are radians a = 1.0 # a = 0.3 b = 0.99 c = -0.7 d = 3.01 e = 1.0 # e = 0.9 f = 1.01 g = 0.1 h = 15.03 # moveTo the first point to avoid a line from # the center position t = -n * stepSize x = a * sin(b * t) + c * cos(d * t) y = e * cos(f * t) + g * sin(h * t) self.moveTo(x * scale + xOffset, y * scale + yOffset) for t in range(-n, n): t *= stepSize x = a * sin(b * t) + c * cos(d * t) y = e * cos(f * t) + g * sin(h * t) #self.plot(x * scale + xOffset, y * scale + yOffset) self.lineTo(x * scale + xOffset, y * scale + yOffset) def draw(canvas): t1 = MadnessTurtle(canvas) t1.cls() # a stepSize of .01 gives pretty smooth curves t1.madness(350, 250, 200, 40000, .01) --- NEW FILE: chaosScript1Fastest.py --- # KEA 2001-10-14 # this is the same algorithm as chaosScript1.py # but rather than using a turtle, the script below uses the # canvas (BitmapCanvas) and drawPointList directly # it still draws line by line so the pattern evolves # on the screen rather than just showing the whole thing at once # plus the extra blit overhead for each line isn't that bad # with a decent video card def draw(canvas): canvas.clear() xOffset = 50 yOffset = 0 scale = 1.0 r = 2.9 # when r was 4.0 I got an exception when doing the int # conversion below, so I need to consider the appropriate # behaviour when x or y is out of bounds for an int # and also out of bounds of the current cliprect or frame steps = 400 inc = (4.0 - 2.9) / steps for j in range(steps): points = [] r += inc x = 0.3 y = j + 30 for i in range(200): x = r * x * (1 - x) for i in range(300): x = r * x * (1 - x) x1 = int(500 * x) x2 = int(xOffset + scale * x1) y2 = int(yOffset + scale * y) points.append((x2, y2)) canvas.drawPointList(points) --- NEW FILE: .cvsignore --- .cvsignore *.pyc *.log .DS_Store --- 4bugs.txt DELETED --- --- NEW FILE: hilbert.py --- # example derived from # Turtle Geometry: The Computer as a Medium for Exploring Mathematics # by Harold Abelson and Andrea diSessa # p. 96-98 from wrappers import CurvesTurtle def draw(canvas): t = CurvesTurtle(canvas) t.cls() t.moveTo(50, 50) t.right(90) t.hilbert(5, 6, 1) --- NEW FILE: wrappers.py --- """ __version__ = "$Revision: 1.1 $" __date__ = "$Date: 2004/05/11 01:12:51 $" """ # by referring to the Turtle class in this # module rather than PythonCard.turtle.BitmapTurtle # directly in scripts, the script can be run in # a different turtle environment such as LegoTurtle # by simply changing the import line below # of course, I haven't written those other # turtle wrappers, but it never hurts to plan ahead <wink> # i'm open to suggestions for another way of achieving # the same result, namely not needing to change myriads # of turtle scripts in order to run them in a different # graphics environment (BitmapTurtle, LegoTurtle, etc.) from PythonCard import turtle class Turtle(turtle.BitmapTurtle): pass # examples derived from # Visual Modeling with Logo: A Structural Approach to Seeing # by James Clayson # and # Turtle Geometry: The Computer as a Medium for Exploring Mathematics # by Harold Abelson and Andrea diSessa class CurvesTurtle(Turtle): # TG p. 92 def cCurve(self, size, level): if level == 0: self.forward(size) return self.cCurve(size, level - 1) self.right(90) self.cCurve(size, level - 1) self.left(90) # TG p. 93 def lDragon(self, size, level): if level == 0: self.forward(size) return self.lDragon(size, level - 1) self.left(90) self.rDragon(size, level - 1) # TG p. 93 def rDragon(self, size, level): if level == 0: self.forward(size) return self.lDragon(size, level - 1) self.right(90) self.rDragon(size, level - 1) # example derived from # Turtle Geometry: The Computer as a Medium for Exploring Mathematics # by Harold Abelson and Andrea diSessa # p. 96-98 def hilbert(self, size, level, parity): if level == 0: return # rotate and draw first subcurve with opposite parity to big curve self.left(parity * 90) self.hilbert(size, level - 1, -parity) # interface to and draw second subcurve with same parity as big curve self.forward(size) self.right(parity * 90) self.hilbert(size, level - 1, parity) # third subcurve self.forward(size) self.hilbert(size, level - 1, parity) # fourth subcurve self.right(parity * 90) self.forward(size) self.hilbert(size, level - 1, -parity) # a final turn is needed to make the turtle # end up facing outward from the large square self.left(parity * 90) # Visual Modeling with Logo: A Structural Approach to Seeing # by James Clayson # Koch curve, after Helge von Koch who introduced this geometric figure in 1904 # p. 146 def fractalgon(self, n, rad, lev, dir): import math # if dir = 1 turn outward # if dir = -1 turn inward edge = 2 * rad * math.sin(math.pi / n) # logo uses sin(180 / n); Python uses radians self.pu() self.fd(rad) self.pd() self.rt(180 - (90 * (n - 2) / n)) for i in range(n): self.fractal(edge, lev, dir) self.rt(360 / n) self.lt(180 - (90 * (n - 2) / n)) self.pu() self.bk(rad) self.pd() # p. 146 def fractal(self, dist, depth, dir): if depth < 1: self.fd(dist) return self.fractal(dist / 3, depth - 1, dir) self.lt(60 * dir) self.fractal(dist / 3, depth - 1, dir) self.rt(120 * dir) self.fractal(dist / 3, depth - 1, dir) self.lt(60 * dir) self.fractal(dist / 3, depth - 1, dir) --- NEW FILE: spingon.py --- # examples derived from # Visual Modeling with Logo: A Structural Approach to Seeing # by James Clayson from wrappers import Turtle import math from math import pi, sin class GonTurtle(Turtle): # same as polygon, but without the efficiency ;-) def ngon(self, n, edge): for i in range(n): self.fd(edge) self.rt(360.0 / n) # draw a n-sided polygon with radius rad # p. 30 def cngon(self, n, rad): self.pu() self.fd(rad) angle = 180 - (90 * (n - 2) / n) self.rt(angle) self.pd() edge = 2 * rad * sin(pi / n) # logo uses sin(180 / n); Python uses radians self.ngon(n, edge) self.left(angle) self.pu() self.bk(rad) self.pd() # p. 22 def spingon(self, n, edge, angle, growth, times): if times < 1: return self.ngon(n, edge) self.rt(angle) self.spingon(n, edge * growth, angle, growth, times - 1) # another way to do recursion, though the way above seems best """ def spingon(self, n, edge, angle, growth, times): if times > 0: self.ngon(n, edge) self.rt(angle) self.spingon(n, edge * growth, angle, growth, times - 1) """ def draw(canvas): t = GonTurtle(canvas) t.cls() # check that variations of plot works """ t.plot() # uses current x, y #t.plot(375, 300) t.plot(None,10) t.plot(10,None) """ # p. 21 #t.spingon(50, 3, 10, 1.02, 95) radius = 150 # check the radius by uncommenting this """ t.color('blue') for i in range(36): t.fd(radius) t.bk(radius) t.rt(10) """ """ # show that as the number of sides increases # the distance traveled approaches the circumference # of the circle # use the built-in cPolygon (centered-Polygon aTurtle class method) # output is sent to the console window print "circumference: %f" % (2 * pi * radius) for i in range(3, 30): t.resetOdometer() t.resumeOdometer() t.cPolygon(i, radius) dist = t.getOdometer() - (2 * radius) print "sides: %d, distance: %f" % (i, dist) t.suspendOdometer() """ t.color(0, 0, 0) # same as t.color('black') t.color(50, 100, 200) # any r, g, b values between 0 - 255 are valid """""" for i in range(10): t.cngon(8, radius) #t.cngon(6, radius) #t.cngon(5, radius) #t.cngon(4, radius) #t.cngon(3, radius) t.rt(5) radius = radius - 5 """""" --- HelloTurtle.txt DELETED --- --- ChaosScript2and3.txt DELETED --- --- spingon.txt DELETED --- --- NEW FILE: fourBugs.py --- # example based on article in BYTE magazine # 4 bugs starting in separate corners of a square # walk towards each other (this is also the picture on the cover) # November 1982 # p. 236 - 240 from wrappers import Turtle def draw(canvas): t = Turtle(canvas) t.cls() # create four bugs and send them to the four corners of a square bug1 = Turtle(canvas) bug1.color('magenta') bug1.st() bug1.pu() bug1.rt(45) bug1.fd(300) bug1.pd() bug2 = Turtle(canvas) bug2.color('green') bug2.st() bug2.pu() bug2.rt(135) bug2.fd(300) bug2.pd() bug3 = Turtle(canvas) bug3.color('blue') bug3.st() bug3.pu() bug3.rt(225) bug3.fd(300) bug3.pd() bug4 = Turtle(canvas) bug4.color('orange') bug4.st() bug4.pu() bug4.rt(315) bug4.fd(300) bug4.pd() # bug1 is added at the end of the list as a convenience bList = [bug1, bug2, bug3, bug4, bug1] # speed up drawing time tempAutoRefresh = canvas.autoRefresh canvas.autoRefresh = 0 # the bugs take 400 "steps" toward each other for i in range(430): # orient each bug towards its neighbor # by doing this separately from # the step forward, we don't need to maintain # state in a separate list for b in range(4): h = bList[b].towards(bList[b + 1]) bList[b].setHeading(h) # each bug takes one step forward for b in range(4): bList[b].fd(1) canvas.refresh() canvas.autoRefresh = tempAutoRefresh for b in range(4): bList[b].ht() --- NEW FILE: generalPlot.py --- # this is the beginnings of a generalized set of plotting # methods for drawing graphs where x and y can be described # by an equation such as x = t, y = cos(t) # where t is the iteration value over some low to high range # and a step value # since Python can be handed a couple of strings that # are then have eval() applied to them in the loop # generalPlot allows any equation to be passed in as long # as it can be defined in terms of t # the tschirnhausen curve is shown as its own method and # defined in terms of generalPlot for comparison import math from math import cos, pi, sin, sqrt, tan from wrappers import Turtle # wrapper for any additional drawing routines # that need to know about each other class PlotTurtle(Turtle): def doTick(self, n): self.right(90) self.forward(5) self.write("%d" % n) self.back(10) self.forward(5) self.left(90) def coordinateLines(self, x0, y0, xScale, yScale, xLow, xHigh): self.moveTo(0, y0) self.color('blue') self.lineTo(1000, y0) self.moveTo(x0, 0) self.lineTo(x0, 1000) self.moveTo(x0, y0) """ for i in range(10): self.moveTo(i * xLow * xScale + x0, y0) self.doTick(i * xLow) self.moveTo(i * xHigh * xScale + x0, y0) self.doTick(i * xHigh) self.lt(90) """ self.color('black') def generalPlot(self, xOffset, yOffset, xScale, yScale, xEquation, yEquation, low, high, stepSize): # the units of t are radians print "xEquation:", xEquation print "yEquation:", yEquation steps = int((high - low) / stepSize) + 2 # low to high inclusive # moveTo the first point to avoid an extra line t = low x = eval(xEquation) y = eval(yEquation) self.moveTo(x * xScale + xOffset, y * yScale + yOffset) for j in range(steps): t += stepSize x = eval(xEquation) y = eval(yEquation) # self.plot(x * xScale + xOffset, y * yScale + yOffset) self.lineTo(x * xScale + xOffset, y * yScale + yOffset) #self.write("%f, %f" % (x, y)) #break def tschirnhausen2(self, xOffset, yOffset, xScale, yScale, a, low, high, stepSize): # the units of t are radians steps = int((high - low) / stepSize) + 2 # low to high inclusive # moveTo the first point to avoid an extra line t = low - stepSize x = 3 * a * (pow(t, 2) - 3) y = a * t * (pow(t, 2) - 3) self.moveTo(x * xScale + xOffset, y * yScale + yOffset) for j in range(steps): t += stepSize temp = a * (pow(t, 2) - 3) x = 3 * temp y = t * temp # self.plot(x * xScale + xOffset, y * yScale + yOffset) self.lineTo(x * xScale + xOffset, y * yScale + yOffset) """ based on the Tschirnhausen algorithm presented in the May 1988 Scientific American Computer Recreations column by A. K. Dewdney algorithm starts on page 121 """ def tschirnhausen(self, xOffset, yOffset, xScale, yScale, low, high, stepSize): # the units of t are radians a = 1.0 # a = 0.3 steps = int(high - low) / stepSize aSteps = int((2 - 0.1) / 0.1) a = 0.1 for i in range(aSteps): # moveTo the first point to avoid an extra line t = low x = 3 * a * (pow(t, 2) - 3) y = t * a * (pow(t, 2) - 3) self.moveTo(x * xScale + xOffset, y * yScale + yOffset) for j in range(steps): t += stepSize x = 3 * a * (pow(t, 2) - 3) y = a * t * (pow(t, 2) - 3) # self.plot(x * xScale + xOffset, y * yScale + yOffset) self.lineTo(x * xScale + xOffset, y * yScale + yOffset) a += .1 def draw(canvas): t1 = PlotTurtle(canvas) t1.cls() t1.coordinateLines(300, 250, 100, 100, -10, 10) # plot sin, cos, and tan t1.color('red') t1.generalPlot(300, 250, 100, 100, "t", "sin(t)", -pi, pi, .01) t1.color('green') t1.generalPlot(300, 250, 100, 100, "t", "cos(t)", -pi, pi, .01) t1.color('purple') t1.generalPlot(300, 250, 100, 100, "t", "tan(t)", -pi, pi, .01) # generalPlot takes an equation for x and an equation for y # and iterates over a range with a step value # t is the value of each iteration # hippopede t1.color('black') for a in range(20, 50, 5): b = 20 t1.generalPlot(300, 250, 2, 2, "2*cos(t)*sqrt("+str(a)+"*"+str(b)+"-"+"pow("+str(b)+",2)*pow(sin(t), 2))", "2*sin(t)*sqrt("+str(a)+"*"+str(b)+"-"+"pow("+str(b)+",2)*pow(sin(t), 2))", -pi, pi, pi/180) t1.tschirnhausen(200, 250, 5, 3, -4.4, 4.4, .01) #t1.tschirnhausen2(200, 250, 5, 3, 1.0, -4.4, 4.4, .01) """ aLow = .1 aHigh = 2 aStepSize = .1 aSteps = ((aHigh - aLow) / aStepSize) + 2 # aLow to aHigh inclusive a = aLow - aStepSize for i in range(aSteps): a += .1 # a stepSize of .01 gives pretty smooth curves t1.generalPlot(200, 250, 5, 3, "3*" + str(a) + "*(pow(t,2)-3)", "t*" + str(a) + "*(pow(t, 2)-3)", -4.4, 4.4, .01) """ --- hopalong.txt DELETED --- --- TurtleScriptFirst.txt DELETED --- --- NEW FILE: firstTests.py --- from wrappers import CurvesTurtle class SimpleTurtle(CurvesTurtle): def square1(self, distance): self.polygon(4, distance) # just to be different, turn right instead of left def square2(self, distance): for i in range(4): self.forward(distance) self.right(90) def polygon(self, sides, distance): angle = 360.0 / sides for i in range(sides): self.forward(distance) self.left(angle) def draw(canvas): t = SimpleTurtle(canvas) t.color('blue') t.rDragon(3, 12) t.color('orange') t.cCurve(5, 10) t.color('black') t.square2(30) t.square1(100) t.polygon(6, 30) #print t._invradian #print t.angle # I would like to be able to call routines like square2 and polygon1 # without having refer to the object if something like below # is possible? #def polygon(sides, distance): tc.polygon1(sides, distance) #polygon(3, 60) # I got this from chapter 4 of Learning Python, it seems to work # functions are just objects # so we create local objects that point to the methods of the object # this only works for the object, not the class in general, so a # different solution might be more appropriate square = t.square1 polygon = t.polygon t.color('green') # test to see if we get a green square square(150) # this also shows some kind of truncation or rounding error # the top corners of the triangle are off by one pixel t.color('black') t.pu() t.home() t.lt(180) t.fd(200) t.rt(180) t.pd() t.color('blue') for i in range(5): polygon(5, 40) #t.polygon(5, 40) t.left(360.0 / 5) t2 = SimpleTurtle(canvas) t2.color('red') t2.polygon(16, 10) t.color('blue') #t.forward(200) polygon(8, 80) # if this works correctly # the arcs will be different colors # so _goto has to be changed to set the pen characteristics # before drawing for i in range(18): #t.color('blue') t.forward(50) t.right(30) #t2.color('red') t2.fd(50) t2.rt(30) --- NEW FILE: distance.py --- import math from wrappers import Turtle def draw(canvas): t1 = Turtle(canvas) t1.cls() """ # test towards (towardsXY) # these kinds of tests should be done using pyunit tt = Turtle(canvas) for i in range(0, 370, 10): tt.pu() tt.lt(i) tt.fd(100) print "angle: %f, t1 towards tt: %f, tt towards t1: %f" % (i, t1.towards(tt), tt.towards(t1)) tt.bk(100) tt.rt(i) """ # test the distance calculation t1.left(45) t1.forward(100 * math.sqrt(2)) t2 = Turtle(canvas) t2.forward(100) d = t2.distance(t1) t2.write("%f" % d) # should display 100 # test the odometer reading t1.resetOdometer() t1.resumeOdometer() t1.polygon(4, 100) t1.write("odometer: %f" % t1.getOdometer()) --- NEW FILE: helloTurtle.py --- # this is a simple turtle script from wrappers import Turtle def draw(canvas): t = Turtle(canvas) t.cls() t.forward(100) t.write("Hello Turtle") --- trees.txt DELETED --- --- NEW FILE: trees.py --- # examples derived from # Visual Modeling with Logo: A Structural Approach to Seeing # by James Clayson # and # Turtle Geometry: The Computer as a Medium for Exploring Mathematics # by Harold Abelson and Andrea diSessa import wrappers from random import uniform class TreesTurtle(wrappers.Turtle): # TG p. 85 def node(self, length, angle, level): if level == 0: return # point along left branch and draw it self.left(angle) self.lbranch(length, angle, level - 1) # draw right branch self.right(2 * angle) self.rbranch(length, angle, level - 1) # make node state-transparent self.left(angle) # TG p. 84 def lbranch(self, length, angle, level): # draw a long stem self.forward(2 * length) # do next level self.node(length, angle, level) # make lbranch state-transparent self.back (2 * length) # TG p. 84 def rbranch(self, length, angle, level): # draw a short stem self.forward(length) # do next level self.node(length, angle, level) # make lbranch state-transparent self.back (length) # VM p. 292 def tree(self, a, b, n, t, bt, f, l): if l < 1: return pos = self.getXY() self.fd(a) self.rt(t) for i in range(n): pos2 = self.getXY() self.fd(b) self.tree(a * f, b * f, n, t, bt, f, l - 1) #self.bk(b) self.setXY(pos2) self.lt(bt) self.rt((n * bt) - t) #self.moveTo(pos[0], pos[1]) self.setXY(pos) #self.bk(a) # VM p. 306 def randTree(self, a, n, t, bt, f, l): # to draw multiply branched recursive trees # with randomized components if l < 1: return # save the current position and angle pos = self.getXY() heading = self.getHeading() self.fd(uniform(0.5 * a, 1.5 * a)) self.rt(uniform(0.5 * t, 1.5 * t)) #self.fd(uniform(0.5 * t, 1.5 * t)) for i in range(n): d = uniform(0.5 * a / 2, 1.5 * a / 2) # save the position (not the heading) pos2 = self.getXY() self.fd(d) self.randTree(a * f, n, t, bt, f, l - 1) # restore the position self.setXY(pos2) self.lt(uniform(0.5 * bt, 1.5 * bt)) # restore the saved position and heading self.setXY(pos) self.setHeading(heading) def testTree(self, size): if size < 5: return self.fd(size) self.lt(30) self.testTree(size * .7) self.rt(60) self.testTree(size * .7) self.lt(30) self.bk(size) def testRTree(self, size): if size < 5: return self.fd(size) self.lt(30) self.testRTree(size * ((uniform(1, 5) + 5) / 10)) self.rt(60) self.testRTree(size * ((uniform(1, 5) + 5) / 10)) self.lt(30) self.bk(size) def draw(canvas): t = TreesTurtle(canvas) t.cls() t.left(90) #t.tree(80, 40, 4, 60, 30, .6, 5) #t.randTree(50, 3, 60, 30, .6, 4) #t.randTree(30, 3, 30, 30, .75, 5) #t.randTree(30, 3, 30, 15, .9, 5) t.pu() t.bk(150) t.pd() #t.testTree(75) t.testRTree(50) #t.lbranch(20, 20, 7) --- NEW FILE: chaosScript1.py --- from wrappers import Turtle def draw(canvas): t = Turtle(canvas) t.cls() autoRefreshTemp = t.canvas.autoRefresh t.canvas.autoRefresh = 0 xOffset = 50 yOffset = 0 scale = 1.0 r = 2.9 # when r was 4.0 I got an exception when doing the int # conversion below, so I need to consider the appropriate # behaviour when x or y is out of bounds for an int # and also out of bounds of the current cliprect or frame steps = 400 inc = (4.0 - 2.9) / steps for j in range(steps): r += inc x = 0.3 y = j + 30 for i in range(200): x = r * x * (1 - x) for i in range(300): x = r * x * (1 - x) x1 = int(500 * x) # originally self.plot(dc, x1, y1, xOffset, yOffset, scale) # the scale and offset stuff should probably # be part of the turtle or coordinate space x2 = int(xOffset + scale * x1) y2 = int(yOffset + scale * y) t.plot(x2, y2) t.canvas.refresh() t.canvas.autoRefresh = autoRefreshTemp --- ChaosScript1.txt DELETED --- --- NEW FILE: toitles.py --- from wrappers import Turtle def draw(canvas): t = Turtle(canvas) t.cls() namedColors = ['aquamarine', 'black', 'blue', 'blue violet', 'brown', 'cadet blue', 'coral', 'cornflower blue', 'cyan', 'dark grey', 'dark green', 'dark olive green', 'dark orchid', 'dark slate blue'] boids = [] for i in range(len(namedColors)): b = Turtle(canvas) b.moveTo(50, 50) #b.penUp() b.color(namedColors[i]) print namedColors[i] b.showTurtle() b.rt(5 * i) b.fd(10 * i) boids.append(b) autoRefreshTemp = boids[0].canvas.autoRefresh boids[0].canvas.autoRefresh = False for i in range(550): for b in boids: b.fd(1) boids[0].canvas.refresh() boids[0].canvas.autoRefresh = autoRefreshTemp --- coordinates.txt DELETED --- --- hilbert.txt DELETED --- --- NEW FILE: raceturtles.py --- # simple example to show putting multiple # turtles in a list and then applying the # same function to each one, in this case # "racing" them down the screen from wrappers import Turtle def draw(canvas): t = Turtle(canvas) t.cls() #print "On your mark, get set,", # don't make this larger than 255 # since we're using a different shade of red for each turtle # and there are only 256 shades :) maxTurtles = 200 tList = [] for i in range(maxTurtles): t = Turtle(canvas) t.moveTo((i + 1) * 3, 10) t.rt(90) t.color(i + (255 - maxTurtles), 0 , 0) # r, g, b color tList.append(t) autoRefreshTemp = tList[0].canvas.autoRefresh tList[0].canvas.autoRefresh = False #print "go!" for i in range(50): for t in tList: t.fd(10) tList[0].canvas.refresh() tList[0].canvas.autoRefresh = autoRefreshTemp --- kochCurves.txt DELETED --- --- TurtleScript2.txt DELETED --- --- originalbytedesign.txt DELETED --- --- NEW FILE: sun.py --- # examples derived from # Turtle Geometry: The Computer as a Medium for Exploring Mathematics # by Harold Abelson and Andrea diSessa from wrappers import Turtle class SunTurtle(Turtle): # p. 10 def arcr(self, r, deg): for i in range(deg): self.forward(r) self.right(1) # p. 11 def arcl(self, r, deg): for i in range(deg): self.forward(r) self.left(1) # p. 12 def ray(self, r): for i in range(2): self.arcr(r, 90) self.arcl(r, 90) """ self.arcl(r, 90) self.arcr(r, 90) self.arcl(r, 90) self.arcr(r, 90) """ # p. 12 def circles(self): for i in range(9): self.arcr(1, 360) self.right(40) # p. 12 def petal(self, size): self.arcr(size, 60) self.right(120) self.arcr(size, 60) self.right(120) # p. 12 def flower(self, size): for i in range(6): self.petal(size) self.right(60) # p. 12 def sun(self, size): for i in range(9): self.ray(size) self.rt(160) def draw(canvas): t = SunTurtle(canvas) t.cls() #t.circles() #t.flower(3) # simplify coding below by mapping the object methods pu = t.pu pd = t.pd rt = t.rt lt = t.lt fd = t.fd bk = t.bk sun = t.sun pu() lt(90) fd(225) rt(90) bk(100) pd() t.color('gold') sun(1.5) t.moveTo(10, 10) t.write("Good Morning!") |