@mikael Please, try this
import ui
from objc_util import *
tv = ui.TextView()
tv.font = ('<System-Bold>',32)
tv.text = 'thid is a sample but could be longer'
tv.frame = (0,0,200,200)
tv.present('sheet')
tvo = ObjCInstance(tv)
#print(dir(tvo))
txt = 'coul'
i = tv.text.find(txt)
p1 = tvo.positionFromPosition_offset_(tvo.beginningOfDocument(), i)
p2 = tvo.positionFromPosition_offset_(tvo.beginningOfDocument(), i+len(txt))
rge = tvo.textRangeFromPosition_toPosition_(p1,p2)
rect = tvo.firstRectForRange_(rge) # CGRect
x,y = rect.origin.x,rect.origin.y
w,h = rect.size.width,rect.size.height
print(x,y,w,h)
l = ui.Label()
l.frame = (x,y,w,h)
l.background_color = (1,0,0,0.5)
tv.add_subview(l)

Or use a button instead a label
tv.text = 'this is a sample but could be longer'
...
txt = 'ampl'
...
l = ui.Button()
l.frame = (x,y,w,h)
l.background_color = (1,0,0,0.5)
l.corner_radius = 10
l.border_width = 1
def button_action(sender):
if l.background_color == (1,0,0,0.5):
sender.background_color = (0,0,1,0.5)
else:
sender.background_color = (1,0,0,0.5)
l.action = button_action
