python - Tkinter Text widget - identify line by y-coord -
is there method identify row/column in tkinter.text
widget in tkinter
? mean methods identify_row(event.y)
, identify_column(event.x)
.
i want highlight line bellow cursor , need work disabled text widget.
i thinking of getting height , count line number current y coord , height of line, thought, there might better way.
so, there? thank advice.
found it, works me:
def __onlclicked(self, event): linestart = self.index("@{0},{1} linestart".format(event.x, event.y)) lineend = self.index("{} lineend".format(linestart)) self.tag_remove("current_line", 1.0, "end") self.tag_add("current_line", linestart, lineend)
only 1 detail, unfortunately doesn't higlight lines same, because each line has different length. if knows how highlight full 'width' (the length of longes line guess) every line without adding spaces...that'd great!
Comments
Post a Comment