I'm using wx.TextCtrl.SetStyle() in my code, but it's changing the style of all the text!
Here's my code:
# Get all the words in my TextCtrl
words = self.GetValue().split(" ")
# Find out what the farthest uneditable word is.
farthest_uneditable = (len(words) // length_constants["words_per_block"]) * length_constants["words_per_block"]
# Use this word knowledge to calculate the actual farthest uneditable character is
farthest_position = 0
for word in range(farthest_uneditable):
farthest_position += len(words[word]) + 1
# Make all the uneditable text (everything from the beginning to farthest_uneditable) have a grey background
self.SetStyle(0, farthest_position, wx.TextAttr(wx.NullColour, (84, 84, 84)))
I've tested this code and made sure my farthest_position isn't at the end of my TextCtrl (It's been in the expected position each time). For some reason though, all of the text in my TextCtrl box is getting a grey background.