View Full Version : Tkinter Text Widget with Line Numbers

October 27th, 2009, 05:34 PM
Hey all,

I'm working on an app in Tkinter and would like to add Line Numbers to the Text widget, but am not sure what the best approach would be. I found this (http://tkinter.unpythonic.net/wiki/A_Text_Widget_with_Line_Numbers) while searching through Google, but it seems a bit clunky to me.

Anyone got any ideas? Thanks!

Penguin Guy
October 27th, 2009, 05:36 PM
Have you taken a look at this (http://tkinter.unpythonic.net/wiki/A_Text_Widget_with_Line_Numbers)?

October 27th, 2009, 05:50 PM
Yes, but there are a things about it that might cause problems. Mainly that it relies on the lines all being 6 pixels in height (which won't always be the case). Having said that I'm not quite sure what a better approach would be.

Does anyone know a way to find out the height of a specific line? Could this be worked out from the Font setting somehow?