GtkSource模块未在Python中导入

GtkSource模块未在Python中导入,python,gtk,gtksourceview,Python,Gtk,Gtksourceview,我尝试使用python和gtk构建源代码编辑器,运行脚本时出现以下错误: AttributeError:'gi.repository.Gtk'对象没有属性'Source' 下面是我的代码,我已经在自制软件上安装了所有的依赖项(我已经研究过),但我仍然无法导入Gtk.sourceview # UI # Imort modules import os,sys,pygtk from gi.repository import Gtk, Vte, GLib from gi.repository impor

我尝试使用python和gtk构建源代码编辑器,运行脚本时出现以下错误:

AttributeError:'gi.repository.Gtk'对象没有属性'Source'

下面是我的代码,我已经在自制软件上安装了所有的依赖项(我已经研究过),但我仍然无法导入Gtk.sourceview

# UI
# Imort modules
import os,sys,pygtk
from gi.repository import Gtk, Vte, GLib
from gi.repository import GObject
from gi.repository import GtkSource



class MainWindow(Gtk.Window):

    def __init__(self):
        Gtk.Window.__init__(self)
        # Window title and Icon
        self.set_title("MaeTrics")
        # Vertical Box
        self.box = Gtk.VBox(homogeneous=False, spacing=0)
        self.add(self.box)
        # Scrolled Text Window
        scrolledwindow1 = Gtk.ScrolledWindow()
        scrolledwindow1.set_hexpand(True)
        scrolledwindow1.set_vexpand(True)
        # Source View
        self.source = Gtk.Source.View()
        self.buffer = self.source.get_buffer()
        self.source.set_show_line_numbers(True)
        scrolledwindow1.add(self.source)
        # Pack everything in vertical box
        self.box.pack_start(scrolledwindow1, True, True, 0)
        # Callback functions
        self.connect("delete-event", Gtk.main_quit)
        self.show_all()



window = MainWindow()
Gtk.main()
应该是

self.source = GtkSource.View()

这对我来说在Debian上是有效的

那么它是什么呢?Gtk.Source.View或GtkSource.View?重新检查您的文档,这看起来不正确,错误也说明了这一点。