A few little cleanups, etc.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@14959 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robin Dunn
2002-04-05 20:55:53 +00:00
parent a8e65eeeae
commit f60765b0fc
4 changed files with 61 additions and 56 deletions

View File

@@ -122,6 +122,7 @@ Source: "demo\data\*.txt"; DestDir: "{app}\wxPython\demo\data";
Source: "demo\data\*.wav"; DestDir: "{app}\wxPython\demo\data"; Components: demo Source: "demo\data\*.wav"; DestDir: "{app}\wxPython\demo\data"; Components: demo
Source: "demo\data\*.wdr"; DestDir: "{app}\wxPython\demo\data"; Components: demo Source: "demo\data\*.wdr"; DestDir: "{app}\wxPython\demo\data"; Components: demo
Source: "demo\data\*.xrc"; DestDir: "{app}\wxPython\demo\data"; Components: demo Source: "demo\data\*.xrc"; DestDir: "{app}\wxPython\demo\data"; Components: demo
Source: "demo\data\*.gif"; DestDir: "{app}\wxPython\demo\data"; Components: demo
Source: "demo\dllwidget\*.cpp"; DestDir: "{app}\wxPython\demo\dllwidget"; Components: demo Source: "demo\dllwidget\*.cpp"; DestDir: "{app}\wxPython\demo\dllwidget"; Components: demo
Source: "demo\dllwidget\*.py"; DestDir: "{app}\wxPython\demo\dllwidget"; Components: demo Source: "demo\dllwidget\*.py"; DestDir: "{app}\wxPython\demo\dllwidget"; Components: demo

View File

@@ -854,6 +854,9 @@ public:
// or output encoding is not supported.) // or output encoding is not supported.)
bool Init(wxFontEncoding input_enc, wxFontEncoding output_enc, int method = wxCONVERT_STRICT); bool Init(wxFontEncoding input_enc, wxFontEncoding output_enc, int method = wxCONVERT_STRICT);
// TODO: Need to do something about unicode mode...
// Convert input string according to settings passed to Init. // Convert input string according to settings passed to Init.
// Note that you must call Init before using Convert! // Note that you must call Init before using Convert!
wxString Convert(const wxString& input); wxString Convert(const wxString& input);
@@ -868,6 +871,7 @@ public:
// #endif // #endif
// Return equivalent(s) for given font that are used // Return equivalent(s) for given font that are used
// under given platform. wxPLATFORM_CURRENT means the plaform // under given platform. wxPLATFORM_CURRENT means the plaform
// this binary was compiled for // this binary was compiled for

View File

