PyGobject(七十六)Gtk.Widget之Gtk.Spinner

Gtk.Spinner

Gtk.Spinner環形加載進度條。

這裏寫圖片描述

Methods

方法修飾詞 方法名及參數
static new ()
start ()
stop ()

Virtual Methods

Properties

Name Type Flags Short Description
active bool r/w/en Whether the spinner is active

Signals

Name Short Description

例子

這裏寫圖片描述
代碼:

#!/usr/bin/env python3
# Created by xiaosanyu at 16/6/15
# section 120
TITLE = "Spinner"
DESCRIPTION = """
A Gtk.Spinner widget displays an icon-size spinning animation.
It is often used as an alternative to a Gtk.ProgressBar for displaying
indefinite activity, instead of actual progress.
"""
import gi

gi.require_version('Gtk', '3.0')
from gi.repository import Gtk


class SpinnerAnimation(Gtk.Window):
    def __init__(self):

        Gtk.Window.__init__(self, title="Spinner")
        self.set_border_width(3)
        self.connect("delete-event", Gtk.main_quit)

        self.button = Gtk.ToggleButton("Start Spinning")
        self.button.connect("toggled", self.on_button_toggled)
        self.button.set_active(False)

        self.spinner = Gtk.Spinner()
        self.table = Gtk.Table(3, 2, True)
        self.table.attach(self.button, 0, 2, 0, 1)
        self.table.attach(self.spinner, 0, 2, 2, 3)

        self.add(self.table)
        self.show_all()

    def on_button_toggled(self, button):

        if button.get_active():
            self.spinner.start()
            self.button.set_label("Stop Spinning")

        else:
            self.spinner.stop()
            self.button.set_label("Start Spinning")


def main():
    myspinner = SpinnerAnimation()
    Gtk.main()


if __name__ == "__main__":
    main()





代碼下載地址:http://download.csdn.net/detail/a87b01c14/9594728

發佈了166 篇原創文章 · 獲贊 24 · 訪問量 48萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章