GIMP Chat http://gimpchat.com/ |
|
How to write python plugin preview? http://gimpchat.com/viewtopic.php?f=9&t=9586 |
Page 1 of 2 |
Author: | okyl168 [ Thu Jan 23, 2014 1:22 pm ] |
Post subject: | How to write python plugin preview? |
Hi, I wrote a simple plugin in to do some artistic transform (see attachement) and would like to change the parameter while looking at the effect applied on the image without leaving the dialog box. Any sample code that I can follow? Thanks. Attachment: capture-20140124-020535.jpg [ 257.67 KiB | Viewed 10762 times ] |
Author: | dinasset [ Thu Jan 23, 2014 1:54 pm ] | ||
Post subject: | Re: How to write python plugin preview? | ||
the attached python plug-in has a preview mechanism. how to imitate it, it's up to you (I don't understand the code!) good luck!
|
Author: | dd [ Thu Jan 23, 2014 2:49 pm ] |
Post subject: | Re: How to write python plugin preview? |
You could also take a look at my selection bevel plugin. It has a preview feature (although I don't even know if anyone uses it...) http://gimpscripts.com/2011/10/selection-bevel/ |
Author: | Ronounours [ Thu Jan 23, 2014 3:46 pm ] |
Post subject: | Re: How to write python plugin preview? |
Another solution (but it's not Python), would be to convert your effect into a G'MIC script, so we could add it to the G'MIC plug-in with a working preview flawlessly. Is it something you are interested in ? If so, I would be interested to convert your algorithm into a G'MIC script (if possible). |
Author: | ofnuts [ Thu Jan 23, 2014 3:54 pm ] |
Post subject: | Re: How to write python plugin preview? |
okyl168 wrote: Hi, I wrote a simple plugin in to do some artistic transform (see attachement) and would like to change the parameter while looking at the effect applied on the image without leaving the dialog box. Any sample code that I can follow? Thanks. Attachment: capture-20140124-020535.jpg It should only be a matter of hooking on the callback that tell you when when the user changes a setting to apply your script (with maybe a short delay). Then the OK button just becomes a "Quit", and the Cancel one does an "Undo". (by the way, the UI "canon" says that your yes/no button should really be a checkbox). |
Author: | dd [ Thu Jan 23, 2014 4:57 pm ] |
Post subject: | Re: How to write python plugin preview? |
Also, you can't use the gimppython helper library "gimpfu", which creates the UI for you - you have to write "closer to the metal" python and write all of your own UI code. And all you get is a button that does pretty much the same thing as the "ok" button except that the plugin window stays open and you can cancel the preview. It's not even a live preview, just a hackish way of doing a sort-of-preview. The problem is that since python plugins are really just external scripts that mostly leverage GIMP's existing procedures and functions to do their job, any accurate preview can only be achieved by running that same code as you'd run on executing the plugin - and thus takes the same amount of time, which kind of defeats the idea of a "preview". Although I guess you could do something like copying the current layer/image and scaling it to a smaller version and then running the plugin on that for preview, but I have to seriously question whether going through all that trouble is worth the payoff... |
Author: | okyl168 [ Fri Jan 24, 2014 6:18 am ] |
Post subject: | Re: How to write python plugin preview? |
dinasset/dd Thanks, the coding is a lot more complicated than I thought. Without the relevant documentation is hard to guess. The code is fast but take time to find the right color concentration, preview will save time jumping in and out of the dialog box. Ronounours, sure attached is the code. Attachment: ofnuts/canon, yes, I know, but I don't see any PF_CHECKBOX in the document. If you point me to the document, that would be great. |
Author: | ofnuts [ Fri Jan 24, 2014 7:25 am ] |
Post subject: | Re: How to write python plugin preview? |
okyl168 wrote: ofnuts/canon, yes, I know, but I don't see any PF_CHECKBOX in the document. If you point me to the document, that would be great. Sorry, I though the dialog was your own dialog, I didn't notice that this was the auto-generated Python-fu one. So I have it extend my remark above, if you want a preview, you have to make your own input dialog. There are rumors about a preview API for python in Gimp, but I have never seen it in action. |
Author: | Gino D [ Fri Jan 24, 2014 8:59 am ] |
Post subject: | Re: How to write python plugin preview? |
I think you might also find it useful to take a look at the "Layer Effects" plugin: http://registry.gimp.org/node/186 The dialog window of the version written in Python is provided with a preview widget represented by a checkbox that, when enabled/disabled, causes a preview of the specified effect to be shown/hidden in the form of a temporary layer added to the processed image. |
Author: | Ronounours [ Sat Jan 25, 2014 6:54 am ] |
Post subject: | Re: How to write python plugin preview? |
Hi. I've transcribed your python script into a G'MIC filter, you can already access it bu updating your filters. I've put this filter in Testing / Okyl168 / Attachment: gmic_jobs_colors.png [ 120.85 KiB | Viewed 10526 times ] For information, here is what I wrote for doing this (13 lines in total) : Code: Select all #@gimp Jobs colors : gimp_jobs_colors, gimp_jobs_colors_preview Let me know if this is what intended. |
Author: | okyl168 [ Sat Jan 25, 2014 10:13 am ] |
Post subject: | Re: How to write python plugin preview? |
Ronounours, Great! How do I download your version? I am new here, I tried the latest beta 1.5.8.3 from sourceforge, but doesn't have the entry under Testing. Oh I found it by pressing the refresh button. LOL Ronounours wrote: Hi.
I've transcribed your python script into a G'MIC filter, you can already access it by updating your filters. I've put this filter in Testing / Okyl168 / For information, here is what I wrote for doing this (13 lines in total) : Let me know if this is what intended. |
Author: | trandoductin [ Tue Nov 07, 2023 10:35 am ] |
Post subject: | Re: How to write python plugin preview? |
While I was looking for a way to do live-preview, this topic came up. And I wanted to try out my own (of course it has to gtk) which is kind'a ok I guess (wish there was a way to do with PF_variables but doesn't look like you can connect to PF_variables. So this example is gtk (I have always been afraid of poking around in gtk) but this time I used help from ChatGPT and I tried to comment as much as I can so if I read it later I'll know what needs changing/fiddling. At first I was going to try calling gegl c2g but the python_fu wrapper to gegl c2g is too slow to call using this preview so I just changed it to ellipse select and invert just to show me that this works on the fly. (see demo video below). Code: Select all #!/usr/bin/env python |
Author: | trandoductin [ Tue Nov 07, 2023 10:39 am ] |
Post subject: | Re: How to write python plugin preview? |
this was my first ever preview try I think and it's great for something simple or fast. working with gtk is well unknown territory to me. Don't think i would be able to do it without asking chatGPT a bunch of questions |
Author: | MareroQ [ Tue Nov 07, 2023 3:15 pm ] | ||
Post subject: | Re: How to write python plugin preview? | ||
For me it's a total revolution (although it seems that the samples & iteration parameters are not active)
|
Author: | trandoductin [ Tue Nov 07, 2023 4:43 pm ] |
Post subject: | Re: How to write python plugin preview? |
yeah I didn't use the samples and iterations which were initially for gegl g2c I was making it but it seemed super slow so I just decided to play with selection and invert and only the first parameter This one is much cooler and more useful I think viewtopic.php?f=9&t=20616 Not trying to start revolution, just poking around. |
Author: | MareroQ [ Sat Nov 25, 2023 1:26 am ] | |||
Post subject: | Re: How to write python plugin preview? | |||
I'm very surprised by the lack of interest in this great feature - now you can preview plugins directly. My first attempt of course with G'mic (I know it has its preview, but not on canvas...) Tin: Do you know how to change the slider type?
|
Author: | dinasset [ Sat Nov 25, 2023 2:01 am ] |
Post subject: | Re: How to write python plugin preview? |
@TT (and @MrQ) if in your try the "function" whose effect has to be "pre-viewed" is too slow, why not to apply the G'MIC technique which scales down the image before showing the preview? Sometimes renders the preview inusable, but... |
Author: | trandoductin [ Sat Nov 25, 2023 9:37 am ] |
Post subject: | Re: How to write python plugin preview? |
MareroQ wrote: I'm very surprised by the lack of interest in this great feature - now you can preview plugins directly. My first attempt of course with G'mic (I know it has its preview, but not on canvas...) Tin: Do you know how to change the slider type? I do not but if I needed any other type I just paste in my code into chatGPT and ask it to give me or add a gtk 2 integer type for example and it would give me something that I can partially copy and play with. I just haven't had the need to learn more. But here's some code I got from chatGPT for integer/float entry and color picker Code: Select all #!/usr/bin/env python |
Author: | MareroQ [ Sun Nov 26, 2023 12:32 am ] |
Post subject: | Re: How to write python plugin preview? |
@Diego Why don't you try to do it? Knowing nothing about gtk2, I adapted the Tin code to the new plugin (Gmic) in 15 minutes (without any understanding of how it works). I don't intend to learn gtk from scratch now (lack of time), but I will look for solutions in other plugins. @Tin. Thank you for sharing the code. I'm trying to learn how to use the color picker in Gmic. I will still want to find equivalents for PF_OPTION and PF_TOGGLE (this is a long way for me - unless someone knows and shares how to use it). |
Author: | trandoductin [ Sun Nov 26, 2023 10:06 am ] |
Post subject: | Re: How to write python plugin preview? |
here's some coded added to existing previous example that I pulled out from ChatGPT for a YES/NO button (so toggle) and a combo choice selection (so options) I do not fully understand it but I can work with what it gave me. Code: Select all #!/usr/bin/env python |
Page 1 of 2 | All times are UTC - 5 hours [ DST ] |
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group http://www.phpbb.com/ |