TypeError :object of type 'GtkSpinner' does not have property 'num-steps'

巧了我就是萌 提交于 2020-01-16 19:27:27

问题


I am learning about Spinners in PyGtk. I executed this program :

#!/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 threw the following error:

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'

It throws a similar error in the case of cycle-duration property of Spinner. Where am I going wrong?

来源:https://stackoverflow.com/questions/21807917/typeerror-object-of-type-gtkspinner-does-not-have-property-num-steps

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!