Python3 ginput 警告 : Using default event loop

标签 python matplotlib

当我实现代码的 ginput 部分时出现警告。

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: Using default event loop until function specific to this GUI is implemented warnings.warn(str, mplDeprecation)

我想知道我正在做什么来生成警告,以及如何以正确的方式执行此操作。

提前致谢!

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

最佳答案

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

import warnings

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

with warnings.catch_warnings():
    warnings.simplefilter("ignore")
    fxn()

关于Python3 ginput 警告 : Using default event loop,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20003744/

相关文章:

python - 使用过滤器检索图形最低高度节点

python - 基于子数组的第二个元素对多维数组进行排序

python - 使用 fromfunction 和数组填充 numpy 矩阵

python - "substring not found"即使它包含在命令行上传递的参数中

python - Pandas 将数据框绘制为多个条形图

python - 如何通过 Selenium 和 Python 验证元素是否存在并调用 send_keys 方法

python - 导入pylab时matplotlib "DLL load failed"

python - numpy 数组梯度和 matplotlib quiver 的倒序

python - 时间戳传递给 matplotlib.date2num : 'str' object has no attribute 'toordinal'

python - matplotlib.mlab 和 numpy.abs(numpy.fft.fft(data)) 中可用的模量谱结果之间的差异