From: Kevin A. <ka...@us...> - 2006-01-24 20:49:38
|
Update of /cvsroot/pythoncard/PythonCard/samples/life In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10097 Modified Files: life.py life.rsrc.py Log Message: made scale menu checkable Index: life.py =================================================================== RCS file: /cvsroot/pythoncard/PythonCard/samples/life/life.py,v retrieving revision 1.48 retrieving revision 1.49 diff -C2 -d -r1.48 -r1.49 *** life.py 13 Dec 2005 11:13:23 -0000 1.48 --- life.py 24 Jan 2006 20:49:27 -0000 1.49 *************** *** 34,38 **** # mouseClick after file dialog self.openingFileDialog = False ! self.setCanvasAttributes(5) self.initSizers() --- 34,43 ---- # mouseClick after file dialog self.openingFileDialog = False ! scale = self.getScaleFromMenu() ! if scale: ! self.setCanvasAttributes(self.getScaleFromMenu()) ! else: ! self.menuBar.setChecked('menuScale5') ! self.setCanvasAttributes(5) self.initSizers() *************** *** 395,400 **** event.skip() def on_setScale_command(self, event): ! self.setCanvasAttributes(int(event.target.name[9:])) self.displayGeneration() --- 400,421 ---- event.skip() + # it would be nice to get the scales from the resource file + # rather than hard coding them here + # that should be possible by walking the resource or the Scale menu + # looking for a prefix menu item name of 'menuScale' + def getScaleFromMenu(self): + for i in [1, 2, 3, 4, 5, 10]: + if self.menuBar.getChecked('menuScale' + str(i)): + return i + + def uncheckScaleMenuItems(self, scale): + for i in [1, 2, 3, 4, 5, 10]: + if i != scale: + self.menuBar.setChecked('menuScale' + str(i), False) + def on_setScale_command(self, event): ! scale = int(event.target.name[9:]) ! self.uncheckScaleMenuItems(scale) ! self.setCanvasAttributes(scale) self.displayGeneration() Index: life.rsrc.py =================================================================== RCS file: /cvsroot/pythoncard/PythonCard/samples/life/life.rsrc.py,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** life.rsrc.py 28 Sep 2004 05:00:26 -0000 1.7 --- life.rsrc.py 24 Jan 2006 20:49:27 -0000 1.8 *************** *** 1,125 **** ! { 'application':{ 'type':'Application', ! 'name':'Life', ! 'backgrounds': ! [ ! { 'type':'Background', ! 'name':'bgLife', ! 'title':'Life PythonCard Application', ! 'size':( 310, 300 ), ! 'statusBar':1, ! 'style':['resizeable'], ! 'menubar': ! { ! 'type':'MenuBar', ! 'menus': ! [ ! { 'type':'Menu', ! 'name':'menuFile', ! 'label':'&File', ! 'items': [ ! { 'type':'MenuItem', ! 'name':'menuFileOpen', ! 'label':'&Open...\tCtrl+O' }, ! { 'type':'MenuItem', ! 'name':'menuFileSaveAs', ! 'enabled':0, ! 'label':'Save &As...' }, ! { 'type':'MenuItem', 'name':'fileSep1', 'label':'-' }, ! { 'type':'MenuItem', ! 'name':'menuFileExit', ! 'label':'E&xit\tAlt+X', ! 'command':'exit' } ] }, ! { 'type':'Menu', ! 'name':'menuEdit', ! 'label':'&Edit', ! 'items': [ ! { 'type':'MenuItem', ! 'name':'menuEditCopy', ! 'label':'&Copy\tCtrl+C'}, ! { 'type':'MenuItem', ! 'name':'menuEditPaste', ! 'label':'&Paste\tCtrl+V'}, ! { 'type':'MenuItem', 'name':'editSep1', 'label':'-' }, ! { 'type':'MenuItem', ! 'name':'menuEditClear', ! 'label':'&Clear', ! 'command':'editClear'} ! ] }, ! { 'type':'Menu', ! 'name':'menuAutomata', ! 'label':'&Automata', ! 'items': [ ! { 'type':'MenuItem', ! 'name':'menuAutomataLife', ! 'label':"Conway's Life...", ! 'command':'doAutomata'}, ! { 'type':'MenuItem', ! 'name':'menuAutomataLexicon', ! 'label':"Lexicon Window"}, ! { 'type':'MenuItem', ! 'name':'menuAutomataPatternsList', ! 'label':"Patterns List Window"}, ! { 'type':'MenuItem', 'name':'automataSep1', 'label':'-' }, ! { 'type':'MenuItem', ! 'name':'menuAutomataDownloadLexiconAndPatterns', ! 'label':"Download Lexicon and Patterns"}, ! ] }, ! { 'type':'Menu', ! 'name':'menuFile', ! 'label':'&Scale', ! 'items': [ ! { 'type':'MenuItem', ! 'name':'menuScale1', ! 'command':'setScale', ! 'label':'1' }, ! { 'type':'MenuItem', ! 'name':'menuScale2', ! 'command':'setScale', ! 'label':'2' }, ! { 'type':'MenuItem', ! 'name':'menuScale3', ! 'command':'setScale', ! 'label':'3' }, ! { 'type':'MenuItem', ! 'name':'menuScale4', ! 'command':'setScale', ! 'label':'4' }, ! { 'type':'MenuItem', ! 'name':'menuScale5', ! 'command':'setScale', ! 'label':'5' }, ! { 'type':'MenuItem', ! 'name':'menuScale10', ! 'command':'setScale', ! 'label':'10' }, ! ] }, ! ] }, ! 'components': ! [ ! { 'type':'Button', ! 'name':'btnStart', ! 'position':(0, 0), ! 'label':'Start' }, ! { 'type':'Button', ! 'name':'btnStop', ! 'position':(100, 0), ! 'label':'Stop' }, ! { 'type':'Button', ! 'name':'btnStep', ! 'position':(200, 0), ! 'label':'Step' }, ! { 'type':'BitmapCanvas', ! 'name':'bufOff', ! 'position':(0, 30), ! 'size':(600, 400) }, ! ] ! } ! ] ! } ! } --- 1,162 ---- + {'application':{'type':'Application', + 'name':'Life', + 'backgrounds': [ + {'type':'Background', + 'name':'bgLife', + 'title':'Life PythonCard Application', + 'size':(310, 300), + 'statusBar':1, + 'style':['resizeable'], ! 'menubar': {'type':'MenuBar', ! 'menus': [ ! {'type':'Menu', ! 'name':'menuFile', ! 'label':'&File', ! 'items': [ ! {'type':'MenuItem', ! 'name':'menuFileOpen', ! 'label':'&Open...\tCtrl+O', ! }, ! {'type':'MenuItem', ! 'name':'menuFileSaveAs', ! 'label':'Save &As...', ! 'enabled':0, ! }, ! {'type':'MenuItem', ! 'name':'fileSep1', ! 'label':'-', ! }, ! {'type':'MenuItem', ! 'name':'menuFileExit', ! 'label':'E&xit\tAlt+X', ! 'command':'exit', ! }, ! ] ! }, ! {'type':'Menu', ! 'name':'menuEdit', ! 'label':'&Edit', ! 'items': [ ! {'type':'MenuItem', ! 'name':'menuEditCopy', ! 'label':'&Copy\tCtrl+C', ! }, ! {'type':'MenuItem', ! 'name':'menuEditPaste', ! 'label':'&Paste\tCtrl+V', ! }, ! {'type':'MenuItem', ! 'name':'editSep1', ! 'label':'-', ! }, ! {'type':'MenuItem', ! 'name':'menuEditClear', ! 'label':'&Clear', ! 'command':'editClear', ! }, ! ] ! }, ! {'type':'Menu', ! 'name':'menuAutomata', ! 'label':'&Automata', ! 'items': [ ! {'type':'MenuItem', ! 'name':'menuAutomataLife', ! 'label':"Conway's Life...", ! 'command':'doAutomata', ! }, ! {'type':'MenuItem', ! 'name':'menuAutomataLexicon', ! 'label':'Lexicon Window', ! }, ! {'type':'MenuItem', ! 'name':'menuAutomataPatternsList', ! 'label':'Patterns List Window', ! }, ! {'type':'MenuItem', ! 'name':'automataSep1', ! 'label':'-', ! }, ! {'type':'MenuItem', ! 'name':'menuAutomataDownloadLexiconAndPatterns', ! 'label':'Download Lexicon and Patterns', ! }, ! ] ! }, ! {'type':'Menu', ! 'name':'menuFile', ! 'label':'&Scale', ! 'items': [ ! {'type':'MenuItem', ! 'name':'menuScale1', ! 'label':'1', ! 'command':'setScale', ! 'checkable':1, ! }, ! {'type':'MenuItem', ! 'name':'menuScale2', ! 'label':'2', ! 'command':'setScale', ! 'checkable':1, ! }, ! {'type':'MenuItem', ! 'name':'menuScale3', ! 'label':'3', ! 'command':'setScale', ! 'checkable':1, ! }, ! {'type':'MenuItem', ! 'name':'menuScale4', ! 'label':'4', ! 'command':'setScale', ! 'checkable':1, ! }, ! {'type':'MenuItem', ! 'name':'menuScale5', ! 'label':'5', ! 'command':'setScale', ! 'checkable':1, ! 'checked':1, ! }, ! {'type':'MenuItem', ! 'name':'menuScale10', ! 'label':'10', ! 'command':'setScale', ! 'checkable':1, ! }, ! ] ! }, ! ] ! }, ! 'components': [ ! {'type':'Button', ! 'name':'btnStart', ! 'position':(0, 0), ! 'label':'Start', ! }, ! {'type':'Button', ! 'name':'btnStop', ! 'position':(100, 0), ! 'label':'Stop', }, ! {'type':'Button', ! 'name':'btnStep', ! 'position':(200, 0), ! 'label':'Step', ! }, + {'type':'BitmapCanvas', + 'name':'bufOff', + 'position':(0, 30), + 'size':(600, 400), + 'backgroundColor':(255, 255, 255), + }, + + ] # end components + } # end background + ] # end backgrounds + } } |