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
This commit is contained in:
Robin Dunn
2003-01-14 06:43:27 +00:00
parent d4118cc7b1
commit b7dbf2d867
20 changed files with 34 additions and 37 deletions

View File

@@ -1,4 +1,4 @@
import sys, string import sys
from wxPython.wx import * from wxPython.wx import *
from wxPython.html import * from wxPython.html import *
@@ -46,7 +46,7 @@ demo item so you can learn how to use the classes yourself.</p>
def __init__(self, parent): def __init__(self, parent):
wxDialog.__init__(self, parent, -1, 'About the wxPython demo',) wxDialog.__init__(self, parent, -1, 'About the wxPython demo',)
html = wxHtmlWindow(self, -1, size=(420, -1)) 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)) html.SetPage(self.text % (wx.__version__, py_version))
btn = html.FindWindowById(wxID_OK) btn = html.FindWindowById(wxID_OK)
btn.SetDefault() btn.SetDefault()

View File

@@ -2,6 +2,7 @@
from wxPython.wx import * from wxPython.wx import *
from wxPython.grid import * from wxPython.grid import *
import string
#--------------------------------------------------------------------------- #---------------------------------------------------------------------------
class MyCellEditor(wxPyGridCellEditor): class MyCellEditor(wxPyGridCellEditor):
""" """
@@ -143,7 +144,7 @@ class MyCellEditor(wxPyGridCellEditor):
elif key < 256 and key >= 0 and chr(key) in string.printable: elif key < 256 and key >= 0 and chr(key) in string.printable:
ch = chr(key) ch = chr(key)
if not evt.ShiftDown(): if not evt.ShiftDown():
ch = string.lower(ch) ch = ch.lower()
if ch is not None: if ch is not None:
# For this example, replace the text. Normally we would append it. # For this example, replace the text. Normally we would append it.

View File

@@ -47,6 +47,14 @@ class HugeTableGrid(wxGrid):
# a reference to it and call it's Destroy method later. # a reference to it and call it's Destroy method later.
self.SetTable(table, true) self.SetTable(table, true)
EVT_GRID_CELL_RIGHT_CLICK(self, self.OnRightDown) #added
def OnRightDown(self, event): #added
print "hello"
print self.GetSelectedRows() #added
#--------------------------------------------------------------------------- #---------------------------------------------------------------------------

View File

@@ -1,7 +1,7 @@
from wxPython.wx import * from wxPython.wx import *
from wxPython.grid import * from wxPython.grid import *
import string, random import random
#--------------------------------------------------------------------------- #---------------------------------------------------------------------------

View File

