Re: why i can't set background of widget?



----- Original Message -----
From: gxw <szg309 sina com>
Date: Wed, 11 Feb 2004 11:39:06 +0800
To: gtk-app-devel <gtk-app-devel-list gnome org>
Subject: why i can't set background of widget?

un the following simple code,the button background is black,and can't see "Hello World",who can tell me the 
reason?

Thank you!

#include <gtk/gtk.h>

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

ain ();
    return 0;
}

Hai,
       
   Your code should be changed to the following way


#include <gtk/gtk.h>
                                                                                                              
 
int main( int argc,char *argv[] )
{
                                                                                                              
 
    GtkWidget *window;
    GtkWidget *button;
    GtkStyle *style;
        GdkColor color;
                                                                                                              
 
    gtk_init (&argc, &argv);
                                                                                                              
 
    window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
                                                                                                              
 
    gtk_container_set_border_width (GTK_CONTAINER (window), 10);
                                                                                                              
 
    button = gtk_button_new_with_label ("Hello World");
        gdk_color_parse("green",&color);
        gtk_widget_modify_bg(button,GTK_STATE_NORMAL,&color);
        gtk_widget_modify_bg(button,GTK_STATE_PRELIGHT,&color);
    gtk_container_add (GTK_CONTAINER (window), button);
                                                                                                              
 
    gtk_widget_show (button);
    gtk_widget_show (window);
    gtk_main ();
    return 0;
}

 


With Regards
Manoj

-- 
______________________________________________
Check out the latest SMS services @ http://www.linuxmail.org 
This allows you to send and receive SMS through your mailbox.


Powered by Outblaze



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