Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Python-Fu - pdb.query ; how to filter to readable output
#1
Caveat: I'm new to Python & Object-Oriented Programming (and not particularly skilled with GIMP)

I'm trying to learn a little about automating GIMP, and found this tutorial:

https://www.gimp.org/tutorials/Automate_Editing_in_GIMP

I was able to do the first little example, finding the python console within GIMP, and learned quite a bit, enough to do some experimenting on my own.

One thing I wanted to experiment with was setting the grid color, and I guessed at several properties ("attributes"?) of the object (?) "pdb" (which I googled to discover was GIMP's "procedural database", which I take to mean the database of scriptable procedures within GIMP), but none of my attempts (like "pdb.gimp_image_grid_set_fgcolor()" or pdb.gimp_image_grid_set_foreground_color()", etc) worked. So I figured there must be a way to list all the attributes ("properties"?) of an object, and after quite a bit of googling, came up with two [relatively easy, one-liner) possibilities:

dir(pdb)

and

pdb.query()

(I see they produce different info, so I'm unclear as to which, if either, will be my better option, but that's a question for later).

The problem is that both commands give too much information to look through efficiently.

So I did yet more googling, and came up with:

re.findall("grid",str(pdb.query()))

hoping to just get the items mentioning "grid", but all that returned was a bunch of "grid"s.

In bash, I'd try something like "pdb.query() | grep grid" (which might or might not give me usable results).

So, my questions:

1. Which is better and why, pdb.query() or dir(pdb), or are neither of these suitable for learning about the attributes/properties of an object?

2. Is there a better way of learning about the properties/attributes of an object (to figure out what attribute/property to tinker with to change the color of the grid a la the tutorial mentioned above?

3. How do I list all the attributes/properties of an object that has a lot of these attributes/properties and filter the results or present them in a way that is digestible, particularly as it relates to the output of "pdb.query" or "dir(pdb)"?

Thanks!

--
Kent
Reply


Messages In This Thread
Python-Fu - pdb.query ; how to filter to readable output - by DebianFanatic - 10-06-2018, 11:23 PM

Forum Jump: