Ubuntu – How to create Ubuntu graphic C programs without Gtk

application-developmentcgraphicsgtk

Is there some sort of program or something to turn your text program graphical in C?

Thank You,

CCM

Best Answer

Here's a simple way with calling external program - zenity. This way your command-line C code is now a GUI app by virtue of using zenity's simple input popup dialog, although this method isn't particularly secure.

#include <unistd.h>
#include <stdio.h>

int main(){
    FILE *zenity;
    char answer[getpagesize()];

    if ((zenity = popen("zenity --entry","r")) != NULL){

        fgets(answer,sizeof(answer),zenity);
        printf("User's answer:%s\n",answer);
        exit(0);
    }
    // we get here if above check failed
    perror("zenity exited with non-zero exit code");

    return 0;
}
Related Question