简体   繁体   English

是否可以在GIMP的python脚本中使用win32com

[英]Is it possible to use win32com in python script for GIMP

I try to use win32com in GIMP python script. 我尝试在GIMP python脚本中使用win32com。 Script should appear under tab: /Grzegorz. 脚本应显示在选项卡:/ Grzegorz下。 I noticed that "IMPORT FROM EXCEL..." shortcut appears on tab only when I delete import declaration "import win32com.client as win32". 我注意到只有当我删除导入声明“将win32com.client作为win32导入”时,选项卡上才会出现“从EXCEL导入...”快捷方式。 So I assume win32com causes problem. 所以我认为win32com会引起问题。

Win32com works when I try it outside gimp as a python file so win32com is ok. 当我在gimp以外以python文件形式尝试Win32com时,它可以正常工作。

#!/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? 有谁知道在gimp脚本中使用win32com的可能性吗?

pypiwin32Yes, but you would have to add the win32com module to the python runtime used by Gimp. pypiwin32是的,但是您必须将win32com模块添加到Gimp使用的python运行时中。

Some indications to install things here (this is for numpy , but holds for anything installed with PIP). 一些指示可以在此处安装东西(这适用于numpy ,但适用于随PIP安装的任何东西)。

This post hints that you should install pypiwin32 with PIP. 这篇文章暗示您应该使用PIP安装pypiwin32

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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