PyGobject(五十三)布局容器之Table

Gtk.Table

Gtk.Table表格布局。Gtk.Table已被弃用,使用Gtk.Grid代替。因为Gtk.Table创建时需要指定列数和行数,而Gtk.Grid不用,它可以动态调整

继承关系

Gtk.Table是Gtk.Container的直接子类
这里写图片描述

Methods

方法修饰词方法名及参数
staticnew (rows, columns, homogeneous)
attach (child, left_attach, right_attach, top_attach, bottom_attach, xoptions, yoptions, xpadding, ypadding)
attach_defaults (widget, left_attach, right_attach, top_attach, bottom_attach)
get_col_spacing (column)
get_default_col_spacing ()
get_default_row_spacing ()
get_homogeneous ()
get_row_spacing (row)
get_size ()
resize (rows, columns)
set_col_spacing (column, spacing)
set_col_spacings (spacing)
set_homogeneous (homogeneous)
set_row_spacing (row, spacing)
set_row_spacings (spacing)

Virtual Methods

Properties

NameTypeFlagsShort Description
column-spacingintr/wThe amount of space between two consecutive columns
homogeneousboolr/wIf True, the table cells are all the same width/height
n-columnsintr/wThe number of columns in the table
n-rowsintr/wThe number of rows in the table
row-spacingintr/wThe amount of space between two consecutive rows

Signals

NameShort Description

例子

这里写图片描述
代码:

#!/usr/bin/env python3
# Created by xiaosanyu at 16/6/16
# section 070

TITLE = "Table"
DESCRIPTION = """
The Gtk.Table functions allow the programmer to arrange widgets in rows and columns,
making it easy to align many widgets next to each other, horizontally and vertically.
"""
import gi

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


class TableWindow(Gtk.Window):
    def __init__(self):
        Gtk.Window.__init__(self, title="Table Example")

        table = Gtk.Table(3, 3, True)
        self.add(table)

        button1 = Gtk.Button(label="Button 1")
        button2 = Gtk.Button(label="Button 2")
        button3 = Gtk.Button(label="Button 3")
        button4 = Gtk.Button(label="Button 4")
        button5 = Gtk.Button(label="Button 5")
        button6 = Gtk.Button(label="Button 6")

        table.attach(button1, 0, 1, 0, 1)
        table.attach(button2, 1, 3, 0, 1)
        table.attach(button3, 0, 1, 1, 3)
        table.attach(button4, 1, 3, 1, 2)
        table.attach(button5, 1, 2, 2, 3)
        table.attach(button6, 2, 3, 2, 3)


def main():
    win = TableWindow()
    win.connect("delete-event", Gtk.main_quit)
    win.show_all()
    Gtk.main()


if __name__ == "__main__":
    main()

代码解析

例子同Gtk.Grid中的例子
比较简单,略过




代码下载地址:http://download.csdn.net/detail/a87b01c14/9594728

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

sanxiaochengyu

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值