0

Is there some method which tells you the line number and column number of a Text widget in Perl/Tk?

Kevin Panko
  • 8,356
  • 19
  • 50
  • 61
Liam Willis
  • 661
  • 6
  • 17

1 Answers1

3

According to the documentation, the widget has a method index() which returns the "line.char" of various positions in the widget. Pass it the name of the special mark "insert" to get the current position of the insertion cursor. Pass it the name of the special mark "current" to get the current position on the mouse.

Your question doesn't make it clear which of the two you want.

Dave Cross
  • 68,119
  • 3
  • 51
  • 97
  • I want to get both, the line number as well as the column number. How do I extract both of them? – Liam Willis Jan 30 '14 at 17:35
  • @LiamWillis Call it twice, once for each index mark that you care about? – Donal Fellows Jan 30 '14 at 22:42
  • @LiamWillis: Yes, I know. And the `index()` method gives you both of them. It returns both values separated by a dot - as I said. Have you tried reading the documentation? :-) – Dave Cross Jan 31 '14 at 09:20