'无法检索有效(未标记)类型的课程' void''在Pygobject?

时间:2014-10-08 02:36:19

标签: python gtk pygobject

我在Windows上安装了Pygobject,当我尝试运行此代码时:

#!/usr/bin/python
from gi.repository import Gtk

class StackWindow(Gtk.Window):

    def __init__(self):
        Gtk.Window.__init__(self, title="Stack Demo")
        self.set_border_width(10)

        vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=6)
        self.add(vbox)

        stack = Gtk.Stack()
        stack.set_transition_type(Gtk.StackTransitionType.SLIDE_LEFT_RIGHT)
        stack.set_transition_duration(1000)

        checkbutton = Gtk.CheckButton("Click me!")
        stack.add_titled(checkbutton, "check", "Check Button")

        label = Gtk.Label()
        label.set_markup("<big>A fancy label</big>")
        stack.add_titled(label, "label", "A label")

        stack_switcher = Gtk.StackSwitcher()
        stack_switcher.set_stack(stack)
        vbox.pack_start(stack_switcher, True, True, 0)
        vbox.pack_start(stack, True, True, 0)

win = StackWindow()
win.connect("delete-event", Gtk.main_quit)
win.show_all()
Gtk.main()

我收到错误消息:

Warning (from warnings module):
  File "F:\ASM_Archive\gui01.py", line 13
    stack = Gtk.Stack()
Warning: cannot retrieve class for invalid (unclassed) type 'void'
Traceback (most recent call last):
  File "F:\ASM_Archive\gui01.py", line 29, in <module>
    win = StackWindow()
  File "F:\ASM_Archive\gui01.py", line 13, in __init__
    stack = Gtk.Stack()
TypeError: could not get a reference to type class

这是否意味着我安装了错误或错过了什么? 我可以创建窗口,添加按钮等,但当我尝试添加更多类似于&#39; Gtk.Stack()&#39;或者&#39; Gtk.ListBox()&#39;我有错误。

0 个答案:

没有答案