Gtk.Table
Gtk.Table表格布局。Gtk.Table已被弃用,使用Gtk.Grid代替。因为Gtk.Table创建时需要指定列数和行数,而Gtk.Grid不用,它可以动态调整
继承关系
Gtk.Table是Gtk.Container的直接子类
Methods
| 方法修饰词 | 方法名及参数 |
|---|---|
| static | new (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
| Name | Type | Flags | Short Description |
|---|---|---|---|
| column-spacing | int | r/w | The amount of space between two consecutive columns |
| homogeneous | bool | r/w | If True, the table cells are all the same width/height |
| n-columns | int | r/w | The number of columns in the table |
| n-rows | int | r/w | The number of rows in the table |
| row-spacing | int | r/w | The amount of space between two consecutive rows |
Signals
| Name | Short 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.youkuaiyun.com/detail/a87b01c14/9594728

1682

被折叠的 条评论
为什么被折叠?



