suggestions sought for a framework for a quick, dirty, reallysimple GUI prototype
ik
idokan at gmail.com
Fri Jul 20 14:10:27 IDT 2012
On Fri, Jul 20, 2012 at 1:21 PM, Dov Grobgeld <dov.grobgeld at gmail.com>wrote:
> 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/
>
Way too much code. In Lazarus you do not need to write this code, unless
you really want to.
Object Pascal is not a dynamic language but a static language, so you can
not compare the two.
Even TP was very complex language, and today's language contain even more
features, generics, mixin, and a lot more.
The API of both Lazarus and Delphi is very close to Qt (Qt came after
Delphi).
But today both with Lazarus and Delphi you can create native code and GUI
depends on the platform.
So you do not need to know GTK, Qt, WinAPI, Android API (yes you can
compile native code to run in JVM), iOS etc...
Except of specific stuff. You just use the API. when you compile to/in
windows it will be WinAPI native, no GTK or Qt.
On Linux, you can use GTK or Qt (in compile time you choose it).
On Mac it will be native to that, on BeOS it will native to BeOS etc..
Have a look at my program (not very simple one):
https://github.com/ik5/display-quotes
Only one method with some GUI code inside for an open dialog, that i did
not want to do in a design time. everything else is about the logic, not
about the GUI.
If you will check it closely, I even have code that that add extra features
if you compile it to GTK, and extra code for Windows based requirements,
only one line of code for it.
I binded there the libnotify library arrive from Gnome/GTK. You can see the
code itself.
When you use Python, you do not use GTK, you use a way that is suitable to
Python that at the end translate into GTK.
When you use Vala, it again translate into C that is translated into
machine code.
When you use Lazarus, you use API, that call the native UI methods (like
with Python), but translated into native machine code (elf, exe, class
files).
You have a lot of components and addons in Lazarus, and it is very simple
to write code with it that will work everywhere.
But people still think that working hard and dealing with too much
dependencies on run time for normal users, is the way to go,
and learning 100000 technologies to write one program, is the proper way,
or that you do not need a fast executable (the fastest in bench-marking
then GCC, intel etc.. ),
then please, by all means, keep on going the wrong way ...
Just remember that C#, Go and even C11 copied from Object Pascal most of
it's features ...
My last "battle" in this thread on the subject.
>
> Regards,
> Dov
>
Ido
> 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/a7311c63/attachment.html>
More information about the Linux-il
mailing list