I'm having great difficulties with testing certain (character) attributes.
As I see from some examples I've to create some kind of template first,
by creating an new instance of TextAttr (should it really be that complicated?)
Now the next test always returns false (except when no selection is mad)
aap = rt.TextAttrEx ()
aap.SetFontStyle ( wx.ITALIC )
aap.SetFontWeight ( wx.BOLD )
print self.rtc.HasCharacterAttributes ( self.rtc.GetSelection(), aap )
The next code gives an error ??
aap = rt.RichTextAttr ()
aap.SetFontWeight (wx.BOLD)
print self.rtc.GetStyle ( self.rtc.GetSelection(), aap )
TypeError: in method 'RichTextCtrl_GetStyle', expected argument 2 of type 'long'
So that remains 2 questions:
1. how to test the character attributes ?
2. how to test attributes at the position of the caret (because then GetSelection returns 2 identical negative numbers) ?
I'm having great difficulties with testing certain (character) attributes.
As I see from some examples I've to create some kind of template first,
by creating an new instance of TextAttr (should it really be that complicated?)
Now the next test always returns false (except when no selection is mad)
aap = rt.TextAttrEx ()
aap.SetFontStyle ( wx.ITALIC )
aap.SetFontWeight ( wx.BOLD )
print self.rtc.HasCharacterAttributes ( self.rtc.GetSelection(), aap )
The next code gives an error ??
aap = rt.RichTextAttr ()
aap.SetFontWeight (wx.BOLD)
print self.rtc.GetStyle ( self.rtc.GetSelection(), aap )
TypeError: in method 'RichTextCtrl_GetStyle', expected argument 2 of type 'long'
So that remains 2 questions:
1. how to test the character attributes ?
Looking at the code I would expect the HasCharacterAttributes to work... If you make a small runnable sample I'll trace through it in the debugger to see what is going on.
2. how to test attributes at the position of the caret (because then GetSelection returns 2 identical negative numbers) ?
Here is the docstring (see pydoc wx.richtext.RichTextCtrl.GetStyle):
GetStyle(self, long position, TextAttrEx style) -> bool
Retrieve the style used at the given position. Copies the style
values at ``position`` into the ``style`` parameter and returns ``True``
if successful. Returns ``False`` otherwise.
GetStyle is looking for a single position value, not a range. So use GetInsertionPoint to get the position of the caret.
···
--
Robin Dunn
Software Craftsman http://wxPython.org Java give you jitters? Relax with wxPython!