[wxpython-users] Repeatedly zooming and resizing a StyledTextCtrl

Jesse Aldridge jessealdridge at gmail.com
Mon Mar 24 16:44:24 PDT 2008


Would it be possible to get the following code to perform at a reasonable
speed?  I'm wanting to experiment with a zooming interface for editing
source code.  I got everything working but performance is lowzy.  I created
this test case to determine whether it was feasible to rapidly resize and
zoom a StyledTextControl over and over.  Performance is good when I do just
resizing or just zooming, but when I try to do both my computer drags
majorly.  The PythonSTC code comes straight out of StyledTextCtrl_2 in the
wxPython demo.

import wx
from PythonSTC import PythonSTC
app =3D wx.App()


class Test_Panel( wx.Panel ):
  def __init__( self, parent ):
    wx.Panel.__init__( self, parent )
    self.Bind( wx.EVT_MOTION, self.on_mouse_move )

  def on_mouse_move( self, e ):
    mouse_pos =3D e.GetPosition()

    box =3D self.GetChildren()[0]

    box.SetDimensions( 0, 0, mouse_pos.x, mouse_pos.y )
    box.SetZoom( mouse_pos.x * .1 )

app =3D wx.App()
frame =3D wx.Frame( None, size =3D (640, 480) )
frame.SetSizer( wx.BoxSizer( wx.VERTICAL ) )
panel =3D Test_Panel( frame )
frame.GetSizer().Add( panel, proportion =3D 1, flag =3D wx.EXPAND )

text_box =3D PythonSTC( panel, -1 )
text_box.SetText( "foo" )
text_box.SetDimensions( 0, 0, 300, 300 )

frame.Show( True )
app.MainLoop()
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.wxwidgets.org/pipermail/wxpython-users/attachments/200803=
24/18a78c45/attachment.htm


More information about the wxpython-users mailing list