2

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 :).. !

liberforce
  • 11,189
  • 37
  • 48
Ashwin Surana
  • 826
  • 3
  • 10
  • 33

3 Answers3

3

To get line numbering, use GtkSourceView instead of GtkTextView.

ptomato
  • 56,175
  • 13
  • 112
  • 165
0

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

David Ranieri
  • 39,972
  • 7
  • 52
  • 94
0

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)
user2109788
  • 1,266
  • 2
  • 12
  • 29