1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
| #!/usr/bin/env python3
# -*- coding: utf-8 -*-
import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk
class ScrolledGrid(Gtk.Window):
def __init__(self):
Gtk.Window.__init__(self, title='ScrolledGrid')
self.set_border_width(10)
self.set_default_size(320, 100)
vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=6)
self.add(vbox)
L1 = Gtk.Label()
L1.set_text('Label n° 1')
vbox.pack_start(L1, True, True, 0)
grid = Gtk.Grid()
grid.set_hexpand(True)
L=0
for I in range (16):
B1 = Gtk.Button(label='Bouton 1 ligne' + str(I))
grid.attach(B1, 0, L, 1, 1)
B2 = Gtk.Button(label='Bouton 2 ligne' + str(I))
grid.attach(B2, 1, L, 1, 1)
L += 1
s_win = Gtk.ScrolledWindow()
s_win.set_policy(Gtk.PolicyType.ALWAYS, Gtk.PolicyType.ALWAYS)
s_win.set_min_content_height(300)
s_win.add(grid)
vbox.add(s_win)
L2 = Gtk.Label()
L2.set_text('Label n° 2')
vbox.pack_start(L2, True, True, 0)
GUI = ScrolledGrid()
GUI.connect("destroy", Gtk.main_quit)
GUI.show_all()
Gtk.main() |
Partager