Re: hello world problem



"Martin Eriksen" <martin1710 hotmail com> writes:

> I am trying to draw some simple text on a widget using
> gtk_draw_string. However the string is not displayed;
> the window remains empty. Any suggestions as to what I do wrong?
> 
> #include <gtk/gtk.h>
> 
> int main(int argc, char *argv[])
> {
>   GtkWidget *window;
>   GdkGC *gc;
>   GdkFont* gfont;
>   gtk_init (&argc, &argv);
>   gfont=gdk_font_load("-adobe-helvetica-bold-r-normal--12-120-75-75-p-70-iso8859-1");
>   window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
>   gtk_widget_show (window);
>   gc=gdk_gc_new(window->window);
>   gdk_draw_string (window->window, gfont,gc, 0,0,"hello world");
>   gtk_widget_draw (window, NULL);
>   gtk_main ();
>   return(0);
> }
> 
> Compile-command:
> gcc temp.c -o temp `gtk-config --cflags --libs`

 a) This is a question about _how_ to program with GTK+, not 
    discussion of improving GTK+, so the question should 
    be on gtk-list or gtk-app-devel-list.

 b) Look at the section about drawing in the tutorial (the scribble
    section). It will explain that you basically always should be
    doing all your drawing in an expose handler.

Regards,
                                        Owen
    
    




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]