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 how to make the string
appear?

Take a look at the scribble example in the GTK+ tutorial.  In a
nutshell, you need to be drawing the text in an expose event.  However,
if all you want to do is draw text, why not use a label:
eg.

#include <gtk/gtk.h>

int main(int argc, char *argv[])
{
  GtkWidget *window;
  GtkWidget *label;

  gtk_init (&argc, &argv);

  window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  label = gtk_label_new ("Hello World");
  gtk_container_add (GTK_CONTAINER (window), label);

  gtk_widget_show_all (window);

  gtk_main ();
  return(0);
}

Thanks,
-Jonathan




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