在 Python 3 中使用 GIO

在 Python 3 中使用 GIO

我如何访问gio有没有 Python 3.2 的模块?(我想与 GVFS 交互。)我做到了

sudo apt-get install python3-gobject

但这不允许我这样做

import gio

就像在 Python 2.7 中一样。Python 3 中 GIO 模块没有随 GObject 一起提供吗?我该如何访问它?

答案1

gio是 PyGTK 模块,不适用于 Python 3,因为 PyGTK 本身已弃用。如果您想在 Python 3 中创建 GTK+ 应用程序,则需要使用它的替代品:对象。对于 Gio,您可以像这样导入它。

$ python3
Python 3.2.2 (default, Sep  5 2011, 21:17:14) 
[GCC 4.6.1] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from gi.repository import Gio

可以找到现有的此类文献这里。祝你好运!

答案2

它似乎被重命名为‘gi’:

$ python3
Python 3.2.2 (default, Sep  5 2011, 22:09:30)
[GCC 4.6.1] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import gi
>>>

查看python3-gobject包的文件清单:http://packages.ubuntu.com/oneiric/i386/python3-gobject/filelist

相关内容