Reputation: 168
I have a application written in PyGtk. I need to convert a particular line number into its corresponding window co-ordinates in a GtkTextView. How can this be done?
Upvotes: 0
Views: 148
Reputation: 399919
Begin by using gtk_text_buffer_get_iter_at_line()
to get a handle on the line. Then use gtk_text_view_get_line_yrange()
to convert that into pixel coordinates. Finally use gtk_text_view_buffer_to_window_coords()
to convert the buffer pixel coordinates into window coordinates.
These are links to the C API calls, but converting to PyGtk should be trivial.
Upvotes: 2
Reputation: 6338
It can't be done, in general. If you're talking about a line of your pygtk program, then you would need an API for your IDE (development environment) to find out where a particular source code line is currently displayed on the screen, if anywhere. If by "line number" you mean something else, then as Ignacio says, you'll need to provide a lot more detail.
Upvotes: 0