@@ -11,7 +11,7 @@
# Licence: wxWindows license # Licence: wxWindows license
#---------------------------------------------------------------------------- #----------------------------------------------------------------------------
import sys, os, time, string import sys, os, time
from wxPython.wx import * from wxPython.wx import *
from wxPython.html import wxHtmlWindow from wxPython.html import wxHtmlWindow
@@ -225,7 +225,7 @@ class MyTP(wxPyTipProvider):
def opj(path): def opj(path):
"""Convert paths to the platform-specific separator""" """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 self.curOverview = text
lead = text[:6] lead = text[:6]
if lead != '<html>' and lead != '<HTML>': if lead != '<html>' and lead != '<HTML>':
text = string.join(string.split(text, '\n'), '<br>') text = '<br>'.join(text.split('\n'))
self.ovr.SetPage(text) self.ovr.SetPage(text)
self.nb.SetPageText(0, name) self.nb.SetPageText(0, name)

View File

@@ -47,11 +47,11 @@ class TablePanel(wxPanel):
data = [] data = []
while 1: while 1:
text = file.readline() text = file.readline()
text = string.strip(text) text = text.strip()
if not text: if not text:
break break
list_val = string.splitfields(text,'\t') list_val = text.split('\t')
data.append(list_val) data.append(list_val)
file.close() file.close()

View File

@@ -1,5 +1,5 @@
import string, sys import sys
py2 = sys.version[0] == '2' py2 = sys.version[0] == '2'
@@ -76,7 +76,7 @@ else:
self.nodeStack = self.nodeStack[:-1] self.nodeStack = self.nodeStack[:-1]
def CharacterData(self, data ): def CharacterData(self, data ):
if string.strip(data): if data.strip():
if py2: if py2:
data = data.encode() data = data.encode()
self.AppendItem(self.nodeStack[-1], data) self.AppendItem(self.nodeStack[-1], data)

View File

@@ -6,7 +6,7 @@ This is a way to save the startup time when running img2py on lots of
files... files...
""" """
import sys, string import sys
from wxPython.tools import img2py from wxPython.tools import img2py
@@ -100,6 +100,6 @@ command_lines = [
for line in command_lines: for line in command_lines:
args = string.split(line) args = line.split()
img2py.main(args) img2py.main(args)

View File

@@ -14,7 +14,7 @@ Have fun with it,
Harm van der Heijden (H.v.d.Heijden@phys.tue.nl)""" Harm van der Heijden (H.v.d.Heijden@phys.tue.nl)"""
import random,re,string import random,re
from wxPython.wx import * from wxPython.wx import *
@@ -47,7 +47,7 @@ class WordFetcher:
m = reg.search(self.words[index:]) m = reg.search(self.words[index:])
if m and len(m.groups()[0]) >= self.min_length: break if m and len(m.groups()[0]) >= self.min_length: break
n = n - 1 n = n - 1
if n: return string.lower(m.groups()[0]) if n: return m.groups()[0].lower()
return "error" return "error"

View File

@@ -1,6 +1,6 @@
import sys, string import sys
from wxPython.wx import * from wxPython.wx import *
from wxPython.html import * from wxPython.html import *
@@ -43,7 +43,7 @@ class TestHtmlPanel(wxPanel):
import About import About
wxPanel.__init__(self, parent, id, size=size) wxPanel.__init__(self, parent, id, size=size)
self.html = wxHtmlWindow(self, -1, wxPoint(5,5), wxSize(400, 350)) 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)) self.html.SetPage(About.MyAboutBox.text % (wx.__version__, py_version))
ir = self.html.GetInternalRepresentation() ir = self.html.GetInternalRepresentation()
self.html.SetSize( (ir.GetWidth()+5, ir.GetHeight()+5) ) self.html.SetSize( (ir.GetWidth()+5, ir.GetHeight()+5) )

View File

@@ -1,4 +1,3 @@
import string
from wxPython.wx import * from wxPython.wx import *
#--------------------------------------------------------------------------- #---------------------------------------------------------------------------
@@ -35,7 +34,7 @@ class TestComboBox(wxPanel):
cb = wxComboBox(self, 501, "default value", wxPoint(90, 80), wxSize(95, -1), cb = wxComboBox(self, 501, "default value", wxPoint(90, 80), wxSize(95, -1),
[], wxCB_SIMPLE) [], wxCB_SIMPLE)
for item in sampleList: for item in sampleList:
cb.Append(item, string.upper(item)) cb.Append(item, item.upper())
EVT_COMBOBOX(self, 501, self.EvtComboBox) EVT_COMBOBOX(self, 501, self.EvtComboBox)
EVT_TEXT(self, 501, self.EvtText) EVT_TEXT(self, 501, self.EvtText)

View File

@@ -1,6 +1,5 @@
from wxPython.wx import * from wxPython.wx import *
import string
#--------------------------------------------------------------------------- #---------------------------------------------------------------------------

View File

@@ -1,8 +1,6 @@
from wxPython.wx import * from wxPython.wx import *
import string
#--------------------------------------------------------------------------- #---------------------------------------------------------------------------
class wxFindPrefixListBox(wxListBox): class wxFindPrefixListBox(wxListBox):
@@ -17,11 +15,11 @@ class wxFindPrefixListBox(wxListBox):
def FindPrefix(self, prefix): def FindPrefix(self, prefix):
self.log.WriteText('Looking for prefix: %s\n' % prefix) self.log.WriteText('Looking for prefix: %s\n' % prefix)
if prefix: if prefix:
prefix = string.lower(prefix) prefix = prefix.lower()
length = len(prefix) length = len(prefix)
for x in range(self.Number()): for x in range(self.Number()):
text = self.GetString(x) text = self.GetString(x)
text = string.lower(text) text = text.lower()
if text[:length] == prefix: if text[:length] == prefix:
self.log.WriteText('Prefix %s is found.\n' % prefix) self.log.WriteText('Prefix %s is found.\n' % prefix)
return x return x

View File

@@ -1,8 +1,6 @@
from wxPython.wx import * from wxPython.wx import *
import string
#---------------------------------------------------------------------- #----------------------------------------------------------------------
class TestPanel(wxPanel): class TestPanel(wxPanel):

View File

@@ -1,8 +1,6 @@
from wxPython.wx import * from wxPython.wx import *
import string
#---------------------------------------------------------------------- #----------------------------------------------------------------------
class TestPanel(wxPanel): class TestPanel(wxPanel):

View File

@@ -1,8 +1,6 @@
from wxPython.wx import * from wxPython.wx import *
import string
#---------------------------------------------------------------------- #----------------------------------------------------------------------
class TestPanel(wxPanel): class TestPanel(wxPanel):

View File

@@ -1,8 +1,6 @@
from wxPython.wx import * from wxPython.wx import *
from Main import opj
import string
import images import images
#---------------------------------------------------------------------- #----------------------------------------------------------------------

View File

@@ -45,7 +45,7 @@ class PythonSTC(wxStyledTextCtrl):
self.CmdKeyAssign(ord('N'), wxSTC_SCMOD_CTRL, wxSTC_CMD_ZOOMOUT) self.CmdKeyAssign(ord('N'), wxSTC_SCMOD_CTRL, wxSTC_CMD_ZOOMOUT)
self.SetLexer(wxSTC_LEX_PYTHON) self.SetLexer(wxSTC_LEX_PYTHON)
self.SetKeyWords(0, string.join(keyword.kwlist)) self.SetKeyWords(0, " ".join(keyword.kwlist))
self.SetProperty("fold", "1") self.SetProperty("fold", "1")
self.SetProperty("tab.timmy.whinge.level", "1") self.SetProperty("tab.timmy.whinge.level", "1")
@@ -151,7 +151,7 @@ class PythonSTC(wxStyledTextCtrl):
#lst = [] #lst = []
#for x in range(50000): #for x in range(50000):
# lst.append('%05d' % x) # lst.append('%05d' % x)
#st = string.join(lst) #st = " ".join(lst)
#print len(st) #print len(st)
#self.AutoCompShow(0, st) #self.AutoCompShow(0, st)
@@ -167,7 +167,7 @@ class PythonSTC(wxStyledTextCtrl):
kw.sort() # Python sorts are case sensitive kw.sort() # Python sorts are case sensitive
self.AutoCompSetIgnoreCase(false) # so this needs to match self.AutoCompSetIgnoreCase(false) # so this needs to match
self.AutoCompShow(0, string.join(kw)) self.AutoCompShow(0, " ".join(kw))
else: else:
event.Skip() event.Skip()

View File

@@ -105,7 +105,7 @@ class TestPanel(wxPanel):
start, end = self.tc.GetSelection() start, end = self.tc.GetSelection()
text = self.tc.GetValue() text = self.tc.GetValue()
if wxPlatform == "__WXMSW__": # This is why GetStringSelection was added 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" self.log.write("GetSelection(): (%d, %d)\n"
"\tGetStringSelection(): %s\n" "\tGetStringSelection(): %s\n"
"\tSelectedText: %s\n" % "\tSelectedText: %s\n" %

View File

@@ -15,7 +15,7 @@ class TestPanel(wxPanel):
self.log = log self.log = log
panel = wxPanel(self, -1) panel = wxPanel(self, -1)
buttons = wxBoxSizer(wxHORIZONTAL) 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) b = wxToggleButton(panel, -1, word)
EVT_TOGGLEBUTTON(self, b.GetId(), self.OnToggle) EVT_TOGGLEBUTTON(self, b.GetId(), self.OnToggle)
buttons.Add(b, flag=wxALL, border=5) buttons.Add(b, flag=wxALL, border=5)