我正在使用基本操作系统,我想使用 python 3 制作自己的通知。我知道这样做的一个简单方法是通过import subprocess
. 然而,在网上阅读我发现这不是最合适的方式。相反,我应该使用from gi.repository import Notify
,但我收到此错误
__main__:1: PyGIWarning: Notify was imported without specifying a version first. Use gi.require_version('Notify', '0.7') before import to ensure that the right version gets loaded.
我一直在尝试解决这个问题,并且使用以下代码似乎有效。
import gi
gi.require_version("Notify", "0.7")
from gi.repository import Notify
有人可以解释为什么首先会产生这个错误以及为什么这是解决它的方法(如果它是正确的方法)?先感谢您。
PS。我在 www.elementaryos.stackexchange.com 上问过,但没有得到任何答案。也许他们对此并不熟悉。