I intend to provide a text wrapping functionality option to my wxPython-based application to be switched ON and OFF from menu (like, say notepad++ allows it).
I have a wxTextCtrl and read in wxWidgets documentation that I have to manipulate the character/paragraph style with TextCtrl::SetStyle( wxTextAttr( my_atributes )) in order to provide text wrapping functionality.
Here is how I do it in my menu item handler:
def OnMenuWrapLines( self, evt):
current_style = wx.TextAttr()
self.TextCtrl.GetStyle( 0, current_style)
print "DBG: OnMenuWrapLines(): prev style = 0x%X" % current_style.GetFlags()
if evt.IsChecked():
current_style.SetFlags( current_style.GetFlags() & ~wx.TE_DONTWRAP | wx.TE_BESTWRAP)
else:
current_style.SetFlags( current_style.GetFlags() & ~wx.TE_BESTWRAP | wx.TE_DONTWRAP)
print "DBG: SetStyle(0x%x)=%d" % ( current_style.GetFlags(), self.TextCtrl.SetStyle( 0, self.TextCtrl.GetNumberOfLines(), current_style))
Which does not work as expected - the style itself is calculated ok, but it can't be set (every time this function gets entered - the style value is the same, the modified value gets not applied).
I heard somewhere that on wxMSW wrapping style can be only specified at the construction time (which is not an option for me). In this case any workaround is welcome.
Thanks in advance