GTK-server - Example

Example

The following Kornshell script starts the GTK-server in stdin mode, and creates a simple window with an exit button:

#!/bin/ksh # Start GTK-server gtk-server -stdin |& # Communicate with GTK-server and assign function function gtk { print -p $1; read -p GTK; } function define { $2 "$3"; eval $1="$GTK"; } # Setup GUI gtk "gtk_init NULL NULL" define WINDOW gtk "gtk_window_new 0" gtk "gtk_window_set_title $WINDOW 'Korn GTK-server demo'" gtk "gtk_window_set_default_size $WINDOW 400 200" define TABLE gtk "gtk_table_new 10 10 1" gtk "gtk_container_add $WINDOW $TABLE" define BUTTON gtk "gtk_button_new_with_label 'Click to Quit'" gtk "gtk_table_attach_defaults $TABLE $BUTTON 5 9 5 9" gtk "gtk_widget_show_all $WINDOW" # Mainloop until ] do define EVENT gtk "gtk_server_callback wait" done # Exit GTK-server gtk "gtk_server_exit"

Read more about this topic:  GTK-server

Famous quotes containing the word example:

    Our intellect is not the most subtle, the most powerful, the most appropriate, instrument for revealing the truth. It is life that, little by little, example by example, permits us to see that what is most important to our heart, or to our mind, is learned not by reasoning but through other agencies. Then it is that the intellect, observing their superiority, abdicates its control to them upon reasoned grounds and agrees to become their collaborator and lackey.
    Marcel Proust (1871–1922)