@@ -1058,18 +1058,18 @@ class Frame(wxFrame):
# Create toolbar # Create toolbar
tb = self.CreateToolBar(wxTB_HORIZONTAL | wxNO_BORDER | wxTB_FLAT) tb = self.CreateToolBar(wxTB_HORIZONTAL | wxNO_BORDER | wxTB_FLAT)
tb.SetToolBitmapSize((24, 23)) tb.SetToolBitmapSize((24, 23))
tb.AddSimpleTool(wxID_NEW, '', images.getNewBitmap(), 'New', 'New file') tb.AddSimpleTool(wxID_NEW, images.getNewBitmap(), 'New', 'New file')
tb.AddSimpleTool(wxID_OPEN, '', images.getOpenBitmap(), 'Open', 'Open file') tb.AddSimpleTool(wxID_OPEN, images.getOpenBitmap(), 'Open', 'Open file')
tb.AddSimpleTool(wxID_SAVE, '', images.getSaveBitmap(), 'Save', 'Save file') tb.AddSimpleTool(wxID_SAVE, images.getSaveBitmap(), 'Save', 'Save file')
tb.AddControl(wxStaticLine(tb, -1, size=(-1,23), style=wxLI_VERTICAL)) tb.AddControl(wxStaticLine(tb, -1, size=(-1,23), style=wxLI_VERTICAL))
tb.AddSimpleTool(wxID_CUT, '', images.getCutBitmap(), 'Cut', 'Cut') tb.AddSimpleTool(wxID_CUT, images.getCutBitmap(), 'Cut', 'Cut')
tb.AddSimpleTool(wxID_COPY, '', images.getCopyBitmap(), 'Copy', 'Copy') tb.AddSimpleTool(wxID_COPY, images.getCopyBitmap(), 'Copy', 'Copy')
tb.AddSimpleTool(wxID_PASTE, '', images.getPasteBitmap(), 'Paste', 'Paste') tb.AddSimpleTool(wxID_PASTE, images.getPasteBitmap(), 'Paste', 'Paste')
tb.AddControl(wxStaticLine(tb, -1, size=(-1,23), style=wxLI_VERTICAL)) tb.AddControl(wxStaticLine(tb, -1, size=(-1,23), style=wxLI_VERTICAL))
tb.AddSimpleTool(self.ID_TEST, '', images.getTestBitmap(), 'Test', 'Test window') tb.AddSimpleTool(self.ID_TEST, images.getTestBitmap(), 'Test', 'Test window')
tb.AddSimpleTool(self.ID_REFRESH, '', images.getRefreshBitmap(), tb.AddSimpleTool(self.ID_REFRESH, images.getRefreshBitmap(),
'Refresh', 'Refresh view') 'Refresh', 'Refresh view')
tb.AddSimpleTool(self.ID_AUTO_REFRESH, '', images.getAutoRefreshBitmap(), tb.AddSimpleTool(self.ID_AUTO_REFRESH, images.getAutoRefreshBitmap(),
'Auto-refresh', 'Toggle auto-refresh mode', true) 'Auto-refresh', 'Toggle auto-refresh mode', true)
if wxGetOsVersion()[0] == wxGTK: if wxGetOsVersion()[0] == wxGTK:
tb.AddSeparator() # otherwise auto-refresh sticks in status line tb.AddSeparator() # otherwise auto-refresh sticks in status line
@@ -1910,7 +1910,7 @@ class App(wxApp):
wc.Flush() wc.Flush()
def main(): def main():
app = App(0) app = App()
app.MainLoop() app.MainLoop()
app.OnExit() app.OnExit()

View File

