Bonjours Je me suis mis aux gtk+ depuis peux de même pour le C (c++ par la suite)
je suis donc les tutoriel proposer sur ce sites:
gtk.developpez.com/cours/gtk2/Gtk.Les.tables.php
donc je rencontre quelque problème pour comprendre et utiliser le système qui permet le positionnement des contrôles.
Dans la première image .
panthere-noire.com/gtk.jpg
Je voudrai que la premier série de bouton 1 a 9 soie placer en haut et pas de cette manière.
de même pour le 10 qui soie placer juste en dessous et pas n’importe ou.
La deuxième montre ce que cela donne quand c’est réduit aux minimum.
panthere-noire.com/gtk1.jpg
bref j’ai de la peine comprendre comment ceci bouge si je puis dire.
voici le code:
#include <stdlib.h>
#include <gtk/gtk.h>
int main(int argc, char **argv)
{
GtkWidget *pWindow;
GtkWidget *pTable;
float Ligne;
float Start_Collonne;
float End_Collonne;
float Feuille_largeur;
float Feuille_Hauteur;
/* valeur par defaut des variables */
Ligne = 1;
Feuille_largeur = 1680;
Feuille_Hauteur = 1050;
Start_Collonne = 0;
End_Collonne = 1;
/*
attention si le nombre est inferieur a la demande cela peux empecher
la feuille de s'afficher
*/
GtkWidget *pButton[11];
gtk_init(&argc, &argv);
pWindow = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_window_set_default_size(GTK_WINDOW(pWindow), Feuille_largeur, Feuille_Hauteur);
gtk_window_set_title(GTK_WINDOW(pWindow), "Les GtkTable");
g_signal_connect(G_OBJECT(pWindow), "destroy", G_CALLBACK(gtk_main_quit), NULL);
/* Creation et insertion de la table 10 lignes 4 colonnes */
pTable=gtk_table_new(4,1,TRUE);
gtk_container_add(GTK_CONTAINER(pWindow), GTK_WIDGET(pTable));
/* Creation des boutons */
pButton[0]= gtk_button_new_with_label("Bouton 1");
pButton[1]= gtk_button_new_with_label("Bouton 2");
pButton[2]= gtk_button_new_with_label("Bouton 3");
pButton[3]= gtk_button_new_with_label("Bouton 4");
pButton[4]= gtk_button_new_with_label("Bouton 5");
pButton[5]= gtk_button_new_with_label("Bouton 6");
pButton[6]= gtk_button_new_with_label("Bouton 7");
pButton[7]= gtk_button_new_with_label("Bouton 8");
pButton[8]= gtk_button_new_with_label("Bouton 9");
pButton[9]= gtk_button_new_with_label("Bouton 10");
/* modification des lignes*/
gtk_table_set_row_spacings(GTK_TABLE (pTable), 2);
/*
Insertion des boutons
premiere colonne (depart) 2 eme colonne (arriveé) ? ligne
*/
gtk_table_attach(GTK_TABLE(pTable), pButton[0],
Start_Collonne, End_Collonne, 0, Ligne,
GTK_EXPAND | GTK_EXPAND, GTK_EXPAND,
0, 1);
Start_Collonne=End_Collonne;
End_Collonne=Start_Collonne+1;
gtk_table_attach(GTK_TABLE(pTable), pButton[1],
Start_Collonne, End_Collonne, 0, Ligne,
GTK_EXPAND | GTK_EXPAND, GTK_EXPAND,
0, 1);
Start_Collonne=End_Collonne;
End_Collonne=Start_Collonne+1;
gtk_table_attach(GTK_TABLE(pTable), pButton[2],
Start_Collonne, End_Collonne, 0, Ligne,
GTK_EXPAND | GTK_EXPAND, GTK_EXPAND,
0, 1);
Start_Collonne=End_Collonne;
End_Collonne=Start_Collonne+1;
gtk_table_attach(GTK_TABLE(pTable), pButton[3],
Start_Collonne, End_Collonne, 0, Ligne,
GTK_EXPAND | GTK_EXPAND, GTK_EXPAND,
0, 1);
Start_Collonne=End_Collonne;
End_Collonne=Start_Collonne+1;
gtk_table_attach(GTK_TABLE(pTable), pButton[4],
Start_Collonne, End_Collonne, 0, Ligne,
GTK_EXPAND | GTK_EXPAND, GTK_EXPAND,
0, 1);
Start_Collonne=End_Collonne;
End_Collonne=Start_Collonne+1;
gtk_table_attach(GTK_TABLE(pTable), pButton[5],
Start_Collonne, End_Collonne, 0, Ligne,
GTK_EXPAND | GTK_EXPAND, GTK_EXPAND,
0, 1);
Start_Collonne=End_Collonne;
End_Collonne=Start_Collonne+1;
gtk_table_attach(GTK_TABLE(pTable), pButton[6],
Start_Collonne, End_Collonne, 0, Ligne,
GTK_EXPAND | GTK_EXPAND, GTK_EXPAND,
0, 1);
Start_Collonne=End_Collonne;
End_Collonne=Start_Collonne+1;
gtk_table_attach(GTK_TABLE(pTable), pButton[7],
Start_Collonne, End_Collonne, 0, Ligne,
GTK_EXPAND | GTK_EXPAND, GTK_EXPAND,
0, 1);
Start_Collonne=End_Collonne;
End_Collonne=Start_Collonne+1;
gtk_table_attach(GTK_TABLE(pTable), pButton[8],
Start_Collonne, End_Collonne, 0, Ligne,
GTK_EXPAND | GTK_FILL, GTK_EXPAND,
1, 0);
Start_Collonne=0;
End_Collonne=Start_Collonne+10;
Ligne=Ligne+1 ;
gtk_table_attach(GTK_TABLE(pTable), pButton[9],
Start_Collonne, End_Collonne, 0, Ligne,
GTK_EXPAND | GTK_FILL, GTK_EXPAND,
1, 0);
gtk_widget_show_all(pWindow);
gtk_main();
return EXIT_SUCCESS;
}
compiler avec : gcc -o speedyfile main.c pkg-config --cflags --libs gtk+-2.0
Merci pour tout aide.