From b7dbf2d86732d25a4e5e90f15d9d0c876682b2df Mon Sep 17 00:00:00 2001 From: Robin Dunn Date: Tue, 14 Jan 2003 06:43:27 +0000 Subject: [PATCH] Migrated demo code to not import string module. (Patch from Kevin Altis) git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_4_BRANCH@18718 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- wxPython/demo/About.py | 4 ++-- wxPython/demo/GridCustEditor.py | 3 ++- wxPython/demo/GridHugeTable.py | 8 ++++++++ wxPython/demo/GridStdEdRend.py | 2 +- wxPython/demo/Main.py | 6 +++--- wxPython/demo/TablePrint.py | 4 ++-- wxPython/demo/XMLtreeview.py | 4 ++-- wxPython/demo/encode_bitmaps.py | 4 ++-- wxPython/demo/hangman.py | 4 ++-- wxPython/demo/widgetTest.py | 4 ++-- wxPython/demo/wxComboBox.py | 3 +-- wxPython/demo/wxFileDialog.py | 1 - wxPython/demo/wxListBox.py | 6 ++---- wxPython/demo/wxSlider.py | 2 -- wxPython/demo/wxSpinButton.py | 2 -- wxPython/demo/wxSpinCtrl.py | 2 -- wxPython/demo/wxStaticBitmap.py | 2 -- wxPython/demo/wxStyledTextCtrl_2.py | 6 +++--- wxPython/demo/wxTextCtrl.py | 2 +- wxPython/demo/wxToggleButton.py | 2 +- 20 files changed, 34 insertions(+), 37 deletions(-) diff --git a/wxPython/demo/About.py b/wxPython/demo/About.py index 0605fa36fa..c76e8639fb 100644 --- a/wxPython/demo/About.py +++ b/wxPython/demo/About.py @@ -1,4 +1,4 @@ -import sys, string +import sys from wxPython.wx import * from wxPython.html import * @@ -46,7 +46,7 @@ demo item so you can learn how to use the classes yourself.

