首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Python3 ginput警告:使用默认事件循环

Python3 ginput警告:使用默认事件循环
EN

Stack Overflow用户
提问于 2013-11-15 14:48:18
回答 2查看 6.8K关注 0票数 4

当我实现代码的ginput部分时,就发出了警告。

代码语言:javascript
复制
def twoClicks(color_img):
    from pylab import ginput, rcParams, imshow, draw, title, axis, close
    rcParams['figure.figsize'] = 12, 8

    imshow(color_img, interpolation='nearest', aspect='equal')
    title("Click the image twice")
    axis('off')
    user_input = ginput(2)
    draw()
    close()
    print(user_input)

    return

执行上述代码将给我以下信息:

/usr/lib/python3.3/site-packages/matplotlib/backend_bases.py:2407: MatplotlibDeprecationWarning:使用默认事件循环,直到特定于该GUI的函数实现为warnings.warn(str,mplDeprecation)

我想知道我在做什么,那就是发出警告,以及如何以正确的方式来做这件事。

提前感谢!

我在linux中,matplotlib输出由默认接口(可能是GTK)处理。

EN

回答 2

Stack Overflow用户

发布于 2014-03-25 15:18:05

查看python教程中如何抑制警告,http://docs.python.org/2/library/warnings.html#temporarily-suppressing-warnings

代码语言:javascript
复制
import warnings

def fxn():
    warnings.warn("deprecated", DeprecationWarning)

with warnings.catch_warnings():
    warnings.simplefilter("ignore")
    fxn()
票数 2
EN

Stack Overflow用户

发布于 2017-04-17 09:26:26

具体而言,在这种情况下,请使用:

代码语言:javascript
复制
warnings.filterwarnings("ignore",".*GUI is implemented.*")

这适用于在警告中查找的模式,这意味着仍将报告其他警告。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/20003744

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档