Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Updating Python Scripts to Gimp 3
#2
When you write:
Code:
xcfFile = file.xcf.load("E:/TemporaryD/AIWorld/Design/TShirts/2304.xcf")

Then either
  • file is a variable that references an object that has an xcf method or attribute, or in this case, and xcf attribute which is a reference to an object with a load method.
  • file is a module (so you did import file at some point), woth an xcf variable which is a reference to an object with a load method.
Looking at your code, neither is true. Furthermore, the value returned is an image  (a Gimp.Image object) and not a file as implied by the name of the xcfFile variable (*)

In practice, you have to import at least a gimp module, which is done like this:
Code:
gi.require_version('Gimp', '3.0')
from gi.repository import Gimp

and then you can at some point in your code (but not right away because there are many things that should be done before to make Gimp consider using your code) issue a
Code:
image=Gimp.file_load(
   Gimp.RunMode.NONINTERACTIVE,
   Gio.file_new_for_path("E:/TemporaryD/AIWorld/Design/TShirts/2304.xcf")
)

as documented here.

However, the mere idea that you are asking this question in these terms hints that you have very little knowledge of Python (and probably of programming as well) so your chances to end up with a working plugin are minimal if you go straight for this.

Better take some time and learn the basics of programming and Python outside of Gimp. The hard part is not writing the code, it is debugging it, and Gimp isn't a very friendly environment for this.


(*) "To name things wrongly is to add to the misfortune of the world". Albert Camus
Reply


Messages In This Thread
RE: Updating Python Scripts to Gimp 3 - by Ofnuts - Yesterday, 08:58 PM

Forum Jump: