[Gimp-developer] PyGimp: letting the use pick coordinates

2009-07-06 Thread Ryan Krauss
I am using the GIMP and a Wacom tablet as a digital blackboard for a course
I am teaching this summer.  With Python and PyGimp, it is going really well
(other than my bad hand writing made worse by the tablet - it is weird
writing on the tablet and having to look to the screen to see what you have
written).  Example lecture notes can be seen here:
http://home.cs.siue.edu/rkrauss/452/lectures/07_02_09/index.html

We are coming into a mathematically intensive part of the course and I feel
like my handwritting has become a barrier.  I am creating my own text tool
that use Latex and dvipng.  The hard part is already done: I have a wxPython
application with a text control and a png preview portion and it is
basically working.  I am now working on better GIMP integration.  Right now
I type in the equations in my wxPython application and preview the png
there.  When I want to paste the png into my lecture slide, I have to switch
back to GIMP and press a key that is a short cut for a PyGimp script to load
the cached png.  Then I position it on the slide with the move tool.  Not
bad, but not as nice as Gimp's text tool.

I would like my Latex enabled approach to act like the regular text tool.
The main thing I don't know how to do is allow the user (me) to click on a
spot on the current image and pass those coordinates to PyGimp so that I can
use that as the top left corner of my png.  Does my question make sense?  Is
there an easy way to allow the user to click on a spot on the image and get
the coordinates from PyGimp?

Thanks,

Ryan
___
Gimp-developer mailing list
Gimp-developer@lists.XCF.Berkeley.EDU
https://lists.XCF.Berkeley.EDU/mailman/listinfo/gimp-developer


[Gimp-developer] Creating a layer from a selection or pasting to a specified x, y coorinate

2009-07-06 Thread Ryan Krauss
OK, so following Alexia's suggestion, I am going to plan on selecting ahead
of time the rectangle I want my text to paste into.  The upper left corner
of this selection will then be the upper left corner that I want to paste my
png to.  How do I do that?  I thought about creating a layer the same size
as the selection rectangle and pasting to (0,0) on that layer.  I see in the
pdb how to create a layer with a certain width and height, but I don't see
how to specify the offset.  And I don't see how to paste to a specific set
of coordinates.  Can this be done?  If I use pdb.gimp_edit_paste_as_new, can
I get the coordinates of the pasted selection and then move the floating
selection before anchoring?  What is the right approach?

Thanks,

Ryan

On Mon, Jul 6, 2009 at 9:37 AM, Alexia Death alexiade...@gmail.com wrote:



 On Mon, Jul 6, 2009 at 5:25 PM, Ryan Krauss ryanli...@gmail.com wrote:



 I would like my Latex enabled approach to act like the regular text tool.
 The main thing I don't know how to do is allow the user (me) to click on a
 spot on the current image and pass those coordinates to PyGimp so that I can
 use that as the top left corner of my png.  Does my question make sense?  Is
 there an easy way to allow the user to click on a spot on the image and get
 the coordinates from PyGimp?


 In various scripts when I have needed to indicate a location on a canvas
 Ive used selections. Id say using an upper left corner of a selection you
 draw first is as good as its going to get...


 --
 --Alexia

___
Gimp-developer mailing list
Gimp-developer@lists.XCF.Berkeley.EDU
https://lists.XCF.Berkeley.EDU/mailman/listinfo/gimp-developer


Re: [Gimp-developer] Improvement for measurement tool

