Gimp-Forum.net
Python-Fu · Get viewport position - Printable Version

+- Gimp-Forum.net (https://www.gimp-forum.net)
+-- Forum: GIMP (https://www.gimp-forum.net/Forum-GIMP)
+--- Forum: Extending the GIMP (https://www.gimp-forum.net/Forum-Extending-the-GIMP)
+---- Forum: Scripting questions (https://www.gimp-forum.net/Forum-Scripting-questions)
+---- Thread: Python-Fu · Get viewport position (/Thread-Python-Fu-%C2%B7-Get-viewport-position)



Python-Fu · Get viewport position - guiritter - 12-16-2017

Hi everyone.

I'm writing a plugin to automate some processes. I'm sticking to Python because I've had issues with C and Scheme.

Consider an image opened in GIMP with a zoom large enough to cause only part of the image to be seen. So, you can scroll the viewport around to see other parts of the image.

I want to know what code I have to use to know which pixels are visible, so I can add a layer to the image to a position where it will be visible in my current zoom setting.

I'm using GIMP 2.8.20 on Windows 7 Ultimate x64.

Thanks in advance.


RE: Python-Fu · Get viewport position - Ofnuts - 12-16-2017

AFAIK you can't. By design the plugins don't know much about what is happening in the UI, and also cannot make any change to it.

Also, in the general case your question has no answer, how do you handle the case where the user has opened several "views"(*) of the same image?

(*) View>New view


RE: Python-Fu · Get viewport position - guiritter - 12-16-2017

(12-16-2017, 04:49 PM)Ofnuts Wrote: AFAIK you can't. By design the plugins don't know much about what is happening in the UI, and also cannot make any change to it.

Also, in the general case your question has no answer, how do you handle the case where the user has opened several "views"(*) of the same image?

(*) View>New view

That's too bad. I'll have to improvise by making a selection to mark where to add the layer.

Thanks anyway!

Regarding the second point, I'm doing this only for me so I'll never open more than one view.


RE: Python-Fu · Get viewport position - Ofnuts - 12-16-2017

(12-16-2017, 05:04 PM)guiritter Wrote:
(12-16-2017, 04:49 PM)Ofnuts Wrote: AFAIK you can't. By design the plugins don't know much about what is happening in the UI, and also cannot make any change to it.

Also, in the general case your question has no answer, how do you handle the case where the user has opened several "views"(*) of the same image?

(*) View>New view

That's too bad. I'll have to improvise by making a selection to mark where to add the layer.

Which is pretty much the right way to do it anyway Smile