3

I have opened an xcf file "BY HAND" in Gimp.

How can i close this file (that is also the current view/display) without beeing asked if i want to save it.

I need the register function to give me the "current Display" something like PF_Display ... (like image and drawable)

Then i would go and use:

pdb.gimp_display_delete(display)

How can i get the SAME result as pressing "CTRL + W" or pressing on the "x" button?

So far nothing worked for me:

1: gimp.pdb.gimp_image_delete(image)

2: display = pdb.gimp_display_new(image)
   pdb.gimp_display_delete(display)

3: use of image.clean_all() in combination with 1: and 2:

This is so basic, i googled alot already, nothing helped me, i fail...

Andre Elrico
  • 10,956
  • 6
  • 50
  • 69

1 Answers1

2

In theory, you can't, because by design the Scheme or Python APIs are prevented from interfering with the UI. This said, I have a script that does this:

    # delete image display and image
    for displayID in range(1,image.ID+50):
        display=gimp._id2display(displayID)
        if isinstance(display,gimp.Display):
            #print 'Image: %d; display %d' % (image.ID,displayID)
            break
    if not display:
        raise Exception('Display not found')            
    gimp.delete(display)

Basically it tries to create a Display using a bunch of ids, and Gimp returns a gimp.Display only if the id matches a gimp.Display. The way the script that uses the code above works, there is only one image active in Gimp at a time. With several images it becomes risky because you cannot check which display goes with which image. However it appears that very often, the id of the display is the id that precedes the image one, so you could just do:

display=gimp._id2display(image.ID-1)
gimp.delete(display)

But, no warranty, and of course I don't know you, we have never met, and StackOverflow doesn't exist...

xenoid
  • 8,396
  • 3
  • 23
  • 49