2009-07-06 Thread Chris Mohler
On Mon, Jul 6, 2009 at 2:57 AM, Dirk
Sohlergimp-developer...@kamerastars.de wrote:
 -BEGIN PGP SIGNED MESSAGE-
 Hash: SHA1

 Chris Mohler schrieb:
 | What the heck - I added it as a (very) simple plug-in:
 | http://registry.gimp.org/node/17235

 I can’t find the menu option „Filters-Measure-Path“. :(

Hmm - did you place the plug-in into ~/.gimp-2.x/plug-ins and is it
executable? (chmod +x)

If so, try starting GIMP from a terminal and see if it throws an error?

Chris
___
Gimp-developer mailing list
Gimp-developer@lists.XCF.Berkeley.EDU
https://lists.XCF.Berkeley.EDU/mailman/listinfo/gimp-developer


Re: [Gimp-developer] Improvement for measurement tool

2009-07-06 Thread Chris Mohler
On Sun, Jul 5, 2009 at 9:42 PM, Alec Burgessbura...@gmail.com wrote:

 Works on Windows 2.6.6 but message is displayed in Error console (which I
 have as one of panels in main dock) not on the status bar. Is this somehow
 configurable?

 Note: IMO this is a feature not a bug since it allows user to change the
 path and re-measure leaving a history record in the Error console.

OK - I don't usually open the error console, but I see the same
behavior in linux with the console open.  I pretty much did just the
bare minimum on the plug-in, but I'm pretty sure it's possible to make
it pop up a message instead, and/or change the message type.


 Whether paths are Active or not does not appear to change results - it still
 shows the measurement.

 I created a second much simpler path with Free-Select-Tool then converted to
 path and named it Path_B. With the two paths it showed: Length of Path_B:
 383 px.

 It appears (based on swapping order of paths with drag+drop) that it always
 shows the length of the lowest path (the one a the bottom of the list)

For me, it gives the length of whatever path is selected in the paths
dialog.  I will install the plugin in Windows at some point and see if
I can reproduce...


 Bug?: The entry Filters - Measurement - Path is always enabled whether or
 not any path exists (expected) but in Filters-Repeat Path,  Filters-Reshow
 Path and Filters-Recently Used-Path it always shows as Disabled (grayed
 out).
 Is this an easy fix?

I see the same thing here - I'm not sure what's happening.  I will
investigate when I find some time...


Chris
___
Gimp-developer mailing list
Gimp-developer@lists.XCF.Berkeley.EDU
https://lists.XCF.Berkeley.EDU/mailman/listinfo/gimp-developer


Re: [Gimp-developer] Improvement for measurement tool

2009-07-06 Thread Rob Antonishen
 Bug?: The entry Filters - Measurement - Path is always enabled whether or
 not any path exists (expected) but in Filters-Repeat Path,  Filters-Reshow
 Path and Filters-Recently Used-Path it always shows as Disabled (grayed
 out).
 Is this an easy fix?

 I see the same thing here - I'm not sure what's happening.  I will
 investigate when I find some time...

I think that if you change the image type to * rather than  it
will be remembered.

-Rob A
___
Gimp-developer mailing list
Gimp-developer@lists.XCF.Berkeley.EDU
https://lists.XCF.Berkeley.EDU/mailman/listinfo/gimp-developer


Re: [Gimp-developer] Improvement for measurement tool

2009-07-06 Thread Chris Mohler
On Mon, Jul 6, 2009 at 12:41 PM, Rob Antonishenrob.antonis...@gmail.com wrote:
 Bug?: The entry Filters - Measurement - Path is always enabled whether or
 not any path exists (expected) but in Filters-Repeat Path,  Filters-Reshow
 Path and Filters-Recently Used-Path it always shows as Disabled (grayed
 out).
 Is this an easy fix?

 I see the same thing here - I'm not sure what's happening.  I will
 investigate when I find some time...

 I think that if you change the image type to * rather than  it
 will be remembered.

I think you are right - thanks!

Chris
___
Gimp-developer mailing list
Gimp-developer@lists.XCF.Berkeley.EDU
https://lists.XCF.Berkeley.EDU/mailman/listinfo/gimp-developer


Re: [Gimp-developer] Creating a layer from a selection or pasting to a specified x, y coorinate

2009-07-06 Thread Ryan Krauss
OK, I think I have solved my problem.  You have to know what to search for
in the pdb.  I think this will do what I need:
pdb.gimp_layer_set_offsets

There is nothing in the pdb browser for moving a layer, you have to offset
it.

On Mon, Jul 6, 2009 at 10:15 AM, Ryan Krauss ryanli...@gmail.com wrote:

 OK, so following Alexia's suggestion, I am going to plan on selecting ahead
 of time the rectangle I want my text to paste into.  The upper left corner
 of this selection will then be the upper left corner that I want to paste my
 png to.  How do I do that?  I thought about creating a layer the same size
 as the selection rectangle and pasting to (0,0) on that layer.  I see in the
 pdb how to create a layer with a certain width and height, but I don't see
 how to specify the offset.  And I don't see how to paste to a specific set
 of coordinates.  Can this be done?  If I use pdb.gimp_edit_paste_as_new, can
 I get the coordinates of the pasted selection and then move the floating
 selection before anchoring?  What is the right approach?

 Thanks,

 Ryan

 On Mon, Jul 6, 2009 at 9:37 AM, Alexia Death alexiade...@gmail.comwrote:



 On Mon, Jul 6, 2009 at 5:25 PM, Ryan Krauss ryanli...@gmail.com wrote:



 I would like my Latex enabled approach to act like the regular text
 tool.  The main thing I don't know how to do is allow the user (me) to click
 on a spot on the current image and pass those coordinates to PyGimp so that
 I can use that as the top left corner of my png.  Does my question make
 sense?  Is there an easy way to allow the user to click on a spot on the
 image and get the coordinates from PyGimp?


 In various scripts when I have needed to indicate a location on a canvas
 Ive used selections. Id say using an upper left corner of a selection you
 draw first is as good as its going to get...


 --
 --Alexia



___
Gimp-developer mailing list
Gimp-developer@lists.XCF.Berkeley.EDU
https://lists.XCF.Berkeley.EDU/mailman/listinfo/gimp-developer


Re: [Gimp-developer] Improvement for measurement tool

2009-07-06 Thread Sven Neumann
Hi,

On Sun, 2009-07-05 at 22:42 -0400, Alec Burgess wrote:

 Works on Windows 2.6.6 but message is displayed in Error console
 (which I have as one of panels in main dock) not on the status bar. Is
 this somehow configurable?
 
 Note: IMO this is a feature not a bug since it allows user to change
 the path and re-measure leaving a history record in the Error
 console.

If the error-console is opened, all messages are redirected there. The
ideas is that the error-console is only useful when debugging or
developing scripts.

 Bug?: The entry Filters - Measurement - Path is always enabled
 whether or not any path exists (expected) but in Filters-Repeat
 Path,  Filters-Reshow Path and Filters-Recently Used-Path it
 always shows as Disabled (grayed out).
 Is this an easy fix?

This might fix itself if you change your script not to use the
deprecated register() API. You should instead use the variant that
passes the menu location as value of the named parameter 'menu'. The way
your script is using register() triggers an obscure backward
compatibility quirks mode, which is probably not what you want.


Sven


___
Gimp-developer mailing list
Gimp-developer@lists.XCF.Berkeley.EDU
https://lists.XCF.Berkeley.EDU/mailman/listinfo/gimp-developer


Re: [Gimp-developer] starting out developing with python-fu

2009-07-06 Thread Sven Neumann
Hi,

On Mon, 2009-07-06 at 00:47 -0400, sergio wrote:
 i am currently working on figuring out how python fu works by  
 following some of the tutorials i see online..
 
 in trying to get a simple one running, and am having problems...
 
 running listing [1], i get:
 
 Traceback (most recent call last):
File /opt/local/lib/gimp/2.0/python/gimpfu.py, line 801, in _run
  res = apply(func, params[1:])
 TypeError: python_pytest() takes exactly 2 arguments (0 given)
 
 in the terminal window..
 
 any ideas?
 
 thanks!
 
 
 
 
 
 listing [1]
 
 #!/usr/bin/env python
 
 from gimpfu import *
 
 def python_pytest(img, layer) :
  pdb.gimp_image_flip(img, ORIENTATION_VERTICAL)
 
 register(
   python_fu_pytest,
   Does something,
   Does something terribly useful,
   Your name,
   Your name,
   2009,
   Py Test...,
   *,
   [
   ],
   [],
   python_pytest,
  menu=Image/Filters/Distorts)
 
 main()

You register your script with zero parameters, but your python_pytest()
function takes two parameters. Just have a look at the scripts that ship
with GIMP.


Sven


___
Gimp-developer mailing list
Gimp-developer@lists.XCF.Berkeley.EDU
https://lists.XCF.Berkeley.EDU/mailman/listinfo/gimp-developer


Re: [Gimp-developer] [Gegl-developer] GEGL-0.1.0

2009-07-06 Thread Sven Neumann
Hi,

On Sat, 2009-07-04 at 12:45 +0100, Øyvind Kolås wrote:
 GEGL 0.1.0
 ⎺⎺

Congratulations to this release. Will the gegl.org web-site be updated
anytime soon?

Note to all users of GIMP 2.6: The gimp-2.6 releases that we have done
so far will not work with GEGL 0.1.0 (or babl 0.1.0). This is not
because GEGL would be incompatible, but rather because of a stupid bug
in the run-time version check. This is fixed in git and we plan to do
GIMP 2.6.7 release with this fix soonish. There are however a few more
patches pending that we'd like to get into 2.6.7 as well. So give us a
few more days...


Sven


___
Gimp-developer mailing list
Gimp-developer@lists.XCF.Berkeley.EDU
https://lists.XCF.Berkeley.EDU/mailman/listinfo/gimp-developer


Re: [Gimp-developer] Improvement for measurement tool

2009-07-06 Thread Chris Mohler
On Mon, Jul 6, 2009 at 2:55 PM, Sven Neumanns...@gimp.org wrote:
 On Sun, 2009-07-05 at 22:42 -0400, Alec Burgess wrote:
 Bug?: The entry Filters - Measurement - Path is always enabled
 whether or not any path exists (expected) but in Filters-Repeat
 Path,  Filters-Reshow Path and Filters-Recently Used-Path it
 always shows as Disabled (grayed out).
 Is this an easy fix?

 This might fix itself if you change your script not to use the
 deprecated register() API. You should instead use the variant that
 passes the menu location as value of the named parameter 'menu'. The way
 your script is using register() triggers an obscure backward
 compatibility quirks mode, which is probably not what you want.

I had a little trouble finding docs on the named parameters (I ended
up using help(gimpfu.register) in the console).  I've pasted the new
register() below - one thing seemed strange: the 'params' parameter
seems to require that I add the current image and drawable - is that
correct?  Any other big mistakes here?  ;)

