From c5bcdfe8442d91802c616b26b8cb46e91b2b2ac4 Mon Sep 17 00:00:00 2001 From: Robin Dunn Date: Sat, 27 Oct 2012 03:16:59 +0000 Subject: [PATCH] Various changes for PyCrust and other py classes to get them working with Phoenix and also avoid deprecation warnings. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxPython/Phoenix/trunk@72797 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- wx/py/editor.py | 8 ++++---- wx/py/editwindow.py | 2 +- wx/py/filling.py | 18 ++++++++---------- wx/py/frame.py | 14 +++++++------- wx/py/images.py | 6 +++--- wx/py/interpreter.py | 2 +- wx/py/introspect.py | 2 +- wx/py/shell.py | 5 ++--- wx/py/sliceshell.py | 8 +++----- 9 files changed, 30 insertions(+), 35 deletions(-) diff --git a/wx/py/editor.py b/wx/py/editor.py index 8c66de80..0ded203d 100644 --- a/wx/py/editor.py +++ b/wx/py/editor.py @@ -766,7 +766,7 @@ class DialogResults: def fileDialog(parent=None, title='Open', directory='', filename='', wildcard='All Files (*.*)|*.*', - style=wx.OPEN | wx.MULTIPLE): + style=wx.FD_OPEN | wx.FD_MULTIPLE): """File dialog wrapper function.""" dialog = wx.FileDialog(parent, title, directory, filename, wildcard, style) @@ -780,7 +780,7 @@ def fileDialog(parent=None, title='Open', directory='', filename='', def openSingle(parent=None, title='Open', directory='', filename='', - wildcard='All Files (*.*)|*.*', style=wx.OPEN): + wildcard='All Files (*.*)|*.*', style=wx.FD_OPEN): """File dialog wrapper function.""" dialog = wx.FileDialog(parent, title, directory, filename, wildcard, style) @@ -795,14 +795,14 @@ def openSingle(parent=None, title='Open', directory='', filename='', def openMultiple(parent=None, title='Open', directory='', filename='', wildcard='All Files (*.*)|*.*', - style=wx.OPEN | wx.MULTIPLE): + style=wx.FD_OPEN | wx.FD_MULTIPLE): """File dialog wrapper function.""" return fileDialog(parent, title, directory, filename, wildcard, style) def saveSingle(parent=None, title='Save', directory='', filename='', wildcard='All Files (*.*)|*.*', - style=wx.SAVE | wx.OVERWRITE_PROMPT): + style=wx.FD_SAVE | wx.FD_OVERWRITE_PROMPT): """File dialog wrapper function.""" dialog = wx.FileDialog(parent, title, directory, filename, wildcard, style) diff --git a/wx/py/editwindow.py b/wx/py/editwindow.py index 2a9bdc47..b258e6fb 100644 --- a/wx/py/editwindow.py +++ b/wx/py/editwindow.py @@ -76,7 +76,7 @@ class EditWindow(stc.StyledTextCtrl): """Create EditWindow instance.""" stc.StyledTextCtrl.__init__(self, parent, id, pos, size, style) self.__config() - stc.EVT_STC_UPDATEUI(self, id, self.OnUpdateUI) + self.Bind(stc.EVT_STC_UPDATEUI, self.OnUpdateUI) dispatcher.connect(receiver=self._fontsizer, signal='FontIncrease') dispatcher.connect(receiver=self._fontsizer, signal='FontDecrease') dispatcher.connect(receiver=self._fontsizer, signal='FontDefault') diff --git a/wx/py/filling.py b/wx/py/filling.py index 4ffe662d..8bff886d 100644 --- a/wx/py/filling.py +++ b/wx/py/filling.py @@ -58,8 +58,7 @@ class FillingTree(wx.TreeCtrl): rootLabel = 'locals()' if not rootLabel: rootLabel = 'Ingredients' - rootData = wx.TreeItemData(rootObject) - self.item = self.root = self.AddRoot(rootLabel, -1, -1, rootData) + self.item = self.root = self.AddRoot(rootLabel, -1, -1, rootObject) self.SetItemHasChildren(self.root, self.objHasChildren(rootObject)) self.Bind(wx.EVT_TREE_ITEM_EXPANDING, self.OnItemExpanding, id=self.GetId()) self.Bind(wx.EVT_TREE_ITEM_COLLAPSED, self.OnItemCollapsed, id=self.GetId()) @@ -99,7 +98,7 @@ class FillingTree(wx.TreeCtrl): """Launch a DirFrame.""" item = event.GetItem() text = self.getFullName(item) - obj = self.GetPyData(item) + obj = self.GetItemData(item) frame = FillingFrame(parent=self, size=(600, 100), rootObject=obj, rootLabel=text, rootIsNamespace=False) frame.Show() @@ -136,7 +135,7 @@ class FillingTree(wx.TreeCtrl): def addChildren(self, item): self.DeleteChildren(item) - obj = self.GetPyData(item) + obj = self.GetItemData(item) children = self.objGetChildren(obj) if not children: return @@ -153,8 +152,7 @@ class FillingTree(wx.TreeCtrl): or (item == self.root and not self.rootIsNamespace)): itemtext = repr(key) child = children[key] - data = wx.TreeItemData(child) - branch = self.AppendItem(parent=item, text=itemtext, data=data) + branch = self.AppendItem(parent=item, text=itemtext, data=child) self.SetItemHasChildren(branch, self.objHasChildren(child)) def display(self): @@ -164,7 +162,7 @@ class FillingTree(wx.TreeCtrl): if self.IsExpanded(item): self.addChildren(item) self.setText('') - obj = self.GetPyData(item) + obj = self.GetItemData(item) if wx.Platform == '__WXMSW__': if obj is None: # Windows bug fix. return @@ -207,7 +205,7 @@ class FillingTree(wx.TreeCtrl): obj = None if item != self.root: parent = self.GetItemParent(item) - obj = self.GetPyData(parent) + obj = self.GetItemData(parent) # Apply dictionary syntax to dictionary items, except the root # and first level children of a namepace. if (type(obj) is types.DictType \ @@ -291,7 +289,7 @@ class Filling(wx.SplitterWindow): static=static) self.text = FillingText(parent=self, static=static) - wx.FutureCall(1, self.SplitVertically, self.tree, self.text, 200) + wx.CallLater(1, self.SplitVertically, self.tree, self.text, 200) self.SetMinimumPaneSize(1) @@ -313,7 +311,7 @@ class Filling(wx.SplitterWindow): def LoadSettings(self, config): pos = config.ReadInt('Sash/FillingPos', 200) - wx.FutureCall(250, self.SetSashPosition, pos) + wx.CallLater(250, self.SetSashPosition, pos) zoom = config.ReadInt('View/Zoom/Filling', -99) if zoom != -99: self.text.SetZoom(zoom) diff --git a/wx/py/frame.py b/wx/py/frame.py index 2bece97b..7ca3e389 100644 --- a/wx/py/frame.py +++ b/wx/py/frame.py @@ -195,9 +195,9 @@ class Frame(wx.Frame): '&Insert Call Tips', wx.ITEM_CHECK) m = self.optionsMenu = wx.Menu() - m.AppendMenu(ID_AUTOCOMP, '&Auto Completion', self.autocompMenu, + m.Append(ID_AUTOCOMP, '&Auto Completion', self.autocompMenu, 'Auto Completion Options') - m.AppendMenu(ID_CALLTIPS, '&Call Tips', self.calltipsMenu, + m.Append(ID_CALLTIPS, '&Call Tips', self.calltipsMenu, 'Call Tip Options') m.AppendSeparator() @@ -209,7 +209,7 @@ class Frame(wx.Frame): 'Save history') self.historyMenu.Append(ID_CLEARHISTORY, '&Clear History ', 'Clear history') - m.AppendMenu(-1, "&History", self.historyMenu, "History Options") + m.Append(-1, "&History", self.historyMenu, "History Options") self.startupMenu = wx.Menu() self.startupMenu.Append(ID_EXECSTARTUPSCRIPT, @@ -222,7 +222,7 @@ class Frame(wx.Frame): self.startupMenu.Append(ID_SHOWPYSLICESTUTORIAL, '&Show PySlices Tutorial', 'Show PySlices Tutorial', wx.ITEM_CHECK) - m.AppendMenu(ID_STARTUP, '&Startup', self.startupMenu, 'Startup Options') + m.Append(ID_STARTUP, '&Startup', self.startupMenu, 'Startup Options') self.settingsMenu = wx.Menu() if self.shellName in ['PySlices','SymPySlices']: @@ -242,7 +242,7 @@ class Frame(wx.Frame): self.settingsMenu.Append(ID_DELSETTINGSFILE, '&Revert to default', 'Revert to the default settings') - m.AppendMenu(ID_SETTINGS, '&Settings', self.settingsMenu, 'Settings Options') + m.Append(ID_SETTINGS, '&Settings', self.settingsMenu, 'Settings Options') m = self.helpMenu = wx.Menu() m.Append(ID_HELP, '&Help\tF1', 'Help!') @@ -488,7 +488,7 @@ class Frame(wx.Frame): def OnWrap(self, event): win = wx.Window.FindFocus() win.SetWrapMode(event.IsChecked()) - wx.FutureCall(1, self.shell.EnsureCaretVisible) + wx.CallLater(1, self.shell.EnsureCaretVisible) def OnSaveHistory(self, event): self.autoSaveHistory = event.IsChecked() @@ -850,7 +850,7 @@ class ShellFrameMixin: name = os.path.join(self.dataDir, 'history') f = file(name, 'w') hist = [] - enc = wx.GetDefaultPyEncoding() + enc = 'utf-8' for h in self.shell.history: if isinstance(h, unicode): h = h.encode(enc) diff --git a/wx/py/images.py b/wx/py/images.py index f3cb5a16..e3a75f6d 100644 --- a/wx/py/images.py +++ b/wx/py/images.py @@ -9,16 +9,16 @@ import cStringIO def getPyIcon(shellName='PyCrust'): - icon = wx.EmptyIcon() + icon = wx.Icon() icon.CopyFromBitmap(getPyBitmap(shellName)) return icon def getPyBitmap(shellName='PyCrust'): - return wx.BitmapFromImage(getPyImage(shellName)) + return wx.Bitmap(getPyImage(shellName)) def getPyImage(shellName='PyCrust'): stream = cStringIO.StringIO(getPyData(shellName)) - return wx.ImageFromStream(stream) + return wx.Image(stream) def getPyData(shellName='PyCrust'): if shellName=='PyCrust': diff --git a/wx/py/interpreter.py b/wx/py/interpreter.py index 35468a10..632d0250 100644 --- a/wx/py/interpreter.py +++ b/wx/py/interpreter.py @@ -60,7 +60,7 @@ class Interpreter(InteractiveInterpreter): # In case the command is unicode try encoding it if type(command) == unicode: try: - command = command.encode(wx.GetDefaultPyEncoding()) + command = command.encode('utf-8') except UnicodeEncodeError: pass # otherwise leave it alone diff --git a/wx/py/introspect.py b/wx/py/introspect.py index 0a14f89d..f450700e 100644 --- a/wx/py/introspect.py +++ b/wx/py/introspect.py @@ -303,7 +303,7 @@ def getTokens(command): # In case the command is unicode try encoding it if type(command) == unicode: try: - command = command.encode(wx.GetDefaultPyEncoding()) + command = command.encode('utf-8') except UnicodeEncodeError: pass # otherwise leave it alone diff --git a/wx/py/shell.py b/wx/py/shell.py index 1009f6ad..c8b08a9a 100644 --- a/wx/py/shell.py +++ b/wx/py/shell.py @@ -33,7 +33,7 @@ USE_MAGIC=True PRINT_UPDATE_MAX_TIME=2 NAVKEYS = (wx.WXK_END, wx.WXK_LEFT, wx.WXK_RIGHT, - wx.WXK_UP, wx.WXK_DOWN, wx.WXK_PRIOR, wx.WXK_NEXT) + wx.WXK_UP, wx.WXK_DOWN, wx.WXK_PAGEUP, wx.WXK_PAGEDOWN) class ShellFrame(frame.Frame, frame.ShellFrameMixin): @@ -173,7 +173,6 @@ class ShellFacade: d = self.__dict__ d['other'] = other d['helpText'] = HELP_TEXT - d['this'] = other.this def help(self): """Display some useful information about how to use the shell.""" @@ -884,7 +883,7 @@ class Shell(editwindow.EditWindow): self.write(os.linesep) else: self.push(command) - wx.FutureCall(1, self.EnsureCaretVisible) + wx.CallLater(1, self.EnsureCaretVisible) # Or replace the current command with the other command. else: # If the line contains a command (even an invalid one). diff --git a/wx/py/sliceshell.py b/wx/py/sliceshell.py index ef30a1f7..041ca44f 100644 --- a/wx/py/sliceshell.py +++ b/wx/py/sliceshell.py @@ -39,7 +39,7 @@ USE_MAGIC=True PRINT_UPDATE_MAX_TIME=2 NAVKEYS = (wx.WXK_HOME, wx.WXK_END, wx.WXK_LEFT, wx.WXK_RIGHT, - wx.WXK_UP, wx.WXK_DOWN, wx.WXK_PRIOR, wx.WXK_NEXT) + wx.WXK_UP, wx.WXK_DOWN, wx.WXK_PAGEUP, wx.WXK_PAGEDOWN) GROUPING_SELECTING=0 IO_SELECTING = 1 @@ -543,7 +543,6 @@ class SlicesShellFacade: d = self.__dict__ d['other'] = other d['helpText'] = HELP_TEXT - d['this'] = other.this def help(self): """Display some useful information about how to use the slices shell.""" @@ -2332,7 +2331,7 @@ class SlicesShell(editwindow.EditWindow): self.runningSlice = (startline,endline) self.push(command,useMultiCommand=True) #print 'command: ',command - wx.FutureCall(1, self.EnsureCaretVisible) + wx.CallLater(1, self.EnsureCaretVisible) self.runningSlice=None skip=self.BackspaceWMarkers(force=True) @@ -3356,8 +3355,7 @@ class SlicesShell(editwindow.EditWindow): and self.GetSelectionStart() <= sliceEndPos \ and self.GetSelectionEnd() <= sliceEndPos: return True - else: - return False + return False def Cut(self): """Remove selection and place it on the clipboard."""