Python GTK 3 GUI 編程 -- 007 Expander

這篇文章講下Expander (其實(shí)沒(méi)什么講的)

什么是expander

Expander 1
Expander 2

創(chuàng)建

self.expander = Gtk.Expander()

使用

直接調(diào)用add(child) 就可以

上面示例的原始碼

import gi
gi.require_version("Gtk", "3.0")

from gi.repository import Gtk


class MyWindow(Gtk.Window):
    def __init__(self):
        super(MyWindow, self).__init__(title="Stack And Stack Switch")

        self.expander = Gtk.Expander(label="Expander")
        self.label = Gtk.Label(label="Label")
        self.expander.add(self.label)
        self.add(self.expander)


win = MyWindow()
win.connect("destroy", Gtk.main_quit)
win.show_all()
Gtk.main()

基本屬性

  • label expander的標(biāo)簽
  • expanded 默認(rèn)張開(kāi)還是收縮 bool
  • label_fill 標(biāo)簽是否填充滿整個(gè)區(qū)域

基本方法

  • add(child) 添加控件
  • 還有一些設(shè)置和獲取屬性的方法

(真的沒(méi)什么說(shuō)的)
下篇文章說(shuō)下progress bar(進(jìn)度條) 和 spinner (旋轉(zhuǎn)控件)

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書(shū)系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容