Thanks a lot!
I’ll ask Julian, and when I can get more info, I will post it.
Meanwhile, I kept trying and got the working function below:
def OnBulletList(self, evt):
ip = self.rtc.GetInsertionPoint()
attr = rt.RichTextAttr()
if self.rtc.GetStyle(ip, attr) and attr.BulletStyle > 0: #Ignoring the possibility of numbered lists on purpose (I don't use them in my app)!
# Takes out the list style
self.rtc.MoveToParagraphStart()
start = self.rtc.GetInsertionPoint()
self.rtc.MoveToParagraphEnd()
end = self.rtc.GetInsertionPoint()
r = rt.RichTextRange(start, end)
attr.SetFlags(rt.TEXT_ATTR_BULLET_STYLE | rt.TEXT_ATTR_BULLET_NUMBER | rt.TEXT_ATTR_BULLET_TEXT | rt.TEXT_ATTR_BULLET_NAME)
attr.BulletStyle = 0
attr.BulletNumber = 0
attr.BulletText = u''
attr.BulletName = u''
attr.BulletFont = u''
self.rtc.SetStyle(r, attr)
else:
# Transforms the current paragraph in a bulleted list item
self.rtc.MoveToParagraphStart()
self.rtc.MoveLeft()
start = self.rtc.GetInsertionPoint()
self.rtc.SetSelection(start, start+1)
self.rtc.DeleteSelection()
self.rtc.BeginSymbolBullet(unichr(9679), 100, 60)
self.rtc.Newline()
self.rtc.MoveToParagraphEnd()
self.rtc.EndSymbolBullet()
# Set the insertion point where it was
self.rtc.MoveCaret(ip)
return
I got rid of the extra paragraph, but even this is rather functional, works only for the paragraph where the insertion point is. The oddity here is that to TAKE OUT the bullets, SetStyle works!
I’ll appreciate if someone can give me a hint about how can I do this work in the case of multiple selected paragraphs. Even if that is not a real issue in my current working scenario, certainly gives a “not well enough done” look if you have to transform each paragraph intended to form part of a list.
Walter
···
El mar, 22-04-2008 a las 15:18 -0700, Robin Dunn escribió:
Walter Mario Gardella Sambeth wrote: > Can someone explain if I'm missing something, or which is the correct > way to apply the style (and to remove it). The RichTextCtrl expert is Julian Smart, and you can reach him via the wx lists. He's not Python person however so you may have to be a little persistent.