RSS/Atom feed Twitter
Site is read-only, email is disabled

Custom Script UI

This discussion is connected to the gimp-user-list.gnome.org mailing list which is provided by the GIMP developers and not related to gimpusers.com.

This is a read-only list on gimpusers.com so this discussion thread is read-only, too.

10 of 10 messages available
Toggle history

Please log in to manage your subscriptions.

Custom Script UI FierySwordswoman 12 Oct 22:14
  Custom Script UI Ofnuts 13 Oct 07:15
   Custom Script UI FierySwordswoman 13 Oct 18:13
    Custom Script UI Kevin Payne 13 Oct 21:30
     Custom Script UI FierySwordswoman 13 Oct 22:25
     Custom Script UI FierySwordswoman 14 Oct 00:35
      Custom Script UI FierySwordswoman 14 Oct 01:47
    Custom Script UI Ofnuts 13 Oct 22:31
     Custom Script UI FierySwordswoman 13 Oct 22:52
      Custom Script UI Ofnuts 14 Oct 21:53
FierySwordswoman
2016-10-12 22:14:01 UTC (about 8 years ago)

Custom Script UI

I've been learning Python as a hobby for a while and can now write my own user interfaces in TkInter or the 3rd party Kivy.

I'm trying to launch my own UI that can run Procedural Database plugins and whatnot, but I can't figure out how to create a GIMP python plugin without using the "Register(...)" command and it's built-in widgets. Any help on how to get started with this is appreciated.

Ofnuts
2016-10-13 07:15:05 UTC (about 8 years ago)

Custom Script UI

On 13/10/16 00:14, FierySwordswoman wrote:

I've been learning Python as a hobby for a while and can now write my own user interfaces in TkInter or the 3rd party Kivy.

I'm trying to launch my own UI that can run Procedural Database plugins and whatnot, but I can't figure out how to create a GIMP python plugin without using the "Register(...)" command and it's built-in widgets. Any help on how to get started with this is appreciated.

You have to use register(), but you can have an empty parameter list. Then your plugin is called directly without the Gimp-built dialog.

FierySwordswoman
2016-10-13 18:13:41 UTC (about 8 years ago)

Custom Script UI

You have to use register(), but you can have an empty parameter list. Then your plugin is called directly without the Gimp-built dialog.

What, you mean with no "PF-XXX" parameters? Yeah, I got that much as I've made scripts with both no UI and the built-in UI before. I'm rather certain it still wants you to use their UI, though.

Even if that's all it took, there's still the issue of gimp using a watered down Python 2.7.5, which I'm not sure how to add normal modules to. I assume Kivy's pretty much out of the question, but TkInter's normally built in to python, except with gimp a number of base modules, including TkInter, aren't present anymore. I already have python 3.4 and 2.7 installations on my pc, but it's unlikely they can be made relevant here.

Kevin Payne
2016-10-13 21:30:50 UTC (about 8 years ago)

Custom Script UI

What, you mean with no "PF-XXX" parameters? Yeah, I got that much as I've made scripts with both no UI and the built-in UI before. I'm rather certain it still wants you to use their UI, though.

Even if that's all it took, there's still the issue of gimp using a watered down Python 2.7.5, which I'm not sure how to add normal modules to. I assume Kivy's pretty much out of the question, but TkInter's normally built in to python, except with gimp a number of base modules, including TkInter, aren't present

.anymore.

As you say TkInter isn't in the GIMP supplied Python (which is a pity as it uses native file browsers instead of the GTK abomination), but you can use PyGTK, which you should be able to understand quite readily as you have TkInter experience.

Here's a relatively simple PyGTK GIMP plug-in I wrote some time ago: https://bitbucket.org/paynekj/paynekj-gimp-scripts/src/2e8e87faf5eaaf6036e0d8b68ff9f6f37a3f0421/plug-ins/pygtk_add_multiple_guides.py?at=default

Kevin

FierySwordswoman
2016-10-13 22:25:18 UTC (about 8 years ago)

Custom Script UI


As you say TkInter isn't in the GIMP supplied Python (which is a pity as it uses native file browsers instead of the GTK abomination), but you can use PyGTK, which you should be able to understand quite readily as you have TkInter experience.

Here's a relatively simple PyGTK GIMP plug-in I wrote some time ago: https://bitbucket.org/paynekj/paynekj-gimp-scripts/src/2e8e87faf5eaaf6036e0d8b68ff9f6f37a3f0421/plug-ins/pygtk_add_multiple_guides.py?at=default

Kevin

Ah, thanks. It does indeed remind me of TkInter. I should be able to reverse-engineer your example code to do some useful stuff.

-Ideally, I use the os module for most of my file-browser-esque operations. Once I learn how to make more complex Kivy widgets, my current and future programs that use file explorers will likely use a hand-made solution instead of Kivy's default widget. When I made my first program (Used TkInter), making my own file explorer turned out pretty nicely.

