button and box
#include <gtk/gtk.h>#include <stdio.h>
void button_start_func (GtkWidget *window, gpointer data)
{
printf ("start\n");
}
void button_end_func (GtkWidget *window, gpointer data)
{
printf ("end\n");
}
int main (int argc, char *argv[])
{
GtkWidget *window;
GtkWidget *entry;
GtkWidget *button_start;
GtkWidget *button_end;
GtkWidget *entry_num;
GtkWidget *entry_val;
GtkWidget *hbox;
GtkWidget *vbox;
gtk_init (&argc, &argv);
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
entry = gtk_entry_new ();
button_start = gtk_button_new_with_label ("start");
button_end = gtk_button_new_with_label ("end");
entry_num = gtk_entry_new ();
entry_val = gtk_entry_new ();
hbox = gtk_hbox_new (FALSE, 4);
vbox = gtk_vbox_new (TRUE, 4);
g_signal_connect (GTK_OBJECT (button_start), "clicked", GTK_SIGNAL_FUNC ( button_start_func ), NULL);
g_signal_connect (GTK_OBJECT (button_end), "clicked", GTK_SIGNAL_FUNC ( button_end_func ), NULL);
gtk_box_pack_start (GTK_BOX (hbox), entry, TRUE, TRUE, 2);
gtk_box_pack_start (GTK_BOX (hbox), entry_num, TRUE, TRUE, 2);
gtk_box_pack_start (GTK_BOX (hbox), button_start, FALSE, TRUE, 2);
gtk_box_pack_start (GTK_BOX (hbox), button_end, FALSE, TRUE, 2);
gtk_box_pack_start (GTK_BOX (vbox), hbox, TRUE, TRUE, 2);
gtk_box_pack_start (GTK_BOX (vbox), entry_val, TRUE, TRUE, 2);
gtk_container_add (GTK_CONTAINER (window), vbox);
gtk_widget_show_all (window);
gtk_main ();
return 0;
}
在label里面显示出来多好啊dos太难看了
页:
[1]