def __init__(self, parent): wxDialog.__init__(self, parent, -1, 'About the wxPython demo',) html = wxHtmlWindow(self, -1, size=(420, -1)) - py_version = string.split(sys.version)[0] + py_version = sys.version.split()[0] html.SetPage(self.text % (wx.__version__, py_version)) btn = html.FindWindowById(wxID_OK) btn.SetDefault() diff --git a/wxPython/demo/GridCustEditor.py b/wxPython/demo/GridCustEditor.py index 39050510f9..a6a6186cca 100644 --- a/wxPython/demo/GridCustEditor.py +++ b/wxPython/demo/GridCustEditor.py @@ -2,6 +2,7 @@ from wxPython.wx import * from wxPython.grid import * +import string #--------------------------------------------------------------------------- class MyCellEditor(wxPyGridCellEditor): """ @@ -143,7 +144,7 @@ class MyCellEditor(wxPyGridCellEditor): elif key < 256 and key >= 0 and chr(key) in string.printable: ch = chr(key) if not evt.ShiftDown(): - ch = string.lower(ch) + ch = ch.lower() if ch is not None: # For this example, replace the text. Normally we would append it. diff --git a/wxPython/demo/GridHugeTable.py b/wxPython/demo/GridHugeTable.py index 6c450ec5d7..3ddc4e8726 100644 --- a/wxPython/demo/GridHugeTable.py +++ b/wxPython/demo/GridHugeTable.py @@ -47,6 +47,14 @@ class HugeTableGrid(wxGrid): # a reference to it and call it's Destroy method later. self.SetTable(table, true) + EVT_GRID_CELL_RIGHT_CLICK(self, self.OnRightDown) #added + + def OnRightDown(self, event): #added + print "hello" + print self.GetSelectedRows() #added + + + #--------------------------------------------------------------------------- diff --git a/wxPython/demo/GridStdEdRend.py b/wxPython/demo/GridStdEdRend.py index b4a3db3c36..69892a9bde 100644 --- a/wxPython/demo/GridStdEdRend.py +++ b/wxPython/demo/GridStdEdRend.py @@ -1,7 +1,7 @@ from wxPython.wx import * from wxPython.grid import * -import string, random +import random #--------------------------------------------------------------------------- diff --git a/wxPython/demo/Main.py b/wxPython/demo/Main.py index 6772638feb..970fcea689 100644 --- a/wxPython/demo/Main.py +++ b/wxPython/demo/Main.py @@ -11,7 +11,7 @@ # Licence: wxWindows license #---------------------------------------------------------------------------- -import sys, os, time, string +import sys, os, time from wxPython.wx import * from wxPython.html import wxHtmlWindow @@ -225,7 +225,7 @@ class MyTP(wxPyTipProvider): def opj(path): """Convert paths to the platform-specific separator""" - return apply(os.path.join, tuple(string.split(path, '/'))) + return apply(os.path.join, tuple(path.split('/'))) #--------------------------------------------------------------------------- @@ -513,7 +513,7 @@ class wxPythonDemo(wxFrame): self.curOverview = text lead = text[:6] if lead != '' and lead != '': - text = string.join(string.split(text, '\n'), '
') + text = '
'.join(text.split('\n')) self.ovr.SetPage(text) self.nb.SetPageText(0, name) diff --git a/wxPython/demo/TablePrint.py b/wxPython/demo/TablePrint.py index 615222c812..682b740dd4 100644 --- a/wxPython/demo/TablePrint.py +++ b/wxPython/demo/TablePrint.py @@ -47,11 +47,11 @@ class TablePanel(wxPanel): data = [] while 1: text = file.readline() - text = string.strip(text) + text = text.strip() if not text: break - list_val = string.splitfields(text,'\t') + list_val = text.split('\t') data.append(list_val) file.close() diff --git a/wxPython/demo/XMLtreeview.py b/wxPython/demo/XMLtreeview.py index ce14928ce8..fccf4a3758 100644 --- a/wxPython/demo/XMLtreeview.py +++ b/wxPython/demo/XMLtreeview.py @@ -1,5 +1,5 @@ -import string, sys +import sys py2 = sys.version[0] == '2' @@ -76,7 +76,7 @@ else: self.nodeStack = self.nodeStack[:-1] def CharacterData(self, data ): - if string.strip(data): + if data.strip(): if py2: data = data.encode() self.AppendItem(self.nodeStack[-1], data) diff --git a/wxPython/demo/encode_bitmaps.py b/wxPython/demo/encode_bitmaps.py index f44c3cf183..b3d027eb11 100644 --- a/wxPython/demo/encode_bitmaps.py +++ b/wxPython/demo/encode_bitmaps.py @@ -6,7 +6,7 @@ This is a way to save the startup time when running img2py on lots of files... """ -import sys, string +import sys from wxPython.tools import img2py @@ -100,6 +100,6 @@ command_lines = [ for line in command_lines: - args = string.split(line) + args = line.split() img2py.main(args) diff --git a/wxPython/demo/hangman.py b/wxPython/demo/hangman.py index eb591471a8..73978372ce 100644 --- a/wxPython/demo/hangman.py +++ b/wxPython/demo/hangman.py @@ -14,7 +14,7 @@ Have fun with it, Harm van der Heijden (H.v.d.Heijden@phys.tue.nl)""" -import random,re,string +import random,re from wxPython.wx import * @@ -47,7 +47,7 @@ class WordFetcher: m = reg.search(self.words[index:]) if m and len(m.groups()[0]) >= self.min_length: break n = n - 1 - if n: return string.lower(m.groups()[0]) + if n: return m.groups()[0].lower() return "error" diff --git a/wxPython/demo/widgetTest.py b/wxPython/demo/widgetTest.py index ee940e89f4..3ca627c6ab 100644 --- a/wxPython/demo/widgetTest.py +++ b/wxPython/demo/widgetTest.py @@ -1,6 +1,6 @@ -import sys, string +import sys from wxPython.wx import * from wxPython.html import * @@ -43,7 +43,7 @@ class TestHtmlPanel(wxPanel): import About wxPanel.__init__(self, parent, id, size=size) self.html = wxHtmlWindow(self, -1, wxPoint(5,5), wxSize(400, 350)) - py_version = string.split(sys.version)[0] + py_version = sys.version.split()[0] self.html.SetPage(About.MyAboutBox.text % (wx.__version__, py_version)) ir = self.html.GetInternalRepresentation() self.html.SetSize( (ir.GetWidth()+5, ir.GetHeight()+5) ) diff --git a/wxPython/demo/wxComboBox.py b/wxPython/demo/wxComboBox.py index b3dfc92739..37e52cbb37 100644 --- a/wxPython/demo/wxComboBox.py +++ b/wxPython/demo/wxComboBox.py @@ -1,4 +1,3 @@ -import string from wxPython.wx import * #--------------------------------------------------------------------------- @@ -35,7 +34,7 @@ class TestComboBox(wxPanel): cb = wxComboBox(self, 501, "default value", wxPoint(90, 80), wxSize(95, -1), [], wxCB_SIMPLE) for item in sampleList: - cb.Append(item, string.upper(item)) + cb.Append(item, item.upper()) EVT_COMBOBOX(self, 501, self.EvtComboBox) EVT_TEXT(self, 501, self.EvtText) diff --git a/wxPython/demo/wxFileDialog.py b/wxPython/demo/wxFileDialog.py index a3c753e45b..559f7e3d0d 100644 --- a/wxPython/demo/wxFileDialog.py +++ b/wxPython/demo/wxFileDialog.py @@ -1,6 +1,5 @@ from wxPython.wx import * -import string #--------------------------------------------------------------------------- diff --git a/wxPython/demo/wxListBox.py b/wxPython/demo/wxListBox.py index d7a67b00c2..074f2de5ae 100644 --- a/wxPython/demo/wxListBox.py +++ b/wxPython/demo/wxListBox.py @@ -1,8 +1,6 @@ from wxPython.wx import * -import string - #--------------------------------------------------------------------------- class wxFindPrefixListBox(wxListBox): @@ -17,11 +15,11 @@ class wxFindPrefixListBox(wxListBox): def FindPrefix(self, prefix): self.log.WriteText('Looking for prefix: %s\n' % prefix) if prefix: - prefix = string.lower(prefix) + prefix = prefix.lower() length = len(prefix) for x in range(self.Number()): text = self.GetString(x) - text = string.lower(text) + text = text.lower() if text[:length] == prefix: self.log.WriteText('Prefix %s is found.\n' % prefix) return x diff --git a/wxPython/demo/wxSlider.py b/wxPython/demo/wxSlider.py index 731486ee2b..c8da0bb546 100644 --- a/wxPython/demo/wxSlider.py +++ b/wxPython/demo/wxSlider.py @@ -1,8 +1,6 @@ from wxPython.wx import * -import string - #---------------------------------------------------------------------- class TestPanel(wxPanel): diff --git a/wxPython/demo/wxSpinButton.py b/wxPython/demo/wxSpinButton.py index 67308b41d0..0095fbad77 100644 --- a/wxPython/demo/wxSpinButton.py +++ b/wxPython/demo/wxSpinButton.py @@ -1,8 +1,6 @@ from wxPython.wx import * -import string - #---------------------------------------------------------------------- class TestPanel(wxPanel): diff --git a/wxPython/demo/wxSpinCtrl.py b/wxPython/demo/wxSpinCtrl.py index f373c82aa0..65683bd9e6 100644 --- a/wxPython/demo/wxSpinCtrl.py +++ b/wxPython/demo/wxSpinCtrl.py @@ -1,8 +1,6 @@ from wxPython.wx import * -import string - #---------------------------------------------------------------------- class TestPanel(wxPanel): diff --git a/wxPython/demo/wxStaticBitmap.py b/wxPython/demo/wxStaticBitmap.py index 1b057913ef..d281d60237 100644 --- a/wxPython/demo/wxStaticBitmap.py +++ b/wxPython/demo/wxStaticBitmap.py @@ -1,8 +1,6 @@ from wxPython.wx import * -from Main import opj -import string import images #---------------------------------------------------------------------- diff --git a/wxPython/demo/wxStyledTextCtrl_2.py b/wxPython/demo/wxStyledTextCtrl_2.py index 325c4ea6ae..70b9d48b2f 100644 --- a/wxPython/demo/wxStyledTextCtrl_2.py +++ b/wxPython/demo/wxStyledTextCtrl_2.py @@ -45,7 +45,7 @@ class PythonSTC(wxStyledTextCtrl): self.CmdKeyAssign(ord('N'), wxSTC_SCMOD_CTRL, wxSTC_CMD_ZOOMOUT) self.SetLexer(wxSTC_LEX_PYTHON) - self.SetKeyWords(0, string.join(keyword.kwlist)) + self.SetKeyWords(0, " ".join(keyword.kwlist)) self.SetProperty("fold", "1") self.SetProperty("tab.timmy.whinge.level", "1") @@ -151,7 +151,7 @@ class PythonSTC(wxStyledTextCtrl): #lst = [] #for x in range(50000): # lst.append('%05d' % x) - #st = string.join(lst) + #st = " ".join(lst) #print len(st) #self.AutoCompShow(0, st) @@ -167,7 +167,7 @@ class PythonSTC(wxStyledTextCtrl): kw.sort() # Python sorts are case sensitive self.AutoCompSetIgnoreCase(false) # so this needs to match - self.AutoCompShow(0, string.join(kw)) + self.AutoCompShow(0, " ".join(kw)) else: event.Skip() diff --git a/wxPython/demo/wxTextCtrl.py b/wxPython/demo/wxTextCtrl.py index ccc5a65880..369498b8dd 100644 --- a/wxPython/demo/wxTextCtrl.py +++ b/wxPython/demo/wxTextCtrl.py @@ -105,7 +105,7 @@ class TestPanel(wxPanel): start, end = self.tc.GetSelection() text = self.tc.GetValue() if wxPlatform == "__WXMSW__": # This is why GetStringSelection was added - text = string.replace(text, '\n', '\r\n') + text = text.replace('\n', '\r\n') self.log.write("GetSelection(): (%d, %d)\n" "\tGetStringSelection(): %s\n" "\tSelectedText: %s\n" % diff --git a/wxPython/demo/wxToggleButton.py b/wxPython/demo/wxToggleButton.py index b184437ab7..582bb32887 100644 --- a/wxPython/demo/wxToggleButton.py +++ b/wxPython/demo/wxToggleButton.py @@ -15,7 +15,7 @@ class TestPanel(wxPanel): self.log = log panel = wxPanel(self, -1) buttons = wxBoxSizer(wxHORIZONTAL) - for word in string.split("These are toggle buttons"): + for word in "These are toggle buttons".split(): b = wxToggleButton(panel, -1, word) EVT_TOGGLEBUTTON(self, b.GetId(), self.OnToggle) buttons.Add(b, flag=wxALL, border=5)