LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   creating buttons in GTK+ (https://www.linuxquestions.org/questions/programming-9/creating-buttons-in-gtk-322551/)

geminigal 05-11-2005 07:56 PM

creating buttons in GTK+
 
hi. How do i pack multiple buttons into a box? I tried the following codes but in vain.
[code]

GtkWidget *create(GtkWidget *b, gpointer gdata)
{
GtkWidget *button;
GtkWidget *box1;
int i;
int text;
gchar buffer[32];

text = gtk_entry_get_text(GTK_ENTRY(b));
/* Create box for xpm and label */
box1 = gtk_hbox_new (FALSE, 0);
gtk_container_set_border_width (GTK_CONTAINER (box1), 2);

for (i=1;i<=text;i++)
{
sprintf (buffer, "PC %d\n", text);
button = gtk_button_new_with_label(buffer);
gtk_box_pack_start (GTK_BOX (box1), button, FALSE, FALSE, 3);
gtk_widget_show (button);
gtk_widget_show(box1);
}
return box1;
//printf("Number of PCs: %d\n",number);
}
{/code]


in Main() function

Code:

  entry = gtk_entry_new();
  text = gtk_entry_get_text(GTK_ENTRY(entry));
...
 button1 = gtk_button_new_with_label ("Ok");
   
    /* Setup the signal to terminate the program when the button is clicked */
    gtk_signal_connect_object (GTK_OBJECT (button1), "clicked",
                              GTK_SIGNAL_FUNC (create),
                              GTK_OBJECT (entry));

  gtk_container_add(GTK_CONTAINER(vbox), create2(entry),NULL);

Now how do i return the box to be packed to the scrolled window or another box to the main() function?? This is because i still can't find any other way to get the returned box in the main() function. can anyone pls help? tq.

mrcheeks 05-11-2005 08:43 PM

i don't remember much for C/C++ but why don't you use GLADE?


All times are GMT -5. The time now is 01:11 AM.