Ofnuts
2016-10-13 22:31:59 UTC (about 8 years ago)

Custom Script UI

On 13/10/16 20:13, FierySwordswoman wrote:

You have to use register(), but you can have an empty parameter list. Then your plugin is called directly without the Gimp-built dialog.

What, you mean with no "PF-XXX" parameters? Yeah, I got that much as I've made scripts with both no UI and the built-in UI before. I'm rather certain it still wants you to use their UI, though.

Something like this:

register( 'new-image',
'Creates a new image','Creates a new image', 'Myself','Myself',
'2012',
'Create new image',
'',[],[],
newImage,
menu='/File/Create/'
)

This script will run without showing up a dialog, and will even run if no images are open in Gimp.

Even if that's all it took, there's still the issue of gimp using a watered down Python 2.7.5, which I'm not sure how to add normal modules to.

Pip could work...

I assume Kivy's
pretty much out of the question, but TkInter's normally built in to python, except with gimp a number of base modules, including TkInter, aren't present anymore.

As Kevin says, PyGTK is a good option.

I already have python 3.4 and 2.7 installations on my pc, but it's unlikely they can be made relevant here.

Don' t speak to fast, and check the /lib/gimp/2.0/interpreters/pygimp.interp file in the Gimp install tree. You can very likely switch to your own 2.7.x. Of course, you'll end up writing scripts that only you can use :)

FierySwordswoman
2016-10-13 22:52:47 UTC (about 8 years ago)

Custom Script UI

Something like this:

register( 'new-image',
'Creates a new image','Creates a new image', 'Myself','Myself',
'2012',
'Create new image',
'',[],[],
newImage,
menu='/File/Create/'
)
This script will run without showing up a dialog, and will even run if no images are open in Gimp.

Yeah.

Pip could work...

No it won't. It's not included in Python 2.7.5, and I can't install it into GIMP's python because it's missing too much of the standard library.

Don' t speak to fast, and check the /lib/gimp/2.0/interpreters/pygimp.interp file in the Gimp install tree.
You can very likely switch to your own 2.7.x. Of course, you'll end up writing scripts that only you can use :)

How can words on a screen be spoken too fast? Did you read them too fast? -Anyway, no, I can't switch over to my own 2.7.X as the file can't be modified. The proper way to do that would be to replace GIMP's python.exe and pythonw.exe with links to the desired ones. Even if it's possible, I'm pretty sure it'd lose the all-important gimpfu module.

FierySwordswoman
2016-10-14 00:35:50 UTC (about 8 years ago)

Custom Script UI

Kevin, in you're code you have no image or drawable picked using the PF_XXX parameters, but they still show up in your code when the starting function is run. How? In this code:

##### def start(*args):
pdb.gimp_message(args)

register( "FSW-SCRIPT",
"desc.",
"desc2.",
"FierySwordswoman",
"FierySwordswoman",
"1989",
"FSW Script",
"*",
[],
[],
start,
menu="/"
)

main()
#####

it prints the message '()', meaning I'm not receiving the image and drawable arguments for the function...why? The closest thing I could find in the python-fu documentation was "gimp.images_list()", which isn't a good solution.

FierySwordswoman
2016-10-14 01:47:15 UTC (about 8 years ago)

Custom Script UI

EDIT:

Adding the PF_IMAGE and PF_LAYER parameters fixes that without impeding the GUI creation.

Alright, I'm set. I even managed to import GIMP's menu themes to use on my custom UI.

Ofnuts
2016-10-14 21:53:36 UTC (about 8 years ago)

Custom Script UI

On 14/10/16 00:52, FierySwordswoman wrote:

Something like this:

register( 'new-image',
'Creates a new image','Creates a new image', 'Myself','Myself',
'2012',
'Create new image',
'',[],[],
newImage,
menu='/File/Create/'
)
This script will run without showing up a dialog, and will even run if no images are open in Gimp.

Yeah.

Pip could work...

No it won't. It's not included in Python 2.7.5, and I can't install it into GIMP's python because it's missing too much of the standard library.

Pip is only making things easy. You can always manually add stuff.

How can words on a screen be spoken too fast? Did you read them too fast? -Anyway, no, I can't switch over to my own 2.7.X as the file can't be modified.

It is burnt in the hard disk? All files can be changed. I remember doing this a long while ago when I was still using Windows.

The proper way to do that would be to replace GIMP's python.exe and pythonw.exe with links to the desired ones.
Even if it's possible, I'm pretty sure it'd lose the all-important gimpfu module.

No it wouldn't but I don"t remember if I had to do something for this.

This said AFAIK the Gimp python includes modules such as xml.eTree, so I wonder what modules you consider missing from the standard Python 2.7 install (as listed here: https://docs.python.org/2/py-modindex.html)