Ci-dessous, les différences entre deux révisions de la page.
| Les deux révisions précédentesRévision précédenteProchaine révision | Révision précédente | ||
| dev:python:pygtk:agencement-widgets [2015/08/13 08:43] – yoann | dev:python:pygtk:agencement-widgets [2021/02/01 21:51] (Version actuelle) – modification externe 127.0.0.1 | ||
|---|---|---|---|
| Ligne 13: | Ligne 13: | ||
| ^ expand= True | Le widget aura la possibilité de consommer l' | ^ expand= True | Le widget aura la possibilité de consommer l' | ||
| ^ expand= False| Le widget ne consommera pas plus d' | ^ expand= False| Le widget ne consommera pas plus d' | ||
| - | ^ fill= True | + | ^ fill= True |
| - | ^ fill= False | Laisser vide l' | + | ^ fill= False | l' |
| < | < | ||
| - | Ces comportements peuvent paraître assez complexes à appréhender au départ mais ils sont indispensables lorsqu' | + | Ces comportements peuvent paraître assez complexes à appréhender au départ mais ils sont indispensables lorsqu' |
| </ | </ | ||
| - | Ci-dessous la signature des méthodes | + | Ci-dessous |
| <code python> | <code python> | ||
| Ligne 26: | Ligne 26: | ||
| </ | </ | ||
| + | **child** est l' | ||
| + | ===== Exemples ===== | ||
| + | |||
| + | Dans les exemples ci-dessous, en mode interactif on crée une fenêtre puis un conteneur horizontal à l’intérieur duquel 4 boutons sont placés. On fait varier les valeurs des arguments **expand**, **fill** et **padding**. | ||
| + | |||
| + | | <code python> | ||
| + | box.pack_start(bt1, | ||
| + | box.pack_end(bt2, | ||
| + | box.pack_start(bt3, | ||
| + | box.pack_start(bt4, | ||
| + | </ | ||
| + | |||
| + | | <code python> | ||
| + | box.pack_start(bt1, | ||
| + | box.pack_end(bt2, | ||
| + | |||
| + | </ | ||
| + | |||
| + | |||
| + | <code python> | ||
| + | box = gtk.HBox(homogeneous=False, | ||
| + | </ | ||
| + | |||
| + | L' | ||
| + | |||
| + | <code python> | ||
| + | box= gtk.HBox(homogeneous=False, | ||
| + | box.pack_start(boutons[0], | ||
| + | box.pack_start(boutons[1], | ||
| + | </ | ||
| + | |||
| + | Dans cet exemple on définit un espace de 20 pixels entre chaque objets dans le conteneur. Lors du packing des boutons on spécifie que ceux-ci n' | ||
| + | |||
| + | {{dev: | ||
| + | |||
| + | |||
| + | Le **padding** ou rembourrage est une marge présente de chaque coté du widget. | ||
| + | <code python> | ||
| + | box = gtk.HBox(homogeneous=False, | ||
| + | box.pack_start(boutons[0], | ||
| + | box.pack_start(boutons[1], | ||
| + | </ | ||
| + | |||
| + | Ici, pour le bouton 0, une marge a été définie a 20 pixel de chaque coté. Les arguments **expand** et **fill** de la méthode **pack_start()** n'ont pas été précisés. Ils prennent donc leur valeur par défaut (True). Le bouton rempliera l' | ||
| + | |||
| + | {{dev: | ||
| + | |||
| + | ===== Tableau ===== | ||
| + | |||
| + | Pour l' | ||
| + | |||
| + | <code python> | ||
| + | table = gtk.Table(rows=1, | ||
| + | </ | ||
| + | |||
| + | L' | ||
| + | |||
| + | Pour placer des widgets dans un objet de type Table, utiliser la méthode attach: | ||
| + | |||
| + | <code python> | ||
| + | object.attach(child, | ||
| + | xoptions=EXPAND|FILL, | ||
| + | </ | ||