Thanks,
Chris

register(
proc_name=(python-fu-measure-path),
blurb=(Measure Path),
help=(Measure Length of the active path.  Output is directed to
the Status Bar or Error Console.),
author=(Chris Mohler),
copyright=(Chris Mohler),
date=(2009),
label=(Active Path),
imagetypes=(*),
params=[
(PF_IMAGE, img, Image, None),
(PF_DRAWABLE, drw, Drawable, None)
   ],
results=[],
function=(measure_path),
menu=(Image/Filters/Measure),
domain=(gimp20-python, gimp.locale_directory)
)
___
Gimp-developer mailing list
Gimp-developer@lists.XCF.Berkeley.EDU
https://lists.XCF.Berkeley.EDU/mailman/listinfo/gimp-developer


Re: [Gimp-developer] Improvement for measurement tool

2009-07-06 Thread Chris Mohler
On Sun, Jul 5, 2009 at 9:42 PM, Alec Burgessbura...@gmail.com wrote:

 Whether paths are Active or not does not appear to change results - it still
 shows the measurement.

I've updated the plug-in at the registry
(http://registry.gimp.org/node/17235).  If in doubt which is which, I
added 'Version 0.2' to the header info of this one.

In linux and XP (both 2.6.6), it reports the length of whichever path
is selected in the Paths dialog.

I also fixed the 'Repeat' and 'Reshow' weirdness, and also disabled
the plug-in when no image is open.

Let me know how it works out...

Chris
___
Gimp-developer mailing list
Gimp-developer@lists.XCF.Berkeley.EDU
https://lists.XCF.Berkeley.EDU/mailman/listinfo/gimp-developer


Re: [Gimp-developer] Improvement for measurement tool

2009-07-06 Thread Sven Neumann
Hi,

On Mon, 2009-07-06 at 16:58 -0500, Chris Mohler wrote:

 I had a little trouble finding docs on the named parameters (I ended
 up using help(gimpfu.register) in the console).  I've pasted the new
 register() below - one thing seemed strange: the 'params' parameter
 seems to require that I add the current image and drawable - is that
 correct?  Any other big mistakes here?  ;)

