Home Programming Basic C# GTK program

Basic C# GTK program

by shedboy71

In a previous example we created a simple console program, in this example we will create a basic GUI program. To do this we need to install GTK.

Lets begin by installing GTK for mono

sudo apt-get install gtk-sharp2

Create a folder and a file called gtkexample as follows

mkdir gtkexample
cd gtkexample
geany gtkexample.cs

Now enter the following code

using Gtk;
using System;
class gtkHello {
static void Main()
{
Application.Init ();
Window gtkWin = new Window ("GTK Example");
gtkWin.Show();
Application.Run();
}
}

Now open the file manager, navigate to the gtkexample folder. This should look like this

gtk folder structure

gtk folder structure

Now double click on the gtkexample.exe. You should see something like the following

gtk window

gtk window

You may also like