Re: hye szg
- From: gxw <szg309 sina com>
- To: "vivek r patel" <vivek_vrp2000 rediffmail com>
- Cc: gtk-app-devel <gtk-app-devel-list gnome org>
- Subject: Re: hye szg
- Date: Wed, 11 Feb 2004 13:53:47 +0800
On 11 Feb 2004 05:01:37 -0000
"vivek r patel" <vivek_vrp2000 rediffmail com> wrote:
i have made a prog in gtk it is running but now showing me the button in that that i have already added
can u help me in that
/* hello-gtk.c */
#include <gtk/gtk.h>
gint QuitProg(GtkWidget *widget, gpointer gdata){
gtk_main_quit();
return (FALSE);
}
int main (int argc, char *argv[]){
GtkWidget *window;
GtkWidget *text_pane;
GtkWidget *button;
gtk_init(&argc, &argv); /*required initializing */
window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_widget_set_usize(window,400,100);
gtk_window_set_title(GTK_WINDOW(window) , "VIVEK PATEL");
gtk_container_set_border_width(GTK_CONTAINER(window),5);
gtk_signal_connect (GTK_OBJECT (window), "delete_event", GTK_SIGNAL_FUNC(QuitProg), NULL);
text_pane = gtk_text_new(NULL, NULL);
gtk_text_set_editable(GTK_TEXT(text_pane) , FALSE);
gtk_container_add(GTK_CONTAINER(window) , text_pane);
gtk_widget_realize(text_pane);
gtk_text_insert(GTK_TEXT(text_pane),NULL,NULL,NULL,"Hello vivek this is ur first gtk based programming
\n\n" , -1);
/* The final step is to display this newly created widget. */
button=gtk_button_new_with_label("hye");
gtk_container_add (GTK_CONTAINER (window), button);
gtk_widget_show (button);
/* this displays the text pane and also the window is shown from here*/
gtk_widget_show(text_pane);
gtk_widget_show (window);
gtk_main ();
}
#include <gtk/gtk.h>
gint QuitProg(GtkWidget *widget, gpointer gdata){
gtk_main_quit();
return (FALSE);
}
int main (int argc, char *argv[]){
GtkWidget *window;
GtkWidget *text_pane;
GtkWidget *vbox; //added
GtkWidget *button;
/*required initializing */
gtk_init(&argc, &argv);
window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_widget_set_usize(window,400,200); //modified,to show all widgets,you also delete the line
gtk_window_set_title(GTK_WINDOW(window) , "VIVEK PATEL");
gtk_container_set_border_width(GTK_CONTAINER(window),5);
gtk_signal_connect (GTK_OBJECT (window), "delete_event", GTK_SIGNAL_FUNC(QuitProg), NULL);
//next three lines was added
vbox=gtk_vbox_new(FALSE,5);
gtk_container_add(GTK_CONTAINER(window) , vbox);
gtk_widget_show(vbox);
text_pane = gtk_text_new(NULL, NULL);
gtk_text_set_editable(GTK_TEXT(text_pane) , FALSE);
//gtk_container_add(GTK_CONTAINER(window) , text_pane); //deleted
gtk_box_pack_start(GTK_BOX(vbox),text_pane,FALSE,FALSE,0); //added
gtk_widget_realize(text_pane);
gtk_text_insert(GTK_TEXT(text_pane),NULL,NULL,NULL,"Hello vivek this is ur first gtk based programming
\n\n" , -1);
/* The final step is to display this newly created widget. */
button=gtk_button_new_with_label("hye");
//gtk_container_add (GTK_CONTAINER (window), button); //deleted
gtk_box_pack_start(GTK_BOX(vbox),button,FALSE,FALSE,0); //added
gtk_widget_show (button);
/* this displays the text pane and also the window is shown from here*/
gtk_widget_show(text_pane);
gtk_widget_show (window);
gtk_main();
return 0;
}
because GTK_CONTAINER is GTK_WINDOW's parent class,so a window is a container,a container has only a
child,you can't add a text_pane and a button to a window.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]