Why does it require that? What's required is that you register all the
parameters that your function actually needs. If you need an image
parameter, then you should have PF_IMAGE in your input parameters. If
you also need a drawable, then this should be followed by PF_DRAWABLE.
But these are by no means obligatory. If you don't need an image nor a
drawable, then you can safely omit them.


Sven


___
Gimp-developer mailing list
Gimp-developer@lists.XCF.Berkeley.EDU
https://lists.XCF.Berkeley.EDU/mailman/listinfo/gimp-developer


Re: [Gimp-developer] Improvement for measurement tool

2009-07-06 Thread Chris Mohler
On Mon, Jul 6, 2009 at 5:19 PM, Sven Neumanns...@gimp.org wrote:
 Hi,

 On Mon, 2009-07-06 at 16:58 -0500, Chris Mohler wrote:

 I had a little trouble finding docs on the named parameters (I ended
 up using help(gimpfu.register) in the console).  I've pasted the new
 register() below - one thing seemed strange: the 'params' parameter
 seems to require that I add the current image and drawable - is that
 correct?  Any other big mistakes here?  ;)

 Why does it require that? What's required is that you register all the
 parameters that your function actually needs. If you need an image
 parameter, then you should have PF_IMAGE in your input parameters. If
 you also need a drawable, then this should be followed by PF_DRAWABLE.
 But these are by no means obligatory. If you don't need an image nor a
 drawable, then you can safely omit them.

