My First Linux App

Posted on 2004-08-13 at 08:01

Having now written an app for Linux, I am left wondering what I should use my newfound great powers for. Forthwith, I present to the world, the "Click the Damn Button!" application written in C#, using GTK#, and compiled to run in mono on Linux:

using System;
using Gtk;

public class ButtonClicker
{
    public static void Main()
    {
        Application.Init();

        Window window = new Window("Click The Damn Button!");

        Label label = new Label("Name");
        Entry entry = new Entry();
        Button button = new Button("Click Me!");

        window.DeleteEvent +=
            new DeleteEventHandler(window_DeleteEvent);
        button.Clicked += new EventHandler(button_Clicked);

        VBox vbox = new VBox();

        HBox hbox = new HBox();
        hbox.PackStart(label, false, false, 12);
        hbox.PackStart(entry, false, false, 12);
        vbox.PackStart(hbox);
        vbox.PackStart(button, false, false, 12);

        window.Add(vbox);
        window.SetDefaultSize(200, 100);
        window.ShowAll();

        Application.Run();
    }

    static void window_DeleteEvent(object o,
                DeleteEventArgs args)
    {
        Application.Quit();
        args.RetVal = true;
    }

    static void button_Clicked(object sender, EventArgs e)
    {
        Console.WriteLine("You clicked the button!");
    }
}

Where is the proof that it works, you ask? Well, suck on this screenshot, bizzotch:

Make A Comment