@@ -66,7 +66,35 @@ Add widgets to the `area` attribute of a `ScrollableAreaQt5`/`ScrollableAreaQt6`
6666
6767--- 
6868
69- In GTK, containers are widgets, so they can be aligned in other containers. For instance, while using PyGObject, you
70- can horizontally centre a ` Gtk.Grid `  in a ` Gtk.ScrolledWindow `  using ` Gtk.Grid.set_halign ` . Since horizontally centring
71- the contents of a scrollable container is the primary function of this package, and GTK has built-in functionality to
72- achieve the same, no submodule for PyGObject is implemented here.
69+ In GTK, containers are widgets, so they can be aligned in other containers.
70+ 
71+ ``` Python 
72+ import  itertools
73+ import  gi; gi.require_version(' Gtk'  , ' 3.0'  )
74+ from  gi.repository import  Gtk
75+ 
76+ window =  Gtk.Window()
77+ window.connect(' destroy'  , Gtk.main_quit)
78+ window.set_default_size(256 , 128 )
79+ 
80+ scrolled_window =  Gtk.ScrolledWindow()
81+ window.add(scrolled_window)
82+ 
83+ grid =  Gtk.Grid()
84+ grid.set_halign(Gtk.Align.CENTER )
85+ grid.set_row_spacing(20 )
86+ grid.set_column_spacing(20 )
87+ scrolled_window.add(grid)
88+ 
89+ dim =  10 
90+ for  (i, j) in  itertools.product(range (dim), repeat = 2 ):
91+     label =  Gtk.Label()
92+     label.set_label(f ' Label \n ( { i} ,  { j} ) ' )
93+     grid.attach(label, j, i, 1 , 1 )
94+ 
95+ window.show_all()
96+ Gtk.main()
97+ ``` 
98+ 
99+ Since horizontally centring the contents of a scrollable container is the primary function of this package, and GTK has
100+ built-in functionality to achieve the same, no submodule for PyGObject is implemented here.
0 commit comments