简体   繁体   中英

Convert Line Number Into its corresponding co-ordinates

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?

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM