Anyone: if you can run the code (way below) and it does not scroll all
over the place for minutes, please report. Only robin has seen it run
nicely so far.
Robin: i updated everything gtk related on my box and restarted it to
make sure no in-memory versions of the libs are running. heres my
relevent version info:
ii gtkam 0.1.2-2 GTK+ application for digital still
cameras
ii gtkdiff 1.8.0-2 A graphical text comparison tool
ii gtkglarea5 1.2.3-1 Gimp Toolkit OpenGL area widget shared
libra
ii gtkhtml 1.0.4-1 HTML rendering/editing library - bonobo
comp
ii gtksee 0.5.0-5 GTK-based clone of ACDSee (an image
viewer)
ii libgdk-pixbuf2 0.22.0-3 The GdkPixBuf image library, gtk+ 1.2
versio
ii libgnorbagtk0 1.4.1.4-3 Gnome CORBA services (Gtk bindings)
ii libgtk1.2 1.2.10-16 The GIMP Toolkit set of widgets for X
ii libgtk1.2-comm 1.2.10-16 Common files for the GTK+ library
ii libgtk1.2-dev 1.2.10-16 Development files for the GIMP Toolkit
ii libgtk2.0-0 2.2.4-3 The GTK+ graphical user interface
library
ii libgtk2.0-comm 2.2.4-3 Common files for the GTK+ graphical
user int
ii libgtk2.0-dbg 2.2.4-3 The GTK+ libraries and debugging
symbols
ii libgtk2.0-dev 2.2.4-3 Development files for the GTK+ library
ii libgtk2.0-doc 2.2.4-3 Documentation for the GTK+ graphical
user in
ii libgtkhtml-dat 1.0.2-1 HTML rendering/editing library - data
files.
ii libgtkhtml20 1.0.4-1 HTML rendering/editing library -
runtime fil
ii libgtkspell0 2.0.4-6 a spell-checking addon for GTK's
TextView wi
ii libgtkxmhtml1 1.4.1.4-3 The Gnome gtkxmhtml (HTML) widget
ii libwxgtk2.2 2.2.9.2 wxWindows Cross-platform C++ GUI
toolkit (GT
ii libwxgtk2.4 2.4.2.4 wxWindows Cross-platform C++ GUI
toolkit (GT
ii libwxgtk2.4-py 2.4.2.4 wxWindows Cross-platform C++ GUI
toolkit (wx
ii python-gtk-1.2 0.6.11-18 GTK support module for Python
ii rep-gtk 0.18-5 GTK binding for librep
import string,os,re
from wxPython.wx import *
from wxPython.lib.scrolledpanel import wxScrolledPanel
class MainWindow(wxFrame):
""" INSTRUCTIONS: run code in a directory with lots of wx files.
In the small upper box, enter a path to a file.
Then press the 'make' button
Program will now open file in lower textctrl and replace all 'wx'
with 'wx' in red.
"""
def __init__(self,parent,id,title):
wxFrame.__init__(self,parent,-4, title, size = ( 200,100),
style=wxDEFAULT_FRAME_STYLE|wxNO_FULL_REPAINT_ON_RESIZE)
self.filetable={}
self.control = wxSplitterWindow(self,1)
p1 = wxScrolledPanel(self.control,1)
ppu=200
p1.SetScrollbars(ppu, ppu, 200/ppu, 200*100/ppu)
self.varPanel = p1
p1.sizer = wxBoxSizer(wxVERTICAL)
p1.sizer.Add(wxTextCtrl(p1,1,"yaya"*1000,style=wxTE_MULTILINE|wxHSCROLL),
1, wxEXPAND)
p1.SetSizer(p1.sizer)
p1.SetAutoLayout(1)
p1.sizer.Fit(p1)
p2 = wxPanel(self.control,1)
p2.sizer = wxBoxSizer(wxVERTICAL)
self.qtext = wxTextCtrl(p2,1,"")
p2.sizer.Add(self.qtext)
p2.sizer.Add(wxButton(p2,10,"Make"))
self.ftext = wxTextCtrl(p2,1,"File goes
here",size=(800,400),style=wxTE_MULTILINE)
p2.sizer.Add(self.ftext,wxEXPAND)
EVT_BUTTON(p2,10,self.filedo)
p2.SetSizer(p2.sizer)
p2.SetAutoLayout(1)
p2.sizer.Fit(p2)
self.control.SplitVertically(p1,p2,300)
self.sizer = wxBoxSizer(wxVERTICAL)
self.sizer.Add(self.control,1, wxEXPAND)
self.SetSizer(self.sizer)
self.Show(true)
def filedo(self,event):
f = open(self.qtext.GetValue()).read()
self.ftext.SetValue(f)
serstr = "wx"
l = findall(serstr,f)
for n,each in enumerate(l):
self.ftext.SetStyle(each,each+len(serstr),wxTextAttr("RED"))
def findall(sub,s):
if s =='' or sub =='':
return []
ret=[]
findval=0
pos=0
while findval != -1:
findval = s.find(sub,pos)
if findval != -1:
ret.append(findval)
pos = findval + len(sub)
return ret
app = wxPySimpleApp()
frame = MainWindow(None, -1, "Small editor")
app.MainLoop()