How to set wxTextCtrl style to wxHSCROLL?

Tom B. sbabbitt at commspeed.net
Tue Aug 24 10:04:02 EDT 2004


"Tim" <timblack1 at yahoo.com> wrote in message
news:b8abecbd.0408202131.3418dae at posting.google.com...
> How can I set the style attribute in the following wxTextCtrl to a new
> style AFTER I have already instantiated the wxTextCtrl?  I'm trying to
> toggle the word wrap attribute of the wxTextCtrl, just like Edit->Word
> Wrap does in Windows Notepad.  (I'm building a Windows Notepad clone
> in wxPython to prove to a VB friend that it can be done.)
>
> Here is the wxTextCtrl instantiation:
>
> --------------
>     self.txtEditor = wxTextCtrl(id=wxID_WXFRAME1TXTEDITOR,
> name='txtEditor',
>         parent=self, pos=wxPoint(0, 0), size=wxSize(760, 492),
>         style=wxTE_MULTILINE, value='')
> --------------
>
> Here is the code I've tried to set the style to a new value:
>
> --------------
>     def OnMnuEditWordwrapMenu(self, event):
>         # TODO: implement word wrap
>         self.txtEditor.SetStyle(0, self.txtEditor.GetLastPosition(),
> wxHSCROLL)
>         #self.txtEditor.style = 'wxHSCROLL'
>
> --------------
>
> What is the correct syntax?
>
> Thanks!
>
> Tim
I might try
import wx

self.txtEditor.style = wx.HSCROLL
#wx.HSCROLL if an integer constant
self.txtEditor.Refresh()

You should be useing something like wx.StyledTextCtrl which has all of the
functionality built in. One thing you don't need to prove to any programmer
is that Python can be as difficult as any language. Find the proper library
to do your task, import it and use it.

Tom





More information about the Python-list mailing list