Gimp-Forum.net
GIMP 2.10 a brush in the filter parameters - Printable Version

+- Gimp-Forum.net (https://www.gimp-forum.net)
+-- Forum: GIMP (https://www.gimp-forum.net/Forum-GIMP)
+--- Forum: Gimp 2.10 (https://www.gimp-forum.net/Forum-Gimp-2-10)
+--- Thread: GIMP 2.10 a brush in the filter parameters (/Thread-GIMP-2-10-a-brush-in-the-filter-parameters)

Pages: 1 2


GIMP 2.10 a brush in the filter parameters - dinasset - 05-04-2018

Hi,
in my activity of porting my filters to 2.10, I faced a strange behavior:
- there is a filter (running on 2.8) which as a "brush" parameter in the definition  
- trying to see it under 2.10 it was in the menu but not showing its menu when launched
- after some trials I discovered that removing the filter name from the parameters it was showing, but..
  only once (unless resetting all the filters)

So I decided to write a couple of test filters, one with the brush parameter (but set to None), the other one which uses the active brush.
The behavior was confirmed:
- using the first one I can see it and run only once (unless resetting the filters)
- using the second one I can see it and run as many times as I like

Ther same 2 filters included in my 2.8, show up and run always.

Hence I post here these 2 small filters; if someone is so kind to double-check them, I will appreciate 
The first one
Code:
#!/usr/bin/env python
from gimpfu import *
import random


def testBrushAsParm (inImage, inDrawable, inBrush, Run) :

   pdb.gimp_context_push
   pdb.gimp_image_undo_group_start(inImage)
   
   # set parameters for drawing the lines
   pdb.gimp_context_set_brush (inBrush)
   distance=100
   count=int(inDrawable.height/distance)
   h=0
   for h in range(count):
       x1 = 0                                  
       x2 = inDrawable.width                
       y1 = 25+(h*distance)              
       y2 = y1
       #info_msg ("x1, x2, y1, y2, Dw, Rh = "+str(x1)+",  "+str(x2)+",  "+str(y1)+",  "+str(y2)+",  "+str(Dw)+",  "+str(Rh))
       pdb.gimp_paintbrush (inDrawable, 0, 4,
                (x1, y1, x2, y2), PAINT_CONSTANT, 0)  
       h+=1
       
   pdb.gimp_image_undo_group_end(inImage)
   return()

# This is the plugin registration function
register(
   "testBrushAsParm",    
   "To test a Brush As Parameter",  
   "This script tests a Brush in the Parameters.",
   "Diego",
   "Diego Nassetti ",
   "2018",
   "testBrushAsParm",
   "RGB*",
   [
     (PF_IMAGE, "image", "Input image", None),
     (PF_DRAWABLE, "drawable", "Input drawable", None),
     (PF_BRUSH, "brush", "Brush to use", None),      
     (PF_TOGGLE, "test", "Does it run more than once?", False),    # fake parameter !
   ],
   [
     (PF_DRAWABLE, "odrawable", "Output drawable", None),
   ],
   testBrushAsParm,
   menu="<Image>/Test",
   )

main()
The second one


Code:
#!/usr/bin/env python
from gimpfu import *
import random


def testBrushAsNoParm (inImage, inDrawable, Run) :

   pdb.gimp_context_push
   pdb.gimp_image_undo_group_start(inImage)
   
   # set parameters for drawing the lines
   distance=100
   count=int(inDrawable.height/distance)
   h=0
   for h in range(count):
       x1 = 0                                  
       x2 = inDrawable.width                
       y1 = 25+(h*distance)              
       y2 = y1
       #info_msg ("x1, x2, y1, y2, Dw, Rh = "+str(x1)+",  "+str(x2)+",  "+str(y1)+",  "+str(y2)+",  "+str(Dw)+",  "+str(Rh))
       pdb.gimp_paintbrush (inDrawable, 0, 4,
                (x1, y1, x2, y2), PAINT_CONSTANT, 0)  
       h+=1
       
   pdb.gimp_image_undo_group_end(inImage)
   return()

# This is the plugin registration function
register(
   "testBrushAsNoParm",    
   "To test a Brush Not As Parameter",  
   "This script tests a Brush Not in the Parameters.",
   "Diego",
   "Diego Nassetti ",
   "2018",
   "testBrushAsNoParm",
   "RGB*",
   [
     (PF_IMAGE, "image", "Input image", None),
     (PF_DRAWABLE, "drawable", "Input drawable", None),
######(PF_BRUSH, "brush", "Brush to use", None),       # removed from the parameters
     (PF_TOGGLE, "test", "Does it run more than once?", True), # fake parameter !
   ],
   [
     (PF_DRAWABLE, "odrawable", "Output drawable", None),
   ],
   testBrushAsNoParm,
   menu="<Image>/Test",
   )

main()



RE: GIMP 2.10 a brush in the filter parameters - Ofnuts - 05-06-2018

There is a gimp_context_push() but no gimp_context_pop()? (not sure if that fixes the problem, but that would be the first thing to check)

Edit: correction: there is no gimp_context_push(), there is just a gimp_context_push, which, by not including the call operator (aka ()) is just the method object but doesn't call anything. So no need for a balancing gimp_context_pop(), at best a gimp_context_pop for the same non-effectiveness Smile
--
Someone


RE: GIMP 2.10 a brush in the filter parameters - dinasset - 05-06-2018

Thanks Ofnuts.
Yes, a mistake (I have written these test filters in a hurry).
Corrected them.
Now the situation is:
- with the initial brush set to "None", the filter can be run repeatedly and not just only once as previously with the error you noticed.
- with the initial brush set to an existing one, still the filter shows up in the menu but does not show the parameters window when called (i.e.: does not start, it's uncallable).
INHO this means that 2.10 is unable to handle a brush initialized in a parameter.
This opinion is reinforced by the fact that the previous (erroneous) version of the filter with the parameter set to "None" did work properly only once, because in the absence of the ...context_pop() at the end, the filter was "remembered" by Gimp as having a predefined brush by default.
What do you think about?


RE: GIMP 2.10 a brush in the filter parameters - Ofnuts - 05-06-2018

Another problem with your code, the functions end with return(). This has no real meaning in Python, for which this is the keyword return followed by an empty tuple. So the method returns an empty tuple. But the registration promises that it returns a drawable [(PF_DRAWABLE, "odrawable", "Output drawable", None),].


RE: GIMP 2.10 a brush in the filter parameters - Ofnuts - 05-06-2018

: If you start Gimp 2.10 and run your code, you get:

Code:
Traceback (most recent call last):
 File "/app/lib/gimp/2.0/python/gimpfu.py", line 853, in _run
   res = _interact(proc_name, params[1:])
 File "/app/lib/gimp/2.0/python/gimpfu.py", line 774, in _interact
   wid = _edit_mapping[pf_type](def_val)
 File "/app/lib/gimp/2.0/python/gimpui.py", line 193, in __init__
   self.set_brush(default, -1.0, -1, -1)
AttributeError: 'BrushSelector' object has no attribute 'set_brush'

Filters>Reset all filters restores the default values to you can rerun your filter (and re-select a brush).

Otherwise, bona fide bug that you can report on bugzilla.gimp.org

The fixed code: [attachment=1692]


RE: GIMP 2.10 a brush in the filter parameters - dinasset - 05-07-2018

Ya, thanks, but the main problem (my problem, which caused this thread to be started) is:
- with a predefined brush indicated the filter does not show up (in 2.8 is shows up normally)
Likely a bug in 2.10, which hope will be fixed.
I just wanted to have a double-check, but I forgot you still work on 2.8 (safer...).
Thanks anyhow for your interest.


RE: GIMP 2.10 a brush in the filter parameters - Ofnuts - 05-07-2018

I did the tests above with 2.10 of course. But yes, your problem is that whatever value is active (not None), whether is comes form a previous run or from your default value, is fed to some object that preset the value in the dialog and in 2.10 that fails.

Time to report the bug if you want it fixed for some future version (I expect 2.10 to have a new version every month for some time, because there are certainly other bugs...)


RE: GIMP 2.10 a brush in the filter parameters - dinasset - 05-07-2018

Thanks.
Yes, also Lyle discovered one (see GC).
In spite of its long "gestation", 2.10 is a ... young baby.


RE: GIMP 2.10 a brush in the filter parameters - Ofnuts - 05-07-2018

Given that hisroty is likely to somehow repeat itself...

Code:
2.8.0-RC1 03-Apr-2012  
2.8.0     02-May-2012  
2.8.2     23-Aug-2012  
2.8.4     05-Feb-2013  
2.8.6     21-Jun-2013  
2.8.8     03-Nov-2013  
2.8.10    28-Nov-2013  
2.8.12    25-Aug-2014  
2.8.14    26-Aug-2014  
2.8.16    21-Nov-2015  
2.8.18    13-Jul-2016  
2.8.20    01-Feb-2017  
2.8.22    08-May-2017  



RE: GIMP 2.10 a brush in the filter parameters - dinasset - 05-07-2018

Long history, really.
Only hope it doesn't take another 5 years to switch to another major release...