morris555's diary

高校生のブログです。

python de Gtk+3 #5

前回ボックスをやったから……今回は何をしよう??

#!/usr/bin/env python
# -*- coding:utf-8 -*-

from gi.repository import Gtk


class MainWindow(Gtk.Window):
    def __init__(self):
        Gtk.Window.__init__(self, title=u'Table')

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

        button1 = Gtk.Button(label=u'Button 1')
        button2 = Gtk.Button(label=u'Button 2')
        button3 = Gtk.Button(label=u'Button 3')
        button4 = Gtk.Button(label=u'Button 4')
        button5 = Gtk.Button(label=u'Button 5')
        button6 = Gtk.Button(label=u'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)

        self.connect('delete-event', Gtk.main_quit)
        self.show_all()

if __name__ == '__main__':
    MainWindow()
    Gtk.main()

はい、テーブルです。

table.attach(*)

で、テーブルに設置してます。
こんな感じでレイアウトできます。

今回からボタンなどの処理は省いてます…
手抜きですww

余談

最近ページビューがちょっとずつ増えてる(笑)
見た人は是非コメントしてくださいね〜ww