DEV Community

ramank-r
ramank-r

Posted on

Example 1- Simple GTK example

/*
to make a GTK project in codeblocks, we have to sepecify 'other compiler settings' and 'linker settigs', to har example ke liye alag jagah source code file save nahi karenge

we will continue testing it in this project and will store our source codes files at one location : desktop/gtk_examples

in case u need to create new project , visit this : (timestamp_for_C 3:45) https://www.youtube.com/watch?v=fdGOmBahxeY&ab_channel=AtoZProgrammingTutorials

*/

`

include

void main (int argc, char *argv[]){

GtkWidget *window;  /*! GtkWidget is a variable type to define various components like window, button, label... In this example, a window is defined like the following:  GtkWidget *window;*/

gtk_init (&argc, &argv); /*! intitiates the toolkit and gets the parameter entered in command line */
/*! this function should be used after declaring the componenets, (jaise hmne window ko define kr dia h)*/

window = gtk_window_new (GTK_WINDOW_TOPLEVEL);  /*! GtkWidget *gtk_window_new(GtkWindowType windowtype) creates a new window. Window type can be: GTK_WINDOW_TOPLEVEL,GTK_WINDOW_DIALOG, GTK_WINDOW_POPUP,,,, hmne TOPLEVEL wala banaya hai*/

gtk_widget_show (window);
/*! void gtk_widget_show(GtkWidget *widget) is used to make the component appear in a window. After defining a component and changing attributes, this function must be used.*/


gtk_main ();
/*! void gtk_main(void) prepares windows and all components to appear in the screen. This function must be used at the end of GTK programs.*/
Enter fullscreen mode Exit fullscreen mode

}`

Top comments (0)