python脚本中输出信息到控制台

python脚本中输出信息到控制台

本文介绍了如何在Gimp python脚本中输出信息到控制台?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚开始学习使用Python的Gimp脚本,并且想知道,如何将文本输出到控制台?
我在Windows 7上使用版本2.7.5。

I've just started learning about Gimp scripting using Python, and was wondering, how do I output text to the console?I am using version 2.7.5 on Windows 7.

我尝试了打印功能,但它不会写任何东西到python-fu控制台或开发控制台与Gimp。
是否有一个函数我应该使用这样做?或者这是2.7.5版本的问题?
我发现几个提到的gimp-message,但似乎是一个用于Scheme(Script-fu)的函数

I tried the print function, but it does not write anything to the python-fu console or the dev console that launches with Gimp.Is there a function I should use to do this? or is this a problem with the 2.7.5 release?I found a few mentions of "gimp-message" but that seems to be a function used with Scheme (Script-fu)

谢谢!

(也张贴为主题)

推荐答案

pdb.gimp_message('This is displayed as a message')

但是...如果控制台窗口已启动,则显示在错误控制台中,否则在带有确定按钮的消息对话框中等待用户确认。所以你可以在脚本中真正使用它一次或两次...

However... this shows in the Error console if the console window is up, else in a message dialog with an OK button, waiting for user acknowledgment. So you can really use it only once or twice in the script...

还有

pdb.gimp_progress_set_text('This goes to the status bar')

这将进入状态栏(IIRC)和插件进度对话框(如果有),但是是暂时的。

That goes to the status bar (IIRC) and to the plugin progress dialog, if any, but is rather temporary.

您还可以使用纯打印语句进行调试。在Linux上,它们的输出显示在您从其启动Gimp的终端中,并且在Windows上,如果您以Gimp的方式启动Gimp,它们可能会显示在gimp-console中(因此一般用户不会看到任何东西,除非您真正告诉他们在哪里查看) 。

You can also use plain print statements for debug purposes. On Linux their output shows up in the terminal from which you started Gimp, and on Windows they may appear in gimp-console if you started Gimp that way (so the general user won't see anything unless you really tell them where to look).

这篇关于如何在Gimp python脚本中输出信息到控制台?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-23 19:47