suggestions sought for a framework for a quick, dirty, reallysimple GUI prototype

suggestions sought for a framework for a quick, dirty, reallysimple GUI prototype

Dov Grobgeld dov.grobgeld at gmail.com
Fri Jul 20 13:21:41 IDT 2012


Here are a few comparisons. (Note that I always prefer inheriting the main
window and thus create a derived widget. This typically requires more code,
but in return you get a real widget that integrates seamlessly into the
widget system.)

Python gtk:

#!/usr/bin/python

import gtk

class HelloWorld(gtk.Window):
    def button_clicked(self, data):
        print "Hello World!"

    def __init__(self):
        gtk.Window.__init__(self, gtk.WINDOW_TOPLEVEL)

        self.connect("destroy", gtk.main_quit)

        button = gtk.Button("Press me")
        button.connect("clicked", self.button_clicked)
        button.show()
        self.add(button)

HelloWorld().show()
gtk.main()

Vala:

using Gtk;

public class HelloWorld : Gtk.Window {
    construct {
        this.title = "Hello World";
        var button = new Button.with_label("Hello world");
        button.clicked.connect( () => {
            stdout.printf("Hello world!\n");
        });

        button.show();
        this.add(button);
    }
}

int main(string[] args) {
    Gtk.init(ref args);

    var hello_world = new HelloWorld();
    hello_world.show();

    Gtk.main();
    return 0;
}

For pyside / PyQt see:

http://www.harshj.com/2009/04/26/the-pyqt-intro/

It carries some additional noise due to the python vs qt bindings.

Regarding tcl, I once wrote a gtk/Tcl quick and dirty prototyping tool,
that may be of interest to someone. See:

http://gemshell.sourceforge.net/

Regards,
Dov
On Thu, Jul 19, 2012 at 9:14 PM, Nadav Har'El <nyh at math.technion.ac.il>wrote:

> On Thu, Jul 19, 2012, Dov Grobgeld wrote about "Re: suggestions sought for
> a framework for a quick, dirty, reallysimple GUI prototype":
> > very nicely reflects the beauty of the GObject system. Especially in C it
> > is easy to miss that because of the very tedious syntax you need to use,
> > e.g. to define an derived class. In Vala the syntax is very concise.
>
> This is a very important point. This is why I loved Tcl/Tk when I
> learned it in the mid 90s - the code to create the gui was so compact,
> so elegant - the complete opposite of Xlib, Xaw and Motif, each
> requiring you to write dozens of lines for every simple task.
>
> For example, here is a program in TCL/TK which shows a "hello" button
> which outputs "hi" when pressed. How does it look in your favorite
> gui language?
>
>         #!/usr/bin/wish
>         button .a -text "hello" -command "puts hi"
>         pack .a
>
> For the curious, the first command creates a button ".a" - in TK, widgets
> are hierarchical and have hierarchical pathnames, with "." separating
> components, so ".a" is a child of the toplevel window "." with the name
> a. The TCL language is a simple language resembling the shell (but with
> interesting improvements, which I can eleborate if anyone cares).
> The second command "packs" .a in its parent, i.e., the toplevel window
> ".". "packing" means that you ask to have .a be placed and sized
> automatically.
>
> I'm still saddened by the fate of TCL/TK. I still blame Sun for what
> happened to it. sun bought TCL/TK and its inventor John Ousterhout
> with intentions of turning TCL into a browser scripting language, and
> then "burried" TCL when Sun decided to go with Java instead (though
> interestingly, Java NEVER become a language of the web). I'm sad,
> because I was really a big fan of TCL and TK. I still am.
>
> Sic transit gloria mundi.
>
> > Regarding the fact that it compiles to C, as long as I have an automatic
> > build system, what do I care what it compiles to? But most other high
> > language bindings to Gtk are just as easy to use (e.g. Python, Lua, or
> > Haskell).
>
> I'm curious, why does it need to compile at all? Why didn't they just
> write an interpreter, like TCL did?
>
> Nadav.
>
>
> --
> Nadav Har'El                        |         Thursday, Jul 19 2012, 1 Av
> 5772
> nyh at math.technion.ac.il
> |-----------------------------------------
> Phone +972-523-790466, ICQ 13349191 |error compiling committee.c: too many
> http://nadav.harel.org.il           |arguments to function
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.cs.huji.ac.il/pipermail/linux-il/attachments/20120720/56d529b5/attachment-0001.html>


More information about the Linux-il mailing list