Sorry - I did not phrase that very well.

When using the old, unnamed register() parameters, if you leave
'params' empty, the main plug-in function still receives two
parameters - the current image and drawable.  Using the new, named
register() parameters does not seem to do this anymore.

No big deal really, but I thought it odd that the behavior would be different.

Chris
___
Gimp-developer mailing list
Gimp-developer@lists.XCF.Berkeley.EDU
https://lists.XCF.Berkeley.EDU/mailman/listinfo/gimp-developer


Re: [Gimp-developer] Improvement for measurement tool

2009-07-06 Thread Sven Neumann
Hi,

On Mon, 2009-07-06 at 17:32 -0500, Chris Mohler wrote:

 When using the old, unnamed register() parameters, if you leave
 'params' empty, the main plug-in function still receives two
 parameters - the current image and drawable.  Using the new, named
 register() parameters does not seem to do this anymore.
 
 No big deal really, but I thought it odd that the behavior would be different.

That is exactly the odd quirks mode for backward compatibility that I
mentioned. If you use the old register() API, then parameters are added
for you depending on the menu location your script is registering to. As
that is hard to understand and frequently leads to automatically added
parameters that the script does not actually need, this behavior was
changed. It is still there, for backward compatibility, if you use the
old API though.


Sven


___
Gimp-developer mailing list
Gimp-developer@lists.XCF.Berkeley.EDU
https://lists.XCF.Berkeley.EDU/mailman/listinfo/gimp-developer


Re: [Gimp-developer] Improvement for measurement tool

2009-07-06 Thread Chris Mohler
On Mon, Jul 6, 2009 at 5:45 PM, Sven Neumanns...@gimp.org wrote:
 Hi,

 On Mon, 2009-07-06 at 17:32 -0500, Chris Mohler wrote:

 When using the old, unnamed register() parameters, if you leave
 'params' empty, the main plug-in function still receives two
 parameters - the current image and drawable.  Using the new, named
 register() parameters does not seem to do this anymore.

 No big deal really, but I thought it odd that the behavior would be 
 different.

 That is exactly the odd quirks mode for backward compatibility that I
 mentioned. If you use the old register() API, then parameters are added
 for you depending on the menu location your script is registering to. As
 that is hard to understand and frequently leads to automatically added
 parameters that the script does not actually need, this behavior was
 changed. It is still there, for backward compatibility, if you use the
 old API though.

OK - thanks for clarifying that.  I had no idea that the automatic
parameters varied based on menu location.

Chris
___
Gimp-developer mailing list
Gimp-developer@lists.XCF.Berkeley.EDU
https://lists.XCF.Berkeley.EDU/mailman/listinfo/gimp-developer