您的位置:首页 > 移动开发 > Objective-C

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

2016-07-30 13:39 429 查看
GtkTable
继承关系

Methods

Virtual Methods

Properties

Signals

例子

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
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息