简体   繁体   中英

Is it possible to use win32com in python script for GIMP

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM