我正在学习PyGtk中的Spinners。我执行了这个程序:
#!/usr/bin/env python
import gtk
class Spinner:
def __init__(self):
window=gtk.Window()
window.set_default_size(200,200)
vbox = gtk.VBox(False, 5)
hbox = gtk.HBox(True, 5)
self.spinner = gtk.Spinner()
self.spinner.set_property("num-steps", 10)
button_start = gtk.Button("Start")
button_stop = gtk.Button("Stop")
window.connect("destroy", lambda q : gtk.main_quit())
button_start.connect("clicked", self.start_animation)
button_stop.connect("clicked", self.stop_animation)
window.add(vbox)
vbox.pack_start(self.spinner,True,True,0)
vbox.pack_end(hbox, False, False, 0)
hbox.pack_start(button_start)
hbox.pack_start(button_stop)
window.show_all()
def start_animation(self, widget):
self.spinner.start()
def stop_animation(self, widget):
self.spinner.stop()
Spinner()
gtk.main()
Shell抛出以下错误:
Traceback (most recent call last):
File "spinner.py", line 37, in <module>
Spinner()
File "spinner.py", line 14, in __init__
self.spinner.set_property("num-steps", 10)
TypeError: object of type `GtkSpinner' does not have property `num-steps'
在Spinner的cycle-duration
属性的情况下,它会抛出类似的错误。我哪里错了?