[Gtk-sharp-list] Displaying an image
Vincent Arnoux
vincent.arnoux@rfo.atmel.com
Mon, 14 Feb 2005 16:56:56 +0100
Hi,
I am trying to have an image displayed in a Gtk.Image component (from a
snapshot) but I can't get it to work. I declared my Gtk.Image in my
gui.glade and tried to assign from the following code.
This application is pretty urgent for me, so I will take any idea from you.
I did 6 tries as you can see :
// project created on 27/01/2005 at 17:51
using System;
using Gtk;
using Glade;
using System.Collections;
using System.IO;
using System.Diagnostics;
using Gdk;
public class GladeApp
{
[Widget] Button goButton;
[Widget] Gtk.Image image1;
[Widget] Gtk.Window window1;
public static void Main (string[] args)
{
new GladeApp (args);
}
public GladeApp (string[] args)
{
Application.Init();
Glade.XML gxml = new Glade.XML (null, "gui.glade",
"window1", null);
gxml.Autoconnect (this);
Application.Run();
}
/* Connect the Signals defined in Glade */
public void OnWindowDeleteEvent (object o, DeleteEventArgs args)
{
Application.Quit ();
args.RetVal = true;
}
public void on_goButton_clicked(object o, EventArgs args)
{
System.Diagnostics.Process proc = new
System.Diagnostics.Process();
proc.StartInfo.FileName = "import";
proc.StartInfo.Arguments="/tmp/hello.png";
proc.Start();
while(!proc.HasExited)
System.Console.WriteLine("J'attend");
proc.Close();
// Test 1
// Pixbuf pix = new Pixbuf("/tmp/hello.png");
//image1.FromPixbuf = pix;
// Test 2
//image1 = new Gtk.Image(pix);
// Test 3
//image1.Pixbuf = new Gdk.Pixbuf (null, "/tmp/hello.png");
// Test 4
//image1 = new Image("/tmp/hello.png");
// Test 5
//image1.FromFile = "/tmp/hello.png";
// Test 6
//image1.Stock = "/tmp/hello.png";
image1.Show();
window1.ShowAll();
goButton.Label = "Ciao";
}
}