python - wxPython SetStyle Not Working -
i'm using wx.textctrl.setstyle() in code, it's changing style of text!
here's code:
# words in textctrl words = self.getvalue().split(" ") # find out farthest uneditable word is. farthest_uneditable = (len(words) // length_constants["words_per_block"]) * length_constants["words_per_block"] # use word knowledge calculate actual farthest uneditable character farthest_position = 0 word in range(farthest_uneditable): farthest_position += len(words[word]) + 1 # make uneditable text (everything beginning farthest_uneditable) have grey background self.setstyle(0, farthest_position, wx.textattr(wx.nullcolour, (84, 84, 84))) i've tested code , made sure farthest_position isn't @ end of textctrl (it's been in expected position each time). reason though, of text in textctrl box getting grey background.
from wxpython 2.8 documentation. last paragraph explains problem is:
" **wxtextctrl::getrange
virtual wxstring getrange(long from, long to) const**
returns string containing text starting in positions , to in control. positions must have been returned wxtextctrl method.
please note positions in multiline wxtextctrl not correspond indices in string returned getvalue because of different new line representations (cr or cr lf) , method should used obtain correct results instead of extracting parts of entire value. may more efficient, if control contains lot of data."
Comments
Post a Comment