I try to use win32com in GIMP python script. Script should appear under tab: /Grzegorz. I noticed that "IMPORT FROM EXCEL..." shortcut appears on tab only when I delete import declaration "import win32com.client as win32". So I assume win32com causes problem.
Win32com works when I try it outside gimp as a python file so win32com is ok.
#!/usr/bin/env python
from gimpfu import *
import win32com.client as win32
def import_text_my(img):
Excel = win32.gencache.EnsureDispatch("Excel.Application")
Excel.Visible = True
title = Excel.ActiveSheet.Cells(Excel.Selection.Row, 1).Value
description = Excel.ActiveSheet.Cells(Excel.Selection.Row, 1).Value
param = pdb.gimp_image_get_active_layer(img)
ret = param.Split(" ")
if len(ret) == 1:
ret = [title, title, 'textZwyklyLeft']
output = param.replace(ret[1], title)
layerMy = img.active_layer
layerMy.Name = output
pdb.gimp_text_layer_set_text(layerMy, description)
register(
"python_import_excel",
"IMPORT FROM EXCEL",
"import_text",
"Grzegorz Mackiewicz",
"Grzegorz Mackiewicz",
"2019",
"IMPORT FROM EXCEL...",
"",
[
(PF_IMAGE, "img", "Input image", None)
],
[],
import_text_my, menu="<Image>/Grzegorz")
main()
Does anyone know if there is possiblility to use win32com in gimp script?
pypiwin32Yes, but you would have to add the win32com module to the python runtime used by Gimp.
Some indications to install things here (this is for numpy
, but holds for anything installed with PIP).
This post hints that you should install pypiwin32
with PIP.