]> git.saurik.com Git - wxWidgets.git/commitdiff
Some little tweaks to PyCrust
authorRobin Dunn <robin@alldunn.com>
Thu, 8 Aug 2002 22:33:57 +0000 (22:33 +0000)
committerRobin Dunn <robin@alldunn.com>
Thu, 8 Aug 2002 22:33:57 +0000 (22:33 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@16428 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

wxPython/wxPython/lib/PyCrust/PyCrustApp.py
wxPython/wxPython/lib/PyCrust/PyShellApp.py
wxPython/wxPython/lib/PyCrust/crust.py
wxPython/wxPython/lib/PyCrust/shell.py

index c6b93c7d14a7219283f48bbb0afa0bf2c19d34c3..9e691ec6a792e91c7db2fcc6001df726064aca8a 100755 (executable)
@@ -13,8 +13,10 @@ class App(wxApp):
     """PyCrust standalone application."""
 
     def OnInit(self):
     """PyCrust standalone application."""
 
     def OnInit(self):
+        wxInitAllImageHandlers()
         locals = {'__app__': 'PyCrust Standalone Application'}
         self.crustFrame = CrustFrame(locals=locals)
         locals = {'__app__': 'PyCrust Standalone Application'}
         self.crustFrame = CrustFrame(locals=locals)
+        self.crustFrame.SetSize((750, 525))
         self.crustFrame.Show(true)
         self.SetTopWindow(self.crustFrame)
         # Add the application object to the sys module's namespace.
         self.crustFrame.Show(true)
         self.SetTopWindow(self.crustFrame)
         # Add the application object to the sys module's namespace.
index 04568c26f56f98544938ae49833c21d68cc7655d..0113b77c7b1d4e0888fa0e9963bfe404b3f83ba7 100755 (executable)
@@ -13,8 +13,10 @@ class App(wxApp):
     """PyShell standalone application."""
 
     def OnInit(self):
     """PyShell standalone application."""
 
     def OnInit(self):
+        wxInitAllImageHandlers()
         locals = {'__app__': 'PyShell Standalone Application'}
         self.shellFrame = ShellFrame(locals=locals)
         locals = {'__app__': 'PyShell Standalone Application'}
         self.shellFrame = ShellFrame(locals=locals)
+        self.shellFrame.SetSize((750, 525))
         self.shellFrame.Show(true)
         self.SetTopWindow(self.shellFrame)
         # Add the application object to the sys module's namespace.
         self.shellFrame.Show(true)
         self.SetTopWindow(self.shellFrame)
         # Add the application object to the sys module's namespace.
index 9a8703738cc3e4fef62828c1c1d3df2729a9db50..23235b2619402b01c8e8f2001d3e2abee9860e4a 100644 (file)
@@ -12,10 +12,10 @@ from version import VERSION
 
 class Crust(wxSplitterWindow):
     """PyCrust Crust based on wxSplitterWindow."""
 
 class Crust(wxSplitterWindow):
     """PyCrust Crust based on wxSplitterWindow."""
-    
+
     name = 'PyCrust Crust'
     revision = __revision__
     name = 'PyCrust Crust'
     revision = __revision__
-    
+
     def __init__(self, parent, id=-1, pos=wxDefaultPosition, \
                  size=wxDefaultSize, style=wxSP_3D, name='Crust Window', \
                  rootObject=None, rootLabel=None, rootIsNamespace=1, \
     def __init__(self, parent, id=-1, pos=wxDefaultPosition, \
                  size=wxDefaultSize, style=wxSP_3D, name='Crust Window', \
                  rootObject=None, rootLabel=None, rootIsNamespace=1, \
@@ -40,10 +40,10 @@ from shell import ShellMenu
 
 class CrustFrame(wxFrame, ShellMenu):
     """Frame containing all the PyCrust components."""
 
 class CrustFrame(wxFrame, ShellMenu):
     """Frame containing all the PyCrust components."""
-    
+
     name = 'PyCrust Frame'
     revision = __revision__
     name = 'PyCrust Frame'
     revision = __revision__
-    
+
     def __init__(self, parent=None, id=-1, title='PyCrust', \
                  pos=wxDefaultPosition, size=wxDefaultSize, \
                  style=wxDEFAULT_FRAME_STYLE, \
     def __init__(self, parent=None, id=-1, title='PyCrust', \
                  pos=wxDefaultPosition, size=wxDefaultSize, \
                  style=wxDEFAULT_FRAME_STYLE, \
@@ -55,11 +55,12 @@ class CrustFrame(wxFrame, ShellMenu):
         intro += '\nSponsored by Orbtech - Your source for Python programming expertise.'
         self.CreateStatusBar()
         self.SetStatusText(intro.replace('\n', ', '))
         intro += '\nSponsored by Orbtech - Your source for Python programming expertise.'
         self.CreateStatusBar()
         self.SetStatusText(intro.replace('\n', ', '))
-        if wxPlatform == '__WXMSW__':
-            import os
-            filename = os.path.join(os.path.dirname(__file__), 'PyCrust.ico')
-            icon = wxIcon(filename, wxBITMAP_TYPE_ICO)
-            self.SetIcon(icon)
+
+        import os
+        filename = os.path.join(os.path.dirname(__file__), 'PyCrust.ico')
+        icon = wxIcon(filename, wxBITMAP_TYPE_ICO)
+        self.SetIcon(icon)
+
         self.crust = Crust(parent=self, intro=intro, \
                            rootObject=rootObject, \
                            rootLabel=rootLabel, \
         self.crust = Crust(parent=self, intro=intro, \
                            rootObject=rootObject, \
                            rootLabel=rootLabel, \
@@ -79,4 +80,4 @@ class CrustFrame(wxFrame, ShellMenu):
         self.createMenus()
 
 
         self.createMenus()
 
 
-   
+
index 79ce1ca33117e061a14e90b78afd50a561989f46..b96ea802184329570a22d9af71d8b0b8bec90997 100644 (file)
@@ -48,12 +48,12 @@ else:  # GTK
 class ShellFacade:
     """Simplified interface to all shell-related functionality.
 
 class ShellFacade:
     """Simplified interface to all shell-related functionality.
 
-    This is a semi-transparent facade, in that all attributes of other are 
+    This is a semi-transparent facade, in that all attributes of other are
     still accessible, even though only some are visible to the user."""
     still accessible, even though only some are visible to the user."""
-    
+
     name = 'PyCrust Shell Interface'
     revision = __revision__
     name = 'PyCrust Shell Interface'
     revision = __revision__
-    
+
     def __init__(self, other):
         """Create a ShellFacade instance."""
         methods = ['ask',
     def __init__(self, other):
         """Create a ShellFacade instance."""
         methods = ['ask',
@@ -126,10 +126,10 @@ F8                Command-completion of History item.
 
 class Shell(wxStyledTextCtrl):
     """PyCrust Shell based on wxStyledTextCtrl."""
 
 class Shell(wxStyledTextCtrl):
     """PyCrust Shell based on wxStyledTextCtrl."""
-    
+
     name = 'PyCrust Shell'
     revision = __revision__
     name = 'PyCrust Shell'
     revision = __revision__
-    
+
     def __init__(self, parent, id=-1, pos=wxDefaultPosition, \
                  size=wxDefaultSize, style=wxCLIP_CHILDREN, introText='', \
                  locals=None, InterpClass=None, *args, **kwds):
     def __init__(self, parent, id=-1, pos=wxDefaultPosition, \
                  size=wxDefaultSize, style=wxCLIP_CHILDREN, introText='', \
                  locals=None, InterpClass=None, *args, **kwds):
@@ -147,7 +147,7 @@ class Shell(wxStyledTextCtrl):
         else:
             Interpreter = InterpClass
         # Create default locals so we have something interesting.
         else:
             Interpreter = InterpClass
         # Create default locals so we have something interesting.
-        shellLocals = {'__name__': 'PyCrust-Shell', 
+        shellLocals = {'__name__': 'PyCrust-Shell',
                        '__doc__': 'PyCrust-Shell, The PyCrust Python Shell.',
                        '__version__': VERSION,
                       }
                        '__doc__': 'PyCrust-Shell, The PyCrust Python Shell.',
                        '__version__': VERSION,
                       }
@@ -196,12 +196,12 @@ class Shell(wxStyledTextCtrl):
 
     def destroy(self):
         del self.interp
 
     def destroy(self):
         del self.interp
-        
+
     def config(self):
         """Configure shell based on user preferences."""
         self.SetMarginType(1, wxSTC_MARGIN_NUMBER)
         self.SetMarginWidth(1, 40)
     def config(self):
         """Configure shell based on user preferences."""
         self.SetMarginType(1, wxSTC_MARGIN_NUMBER)
         self.SetMarginWidth(1, 40)
-        
+
         self.SetLexer(wxSTC_LEX_PYTHON)
         self.SetKeyWords(0, ' '.join(keyword.kwlist))
 
         self.SetLexer(wxSTC_LEX_PYTHON)
         self.SetKeyWords(0, ' '.join(keyword.kwlist))
 
@@ -229,10 +229,10 @@ class Shell(wxStyledTextCtrl):
             self.write(self.interp.introText)
         except AttributeError:
             pass
             self.write(self.interp.introText)
         except AttributeError:
             pass
-    
+
     def setBuiltinKeywords(self):
         """Create pseudo keywords as part of builtins.
     def setBuiltinKeywords(self):
         """Create pseudo keywords as part of builtins.
-        
+
         This simply sets "close", "exit" and "quit" to a helpful string.
         """
         import __builtin__
         This simply sets "close", "exit" and "quit" to a helpful string.
         """
         import __builtin__
@@ -241,19 +241,19 @@ class Shell(wxStyledTextCtrl):
 
     def quit(self):
         """Quit the application."""
 
     def quit(self):
         """Quit the application."""
-        
+
         # XXX Good enough for now but later we want to send a close event.
         # XXX Good enough for now but later we want to send a close event.
-        
+
         # In the close event handler we can make sure they want to quit.
         # Other applications, like PythonCard, may choose to hide rather than
         # quit so we should just post the event and let the surrounding app
         # decide what it wants to do.
         self.write('Click on the close button to leave the application.')
         # In the close event handler we can make sure they want to quit.
         # Other applications, like PythonCard, may choose to hide rather than
         # quit so we should just post the event and let the surrounding app
         # decide what it wants to do.
         self.write('Click on the close button to leave the application.')
-    
+
     def setLocalShell(self):
         """Add 'shell' to locals as reference to ShellFacade instance."""
         self.interp.locals['shell'] = ShellFacade(other=self)
     def setLocalShell(self):
         """Add 'shell' to locals as reference to ShellFacade instance."""
         self.interp.locals['shell'] = ShellFacade(other=self)
-    
+
     def execStartupScript(self, startupScript):
         """Execute the user's PYTHONSTARTUP script if they have one."""
         if startupScript and os.path.isfile(startupScript):
     def execStartupScript(self, startupScript):
         """Execute the user's PYTHONSTARTUP script if they have one."""
         if startupScript and os.path.isfile(startupScript):
@@ -262,10 +262,10 @@ class Shell(wxStyledTextCtrl):
                       (`startupText`, `startupScript`))
         else:
             self.push('')
                       (`startupText`, `startupScript`))
         else:
             self.push('')
-            
+
     def setStyles(self, faces):
         """Configure font size, typeface and color for lexer."""
     def setStyles(self, faces):
         """Configure font size, typeface and color for lexer."""
-        
+
         # Default style
         self.StyleSetSpec(wxSTC_STYLE_DEFAULT, "face:%(mono)s,size:%(size)d,back:%(backcol)s" % faces)
 
         # Default style
         self.StyleSetSpec(wxSTC_STYLE_DEFAULT, "face:%(mono)s,size:%(size)d,back:%(backcol)s" % faces)
 
@@ -533,7 +533,7 @@ class Shell(wxStyledTextCtrl):
 
     def setStatusText(self, text):
         """Display status information."""
 
     def setStatusText(self, text):
         """Display status information."""
-        
+
         # This method will most likely be replaced by the enclosing app
         # to do something more interesting, like write to a status bar.
         print text
         # This method will most likely be replaced by the enclosing app
         # to do something more interesting, like write to a status bar.
         print text
@@ -547,11 +547,11 @@ class Shell(wxStyledTextCtrl):
 
     def processLine(self):
         """Process the line of text at which the user hit Enter."""
 
     def processLine(self):
         """Process the line of text at which the user hit Enter."""
-        
+
         # The user hit ENTER and we need to decide what to do. They could be
         # sitting on any line in the shell.
 
         # The user hit ENTER and we need to decide what to do. They could be
         # sitting on any line in the shell.
 
-        thepos = self.GetCurrentPos()        
+        thepos = self.GetCurrentPos()
         startpos = self.promptPosEnd
         endpos = self.GetTextLength()
         # If they hit RETURN inside the current command, execute the command.
         startpos = self.promptPosEnd
         endpos = self.GetTextLength()
         # If they hit RETURN inside the current command, execute the command.
@@ -577,7 +577,7 @@ class Shell(wxStyledTextCtrl):
 
     def getMultilineCommand(self, rstrip=1):
         """Extract a multi-line command from the editor.
 
     def getMultilineCommand(self, rstrip=1):
         """Extract a multi-line command from the editor.
-        
+
         The command may not necessarily be valid Python syntax."""
         # XXX Need to extract real prompts here. Need to keep track of the
         # prompt every time a command is issued.
         The command may not necessarily be valid Python syntax."""
         # XXX Need to extract real prompts here. Need to keep track of the
         # prompt every time a command is issued.
@@ -611,10 +611,10 @@ class Shell(wxStyledTextCtrl):
         if rstrip:
             command = command.rstrip()
         return command
         if rstrip:
             command = command.rstrip()
         return command
-    
+
     def getCommand(self, text=None, rstrip=1):
         """Extract a command from text which may include a shell prompt.
     def getCommand(self, text=None, rstrip=1):
         """Extract a command from text which may include a shell prompt.
-        
+
         The command may not necessarily be valid Python syntax."""
         if not text:
             text = self.GetCurLine()[0]
         The command may not necessarily be valid Python syntax."""
         if not text:
             text = self.GetCurLine()[0]
@@ -638,7 +638,7 @@ class Shell(wxStyledTextCtrl):
         elif text[:ps2size] == ps2:
             text = text[ps2size:]
         return text
         elif text[:ps2size] == ps2:
             text = text[ps2size:]
         return text
-    
+
     def push(self, command):
         """Send command to the interpreter for execution."""
         self.write(os.linesep)
     def push(self, command):
         """Send command to the interpreter for execution."""
         self.write(os.linesep)
@@ -678,7 +678,7 @@ class Shell(wxStyledTextCtrl):
 
     def prompt(self):
         """Display appropriate prompt for the context, either ps1 or ps2.
 
     def prompt(self):
         """Display appropriate prompt for the context, either ps1 or ps2.
-        
+
         If this is a continuation line, autoindent as necessary."""
         if self.more:
             prompt = str(sys.ps2)
         If this is a continuation line, autoindent as necessary."""
         if self.more:
             prompt = str(sys.ps2)
@@ -728,25 +728,25 @@ class Shell(wxStyledTextCtrl):
     def ask(self, prompt='Please enter your response:'):
         """Get response from the user."""
         return raw_input(prompt=prompt)
     def ask(self, prompt='Please enter your response:'):
         """Get response from the user."""
         return raw_input(prompt=prompt)
-        
+
     def pause(self):
         """Halt execution pending a response from the user."""
         self.ask('Press enter to continue:')
     def pause(self):
         """Halt execution pending a response from the user."""
         self.ask('Press enter to continue:')
-        
+
     def clear(self):
         """Delete all text from the shell."""
         self.ClearAll()
     def clear(self):
         """Delete all text from the shell."""
         self.ClearAll()
-        
+
     def run(self, command, prompt=1, verbose=1):
         """Execute command within the shell as if it was typed in directly.
         >>> shell.run('print "this"')
         >>> print "this"
         this
     def run(self, command, prompt=1, verbose=1):
         """Execute command within the shell as if it was typed in directly.
         >>> shell.run('print "this"')
         >>> print "this"
         this
-        >>> 
+        >>>
         """
         # Go to the very bottom of the text.
         endpos = self.GetTextLength()
         """
         # Go to the very bottom of the text.
         endpos = self.GetTextLength()
-        self.SetCurrentPos(endpos)        
+        self.SetCurrentPos(endpos)
         command = command.rstrip()
         if prompt: self.prompt()
         if verbose: self.write(command)
         command = command.rstrip()
         if prompt: self.prompt()
         if verbose: self.write(command)
@@ -764,7 +764,7 @@ class Shell(wxStyledTextCtrl):
                     self.run(command, prompt=0, verbose=1)
         finally:
             file.close()
                     self.run(command, prompt=0, verbose=1)
         finally:
             file.close()
-    
+
     def autoCompleteShow(self, command):
         """Display auto-completion popup list."""
         list = self.interp.getAutoCompleteList(command, 
     def autoCompleteShow(self, command):
         """Display auto-completion popup list."""
         list = self.interp.getAutoCompleteList(command, 
@@ -796,11 +796,11 @@ class Shell(wxStyledTextCtrl):
     def writeOut(self, text):
         """Replacement for stdout."""
         self.write(text)
     def writeOut(self, text):
         """Replacement for stdout."""
         self.write(text)
-    
+
     def writeErr(self, text):
         """Replacement for stderr."""
         self.write(text)
     def writeErr(self, text):
         """Replacement for stderr."""
         self.write(text)
-    
+
     def redirectStdin(self, redirect=1):
         """If redirect is true then sys.stdin will come from the shell."""
         if redirect:
     def redirectStdin(self, redirect=1):
         """If redirect is true then sys.stdin will come from the shell."""
         if redirect:
@@ -830,7 +830,7 @@ class Shell(wxStyledTextCtrl):
             return 1
         else:
             return 0
             return 1
         else:
             return 0
-    
+
     def CanCopy(self):
         """Return true if text is selected and can be copied."""
         return self.GetSelectionStart() != self.GetSelectionEnd()
     def CanCopy(self):
         """Return true if text is selected and can be copied."""
         return self.GetSelectionStart() != self.GetSelectionEnd()
@@ -926,7 +926,7 @@ class Shell(wxStyledTextCtrl):
                             command += '\n'
                             command += line
                     commands.append(command)
                             command += '\n'
                             command += line
                     commands.append(command)
-                    for command in commands:    
+                    for command in commands:
                         command = command.replace('\n', os.linesep + sys.ps2)
                         self.write(command)
                         self.processLine()
                         command = command.replace('\n', os.linesep + sys.ps2)
                         self.write(command)
                         self.processLine()
@@ -945,7 +945,7 @@ ID_CALLTIPS_SHOW = NewId()
 
 class ShellMenu:
     """Mixin class to add standard menu items."""
 
 class ShellMenu:
     """Mixin class to add standard menu items."""
-    
+
     def createMenus(self):
         m = self.fileMenu = wxMenu()
         m.AppendSeparator()
     def createMenus(self):
         m = self.fileMenu = wxMenu()
         m.AppendSeparator()
@@ -1106,14 +1106,14 @@ class ShellMenu:
             event.Check(self.shell.autoCompleteIncludeDouble)
         elif id == ID_CALLTIPS_SHOW:
             event.Check(self.shell.autoCallTip)
             event.Check(self.shell.autoCompleteIncludeDouble)
         elif id == ID_CALLTIPS_SHOW:
             event.Check(self.shell.autoCallTip)
-            
+
 
 class ShellFrame(wxFrame, ShellMenu):
     """Frame containing the PyCrust shell component."""
 
 class ShellFrame(wxFrame, ShellMenu):
     """Frame containing the PyCrust shell component."""
-    
+
     name = 'PyCrust Shell Frame'
     revision = __revision__
     name = 'PyCrust Shell Frame'
     revision = __revision__
-    
+
     def __init__(self, parent=None, id=-1, title='PyShell', \
                  pos=wxDefaultPosition, size=wxDefaultSize, \
                  style=wxDEFAULT_FRAME_STYLE, locals=None, \
     def __init__(self, parent=None, id=-1, title='PyShell', \
                  pos=wxDefaultPosition, size=wxDefaultSize, \
                  style=wxDEFAULT_FRAME_STYLE, locals=None, \
@@ -1124,11 +1124,12 @@ class ShellFrame(wxFrame, ShellMenu):
         intro += '\nSponsored by Orbtech - Your source for Python programming expertise.'
         self.CreateStatusBar()
         self.SetStatusText(intro.replace('\n', ', '))
         intro += '\nSponsored by Orbtech - Your source for Python programming expertise.'
         self.CreateStatusBar()
         self.SetStatusText(intro.replace('\n', ', '))
-        if wxPlatform == '__WXMSW__':
-            import os
-            filename = os.path.join(os.path.dirname(__file__), 'PyCrust.ico')
-            icon = wxIcon(filename, wxBITMAP_TYPE_ICO)
-            self.SetIcon(icon)
+
+        import os
+        filename = os.path.join(os.path.dirname(__file__), 'PyCrust.ico')
+        icon = wxIcon(filename, wxBITMAP_TYPE_ICO)
+        self.SetIcon(icon)
+
         self.shell = Shell(parent=self, id=-1, introText=intro, \
                            locals=locals, InterpClass=InterpClass, \
                            *args, **kwds)
         self.shell = Shell(parent=self, id=-1, introText=intro, \
                            locals=locals, InterpClass=InterpClass, \
                            *args, **kwds)
@@ -1137,5 +1138,5 @@ class ShellFrame(wxFrame, ShellMenu):
         self.createMenus()
 
 
         self.createMenus()
 
 
-           
-    
+
+