@@ -48,12 +48,12 @@ else: # GTK
class ShellFacade: class ShellFacade:
"""Simplified interface to all shell-related functionality. """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' name = 'PyCrust Shell Interface'
revision = __version__ revision = __version__
def __init__(self, other): def __init__(self, other):
"""Create a ShellFacade instance.""" """Create a ShellFacade instance."""
methods = ['ask', methods = ['ask',
@@ -126,10 +126,10 @@ F8 Command-completion of History item.
class Shell(wxStyledTextCtrl): class Shell(wxStyledTextCtrl):
"""PyCrust Shell based on wxStyledTextCtrl.""" """PyCrust Shell based on wxStyledTextCtrl."""
name = 'PyCrust Shell' name = 'PyCrust Shell'
revision = __version__ revision = __version__
def __init__(self, parent, id=-1, pos=wxDefaultPosition, \ def __init__(self, parent, id=-1, pos=wxDefaultPosition, \
size=wxDefaultSize, style=wxCLIP_CHILDREN, introText='', \ size=wxDefaultSize, style=wxCLIP_CHILDREN, introText='', \
locals=None, InterpClass=None, *args, **kwds): locals=None, InterpClass=None, *args, **kwds):
@@ -147,7 +147,7 @@ class Shell(wxStyledTextCtrl):
else: else:
Interpreter = InterpClass Interpreter = InterpClass
# Create default locals so we have something interesting. # Create default locals so we have something interesting.
shellLocals = {'__name__': 'PyCrust-Shell', shellLocals = {'__name__': 'PyCrust-Shell',
'__doc__': 'PyCrust-Shell, The PyCrust Python Shell.', '__doc__': 'PyCrust-Shell, The PyCrust Python Shell.',
'__version__': VERSION, '__version__': VERSION,
} }
@@ -194,12 +194,12 @@ class Shell(wxStyledTextCtrl):
def destroy(self): def destroy(self):
del self.interp del self.interp
def config(self): def config(self):
"""Configure shell based on user preferences.""" """Configure shell based on user preferences."""
self.SetMarginType(1, wxSTC_MARGIN_NUMBER) self.SetMarginType(1, wxSTC_MARGIN_NUMBER)
self.SetMarginWidth(1, 40) self.SetMarginWidth(1, 40)
self.SetLexer(wxSTC_LEX_PYTHON) self.SetLexer(wxSTC_LEX_PYTHON)
self.SetKeyWords(0, ' '.join(keyword.kwlist)) self.SetKeyWords(0, ' '.join(keyword.kwlist))
@@ -227,11 +227,11 @@ class Shell(wxStyledTextCtrl):
self.write(self.interp.introText) self.write(self.interp.introText)
except AttributeError: except AttributeError:
pass pass
def setBuiltinKeywords(self): def setBuiltinKeywords(self):
"""Create pseudo keywords as part of builtins. """Create pseudo keywords as part of builtins.
This is a rather clever hack that sets "close", "exit" and "quit" This is a rather clever hack that sets "close", "exit" and "quit"
to a PseudoKeyword object so that we can make them do what we want. to a PseudoKeyword object so that we can make them do what we want.
In this case what we want is to call our self.quit() method. In this case what we want is to call our self.quit() method.
The user can type "close", "exit" or "quit" without the final parens. The user can type "close", "exit" or "quit" without the final parens.
@@ -248,19 +248,19 @@ class Shell(wxStyledTextCtrl):
def quit(self): def quit(self):
"""Quit the application.""" """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. # In the close event handler we can make sure they want to quit.
# Other applications, like PythonCard, may choose to hide rather than # Other applications, like PythonCard, may choose to hide rather than
# quit so we should just post the event and let the surrounding app # quit so we should just post the event and let the surrounding app
# decide what it wants to do. # decide what it wants to do.
self.write('Click on the close button to leave the application.') self.write('Click on the close button to leave the application.')
def setLocalShell(self): def setLocalShell(self):
"""Add 'shell' to locals as reference to ShellFacade instance.""" """Add 'shell' to locals as reference to ShellFacade instance."""
self.interp.locals['shell'] = ShellFacade(other=self) self.interp.locals['shell'] = ShellFacade(other=self)
def execStartupScript(self, startupScript): def execStartupScript(self, startupScript):
"""Execute the user's PYTHONSTARTUP script if they have one.""" """Execute the user's PYTHONSTARTUP script if they have one."""
if startupScript and os.path.isfile(startupScript): if startupScript and os.path.isfile(startupScript):
@@ -269,10 +269,10 @@ class Shell(wxStyledTextCtrl):
(`startupText`, `startupScript`)) (`startupText`, `startupScript`))
else: else:
self.push('') self.push('')
def setStyles(self, faces): def setStyles(self, faces):
"""Configure font size, typeface and color for lexer.""" """Configure font size, typeface and color for lexer."""
# Default style # Default style
self.StyleSetSpec(wxSTC_STYLE_DEFAULT, "face:%(mono)s,size:%(size)d,back:%(backcol)s" % faces) self.StyleSetSpec(wxSTC_STYLE_DEFAULT, "face:%(mono)s,size:%(size)d,back:%(backcol)s" % faces)
@@ -508,7 +508,7 @@ class Shell(wxStyledTextCtrl):
def setStatusText(self, text): def setStatusText(self, text):
"""Display status information.""" """Display status information."""
# This method will most likely be replaced by the enclosing app # This method will most likely be replaced by the enclosing app
# to do something more interesting, like write to a status bar. # to do something more interesting, like write to a status bar.
print text print text
@@ -522,11 +522,11 @@ class Shell(wxStyledTextCtrl):
def processLine(self): def processLine(self):
"""Process the line of text at which the user hit Enter.""" """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 # The user hit ENTER and we need to decide what to do. They could be
# sitting on any line in the shell. # sitting on any line in the shell.
thepos = self.GetCurrentPos() thepos = self.GetCurrentPos()
startpos = self.promptPosEnd startpos = self.promptPosEnd
endpos = self.GetTextLength() endpos = self.GetTextLength()
# If they hit RETURN inside the current command, execute the command. # If they hit RETURN inside the current command, execute the command.
@@ -552,7 +552,7 @@ class Shell(wxStyledTextCtrl):
def getMultilineCommand(self, rstrip=1): def getMultilineCommand(self, rstrip=1):
"""Extract a multi-line command from the editor. """Extract a multi-line command from the editor.
The command may not necessarily be valid Python syntax.""" The command may not necessarily be valid Python syntax."""
# XXX Need to extract real prompts here. Need to keep track of the # XXX Need to extract real prompts here. Need to keep track of the
# prompt every time a command is issued. # prompt every time a command is issued.
@@ -586,10 +586,10 @@ class Shell(wxStyledTextCtrl):
if rstrip: if rstrip:
command = command.rstrip() command = command.rstrip()
return command return command
def getCommand(self, text=None, rstrip=1): def getCommand(self, text=None, rstrip=1):
"""Extract a command from text which may include a shell prompt. """Extract a command from text which may include a shell prompt.
The command may not necessarily be valid Python syntax.""" The command may not necessarily be valid Python syntax."""
if not text: if not text:
text = self.GetCurLine()[0] text = self.GetCurLine()[0]
@@ -613,7 +613,7 @@ class Shell(wxStyledTextCtrl):
elif text[:ps2size] == ps2: elif text[:ps2size] == ps2:
text = text[ps2size:] text = text[ps2size:]
return text return text
def push(self, command): def push(self, command):
"""Send command to the interpreter for execution.""" """Send command to the interpreter for execution."""
self.write(os.linesep) self.write(os.linesep)
@@ -653,7 +653,7 @@ class Shell(wxStyledTextCtrl):
def prompt(self): def prompt(self):
"""Display appropriate prompt for the context, either ps1 or ps2. """Display appropriate prompt for the context, either ps1 or ps2.
If this is a continuation line, autoindent as necessary.""" If this is a continuation line, autoindent as necessary."""
if self.more: if self.more:
prompt = str(sys.ps2) prompt = str(sys.ps2)
@@ -703,25 +703,25 @@ class Shell(wxStyledTextCtrl):
def ask(self, prompt='Please enter your response:'): def ask(self, prompt='Please enter your response:'):
"""Get response from the user.""" """Get response from the user."""
return raw_input(prompt=prompt) return raw_input(prompt=prompt)
def pause(self): def pause(self):
"""Halt execution pending a response from the user.""" """Halt execution pending a response from the user."""
self.ask('Press enter to continue:') self.ask('Press enter to continue:')
def clear(self): def clear(self):
"""Delete all text from the shell.""" """Delete all text from the shell."""
self.ClearAll() self.ClearAll()
def run(self, command, prompt=1, verbose=1): def run(self, command, prompt=1, verbose=1):
"""Execute command within the shell as if it was typed in directly. """Execute command within the shell as if it was typed in directly.
>>> shell.run('print "this"') >>> shell.run('print "this"')
>>> print "this" >>> print "this"
this this
>>> >>>
""" """
# Go to the very bottom of the text. # Go to the very bottom of the text.
endpos = self.GetTextLength() endpos = self.GetTextLength()
self.SetCurrentPos(endpos) self.SetCurrentPos(endpos)
command = command.rstrip() command = command.rstrip()
if prompt: self.prompt() if prompt: self.prompt()
if verbose: self.write(command) if verbose: self.write(command)
@@ -739,7 +739,7 @@ class Shell(wxStyledTextCtrl):
self.run(command, prompt=0, verbose=1) self.run(command, prompt=0, verbose=1)
finally: finally:
file.close() file.close()
def autoCompleteShow(self, command): def autoCompleteShow(self, command):
"""Display auto-completion popup list.""" """Display auto-completion popup list."""
list = self.interp.getAutoCompleteList(command, \ list = self.interp.getAutoCompleteList(command, \
@@ -771,11 +771,11 @@ class Shell(wxStyledTextCtrl):
def writeOut(self, text): def writeOut(self, text):
"""Replacement for stdout.""" """Replacement for stdout."""
self.write(text) self.write(text)
def writeErr(self, text): def writeErr(self, text):
"""Replacement for stderr.""" """Replacement for stderr."""
self.write(text) self.write(text)
def redirectStdin(self, redirect=1): def redirectStdin(self, redirect=1):
"""If redirect is true then sys.stdin will come from the shell.""" """If redirect is true then sys.stdin will come from the shell."""
if redirect: if redirect:
@@ -805,7 +805,7 @@ class Shell(wxStyledTextCtrl):
return 1 return 1
else: else:
return 0 return 0
def CanCopy(self): def CanCopy(self):
"""Return true if text is selected and can be copied.""" """Return true if text is selected and can be copied."""
return self.GetSelectionStart() != self.GetSelectionEnd() return self.GetSelectionStart() != self.GetSelectionEnd()
@@ -901,7 +901,7 @@ class Shell(wxStyledTextCtrl):
command += '\n' command += '\n'
command += line command += line
commands.append(command) commands.append(command)
for command in commands: for command in commands:
command = command.replace('\n', os.linesep + sys.ps2) command = command.replace('\n', os.linesep + sys.ps2)
self.write(command) self.write(command)
self.processLine() self.processLine()
@@ -920,7 +920,7 @@ ID_CALLTIPS_SHOW = NewId()
class ShellMenu: class ShellMenu:
"""Mixin class to add standard menu items.""" """Mixin class to add standard menu items."""
def createMenus(self): def createMenus(self):
m = self.fileMenu = wxMenu() m = self.fileMenu = wxMenu()
m.AppendSeparator() m.AppendSeparator()
@@ -940,20 +940,20 @@ class ShellMenu:
m = self.autocompMenu = wxMenu() m = self.autocompMenu = wxMenu()
m.Append(ID_AUTOCOMP_SHOW, 'Show Auto Completion', \ m.Append(ID_AUTOCOMP_SHOW, 'Show Auto Completion', \
'Show auto completion during dot syntax', \ 'Show auto completion during dot syntax', \
checkable=1) kind=wxITEM_CHECK)
m.Append(ID_AUTOCOMP_INCLUDE_MAGIC, 'Include Magic Attributes', \ m.Append(ID_AUTOCOMP_INCLUDE_MAGIC, 'Include Magic Attributes', \
'Include attributes visible to __getattr__ and __setattr__', \ 'Include attributes visible to __getattr__ and __setattr__', \
checkable=1) kind=wxITEM_CHECK)
m.Append(ID_AUTOCOMP_INCLUDE_SINGLE, 'Include Single Underscores', \ m.Append(ID_AUTOCOMP_INCLUDE_SINGLE, 'Include Single Underscores', \
'Include attibutes prefixed by a single underscore', \ 'Include attibutes prefixed by a single underscore', \
checkable=1) kind=wxITEM_CHECK)
m.Append(ID_AUTOCOMP_INCLUDE_DOUBLE, 'Include Double Underscores', \ m.Append(ID_AUTOCOMP_INCLUDE_DOUBLE, 'Include Double Underscores', \
'Include attibutes prefixed by a double underscore', \ 'Include attibutes prefixed by a double underscore', \
checkable=1) kind=wxITEM_CHECK)
m = self.calltipsMenu = wxMenu() m = self.calltipsMenu = wxMenu()
m.Append(ID_CALLTIPS_SHOW, 'Show Call Tips', \ m.Append(ID_CALLTIPS_SHOW, 'Show Call Tips', \
'Show call tips with argument specifications', checkable=1) 'Show call tips with argument specifications', kind=wxITEM_CHECK)
m = self.optionsMenu = wxMenu() m = self.optionsMenu = wxMenu()
m.AppendMenu(ID_AUTOCOMP, '&Auto Completion', self.autocompMenu, \ m.AppendMenu(ID_AUTOCOMP, '&Auto Completion', self.autocompMenu, \
@@ -1085,14 +1085,14 @@ class ShellMenu:
event.Check(self.shell.autoCompleteIncludeDouble) event.Check(self.shell.autoCompleteIncludeDouble)
elif id == ID_CALLTIPS_SHOW: elif id == ID_CALLTIPS_SHOW:
event.Check(self.shell.autoCallTip) event.Check(self.shell.autoCallTip)
class ShellFrame(wxFrame, ShellMenu): class ShellFrame(wxFrame, ShellMenu):
"""Frame containing the PyCrust shell component.""" """Frame containing the PyCrust shell component."""
name = 'PyCrust Shell Frame' name = 'PyCrust Shell Frame'
revision = __version__ revision = __version__
def __init__(self, parent=None, id=-1, title='PyShell', \ def __init__(self, parent=None, id=-1, title='PyShell', \
pos=wxDefaultPosition, size=wxDefaultSize, \ pos=wxDefaultPosition, size=wxDefaultSize, \
style=wxDEFAULT_FRAME_STYLE, locals=None, \ style=wxDEFAULT_FRAME_STYLE, locals=None, \
@@ -1116,5 +1116,5 @@ class ShellFrame(wxFrame, ShellMenu):
self.createMenus() self.createMenus()