Loading image in main window when a button from main window is pressed
- From: RAMINENI <ramineni_bsp yahoo com>
- To: gtk-list gnome org
- Subject: Loading image in main window when a button from main window is pressed
- Date: Wed, 17 Nov 2004 07:29:34 -0800 (PST)
Hi all,
I want to Load the image in main window when a button
from the main window is clicked.I loaded the image
from the main function but when the button is pressed
the image is not changing. How can I change the image
when the button is clicked.Below is my source code
Thanks in advance
AIS
__________________________________
Do you Yahoo!?
Meet the all-new My Yahoo! - Try it today!
http://my.yahoo.com
#include <gtk/gtk.h>
#define WIDTH 640
#define HEIGHT 480
GtkWidget *xpm_label_box( gchar *xpm_filename)
{
GtkWidget *box;
GtkWidget *label;
GtkWidget *image;
gchar *filename="fruits.jpg";
box = gtk_hbox_new (FALSE, 0);
gtk_container_set_border_width (GTK_CONTAINER (box), 2);
image = gtk_image_new_from_file (xpm_filename);
gtk_box_pack_start (GTK_BOX (box), image, FALSE, FALSE, 3);
gtk_widget_show (image);
return box;
}
void hello( GtkWidget *widget, GtkWidget *win)
{
GtkWidget *box=xpm_label_box("images.ppm");
gtk_container_add(GTK_CONTAINER(win), box);
gtk_widget_show(win);
gtk_widget_show_all(win);
}
int main( int argc,
char *argv[] )
{
GtkWidget *frame;
GtkWidget *hbox;
GtkWidget *image_hbox;
GtkWidget *main_vbox;
GtkWidget *vbox;
GtkWidget *vbox2;
GtkWidget *spinner;
GtkWidget *button;
GtkWidget *label;
GtkWidget *val_label;
GtkWidget *box;
gtk_init (&argc, &argv);
GtkWidget* window = gtk_widget_new(gtk_window_get_type(),
"GtkObject::user_data", NULL,
"GtkWindow::type", GTK_WINDOW_TOPLEVEL,
"GtkWindow::title", "Result",
"GtkWindow::allow_shrink", FALSE,
NULL);
g_signal_connect (G_OBJECT (window), "destroy",
G_CALLBACK (gtk_main_quit),
NULL);
gtk_window_set_title (GTK_WINDOW (window), "MAKRO PLUS Obstacle Detection");
gtk_window_set_policy (GTK_WINDOW (window), TRUE, TRUE, TRUE);
gtk_widget_set_size_request(GTK_WIDGET (window), 640, 480);
hbox=gtk_hbox_new (FALSE, 5);
gtk_container_set_border_width (GTK_CONTAINER (hbox), 10);
gtk_container_add (GTK_CONTAINER (window), hbox);
button = gtk_button_new_with_label ("Hello World");
gtk_signal_connect (GTK_OBJECT (button), "clicked",
GTK_SIGNAL_FUNC (hello), (gpointer)window);
gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, TRUE, 0);
box = xpm_label_box("fruits.jpg");
gtk_box_pack_start (GTK_BOX (hbox), box, FALSE, TRUE, 0);
gtk_widget_show (window);
gtk_widget_show_all(window);
gtk_main ();
return 0;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]