Ashwin Surana
Ashwin Surana

Reputation: 876

GTK+ line numbering for Text View

I'm designing an editor in GTK+ and wanted to add a feature of the gedit text editor to represent the line number at the left side of the text. I've added an image of gedit showing the line number at the left of each line. I require guidance of which widget I should use and how to use it.

Thanks in advance :).. !

Upvotes: 2

Views: 1698

Answers (3)

user2109788
user2109788

Reputation: 1336

In textview you can try this. self.textview.get_iter_at_location(x, y).get_line() Documented here http://www.pygtk.org/pygtk2tutorial/sec-TextIters.html.

x, y position can be get using the following code:

 x, y = self.textview.get_pointer()
 x, y = self.textview.window_to_buffer_coords(gtk.TEXT_WINDOW_WIDGET, x, y)

Upvotes: 0

ptomato
ptomato

Reputation: 57920

To get line numbering, use GtkSourceView instead of GtkTextView.

Upvotes: 3

David Ranieri
David Ranieri

Reputation: 41045

It's an object called geditview, you can take a look to http://code.ohloh.net/file?fid=UbTA_LHqUuoYhNCUyaNFsy91ZqQ&cid=vmd9QnPTRes&s=&browser=Default#L545

geany also implements line-numbers using an object called Scintilla

Upvotes: 0

Related Questions