Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Palette as input Script/Plug-in noob question
In a .py file I have this register call

    'Exports Palette to HTML table',
    'Exports Palette to HTML table',
    'Tin Tran',
    'Tin Tran',
    'July 2018',
    'HTML table...',
    (PF_DIRNAME, "folder", "Foler for the output file:", 0),
    (PF_STRING, "name", "The name of the file to create:", "palette.html"),
    (PF_SPINNER, "per_row", "Colors per row:", 16, (1, 500, 1)),
    menu='<Palettes>/Export as',

It's in the right menu, but it's only prompting for 2 inputs (the name and the per_row) and passing 3 parameters to my function which i am expecting 4.
I want it to prompt for all 3 and passing the palette in as first parameter so that my function has 4 parameters.
How to do this so that it passes palette (that is selected) and the other 3 prompted?

Okay I think I figured it out.
I just had to declare another PF_STRING for palette before the other PF'ses and it does't prompt it just passes it in. So that works for me
No, you didn't: )

You should be using PF_PALETTE instead of PF_STRING. Of course you script only gets a string, but you get a real palette selector in the auto-built dialog.

Also, as a rule, there should be exactly as many args in your python function as you declared PF_* args in the registration list (unless you function takes default parms of course).
I really did that ..heeh
Thanks I'll change it to PF_PALETTE which makes more sense.
What I don't undertstand is that it acts like a default param, like I can't select Palette at prompt (which is what i want because the palette is already active), like passing in Image and Layer but it's different because for Image and Layer I never had to define PF_*
Where it makes sense Gimp auto-fills the first arguments. For instance, for a regular script called form an image display, if the first two args are a PF_IMAGE and a PF_DRAWABLE, they are set to the current image/layer and the dialog doesn't show input fields for them. Likewise, scripts that takes PF_IMAGE and PF_VECTORS as first args get that pre-filled if called from the Paths list. So I'm not surprised that if you call something from the Palettes list, a leading PF_PALETTE arg is pre-filled with the current palette.
If the first PF_* is PF_ OPTION and I use <Palette> it doens't do auto prefill... so it tries to be smart... I just didn't expect it to be so smart I guess.

Forum Jump: