Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Divide selection using guides
#7
(04-15-2023, 04:02 AM)PixLab Wrote: I did tried today, nice and indeed it will be useful.

Two things though, would it be possible to change the PF_INT to something like PF_SPINNER ?

I took the freedom to slightly add 2 code lines to be able to do a Ctrl+Z at once and not have to do it multiple time (I'm no programmer, I hope it's ok)


Well I'm also new to this, but yes, from what I read PF_SPINNER requires additional argument.

it's a tuple in the form of (min, max, step). So if you change these two lines:
Code:
(PF_INT, "x_div", "horizontal divisions", 10),
(PF_INT, "y_div", "vertical divisions", 10)


with these:
Code:
(PF_SPINNER, "x_div", "horizontal divisions", 3, (1,10,1)),
(PF_SPINNER, "y_div", "vertical divisions", 3, (1,10,1))

You'll get a spinner that goes from 1 to 10 with the default value
of 3. If you need more, you can easily change number 10 in both lines.

But after testing it I realized it sends a float instead of an int,
so it messed up the range in the loop which requires int.

So you'll also have to cast the values, you can just put these two lines
in the beginning of the function (def line is the same as it was):

Code:
def divide_selection_using_guides(img, x_div, y_div):
   
   x_div = int(x_div)
   y_div = int(y_div)

That should be it.
Reply


Messages In This Thread
Divide selection using guides - by goran - 04-14-2023, 09:33 AM
RE: Divide selection using guides - by PixLab - 04-14-2023, 02:11 PM
RE: Divide selection using guides - by goran - 04-14-2023, 04:20 PM
RE: Divide selection using guides - by Ofnuts - 04-14-2023, 04:46 PM
RE: Divide selection using guides - by PixLab - 04-15-2023, 04:02 AM
RE: Divide selection using guides - by goran - 04-15-2023, 11:01 AM
RE: Divide selection using guides - by PixLab - 04-16-2023, 04:05 AM
RE: Divide selection using guides - by denzjos - 04-15-2023, 07:50 AM
RE: Divide selection using guides - by goran - 04-15-2023, 05:55 PM
RE: Divide selection using guides - by denzjos - 04-18-2023, 07:01 AM
RE: Divide selection using guides - by teapot - 04-15-2023, 11:14 PM
RE: Divide selection using guides - by goran - 04-16-2023, 06:16 AM
RE: Divide selection using guides - by Krikor - 04-18-2023, 06:09 PM
RE: Divide selection using guides - by goran - 04-18-2023, 06:53 PM
RE: Divide selection using guides - by Krikor - 04-18-2023, 07:02 PM
RE: Divide selection using guides - by goran - 04-19-2023, 06:26 AM
RE: Divide selection using guides - by PixLab - 04-19-2023, 01:41 PM
RE: Divide selection using guides - by denzjos - 04-19-2023, 08:39 AM
RE: Divide selection using guides - by goran - 04-19-2023, 11:36 AM
RE: Divide selection using guides - by Krikor - 04-19-2023, 06:18 PM

Forum Jump: