flat assembler
Message board for the users of flat assembler.

Index > Heap > Easy GTK GUI for lots of languages!

Author
Thread Post new topic Reply to topic
OzzY



Joined: 19 Sep 2003
Posts: 1029
Location: Everywhere
OzzY
www.gtk-server.org

Looks like a great project!
Provides GTK GUI for lots of scripting languages.
I'll later try to use it with FASM. Laughing
Post 30 Sep 2006, 04:40
View user's profile Send private message Reply with quote
DataHunter2009



Joined: 10 Jun 2005
Posts: 144
DataHunter2009
There are already GTK libraries for various languages. This looks OK, but I'd rather use something proven to be stable and something that makes the code look better. Besides, the site is awful! Frame are pure evil and tables are almost as bad.
Post 30 Sep 2006, 12:37
View user's profile Send private message Reply with quote
OzzY



Joined: 19 Sep 2003
Posts: 1029
Location: Everywhere
OzzY
But this project targets scripting languages that can't use GTK DLL's.
It's possible to access GTK with VBScript for example!
What's so bad about the site? Looks OK for me. I don't see a reason to hate frames.
Post 30 Sep 2006, 15:58
View user's profile Send private message Reply with quote
Pjot



Joined: 30 Sep 2006
Posts: 4
Pjot
Can't help noticing you are talking about this project.

- GTK-server has proven to be stable.
- The code can look as nice as if you are programming GTK directly. Check the download section for the language bindings, or the various Lisp examples.
Post 30 Sep 2006, 16:51
View user's profile Send private message Reply with quote
DataHunter2009



Joined: 10 Jun 2005
Posts: 144
DataHunter2009
Quote:
What's so bad about the site? Looks OK for me. I don't see a reason to hate frames.

No offense, but you must not be a web designer, then. You can accomplish everything with CSS that you can with frames, and CSS is supported better. The site uses the default browser font, one shade of blue, default link colors, etc. Must I go on? I believe that a website can influence the user's first impression of the software. That website didn't give me a good first impression.
Quote:
The code can look as nice as if you are programming GTK directly

For me? No. Maybe for other people. But, imho, the one function system just looks really bad to me. You use one function to access everything, which makes it harder to read. That's just my opinion, and I would rather not argue about it.
Post 30 Sep 2006, 17:44
View user's profile Send private message Reply with quote
Pjot



Joined: 30 Sep 2006
Posts: 4
Pjot
Quote:

You use one function to access everything, which makes it harder to read.

I am afraid I do not get this remark. Can you give an example?
Post 30 Sep 2006, 18:03
View user's profile Send private message Reply with quote
DataHunter2009



Joined: 10 Jun 2005
Posts: 144
DataHunter2009
For example, in the Python example, you pass everything to a "gtk()" function. In PHP, you pass everything to a "Gtk_Msg()" function. It just looks sloppy to me. *shrugs*
Post 30 Sep 2006, 18:06
View user's profile Send private message Reply with quote
Pjot



Joined: 30 Sep 2006
Posts: 4
Pjot
As I mentioned before, you should look at the language bindings in the download section.

For example, with newLisp, symbols can be created on-the-fly and can be used as genuine GTK-functions:
Code:
#!/usr/bin/newlisp

(import "libgtk-server.so" "gtk")

(set 'cfgfile (open "/etc/gtk-server.cfg" "read"))

(cond ((not cfgfile)(println "No GTK-server configfile found! Exiting...")(exit)))

(while (read-line cfgfile)
    (if (starts-with (current-line) "FUNCTION_NAME")
        (begin
            (set 'func (chop ((parse (current-line) " ") 2)))
            (set 'lb (append {(lambda()(setq s "} func {")(dolist (x (args))(setq s (string s " " x)))(get-string (gtk s)))}))
            (constant (global (sym func)) (eval-string lb))
        )
    )
)
(close cfgfile)

# Setup main window
(gtk_init "NULL" "NULL)")
(set 'win (gtk_window_new 0))
(gtk_window_set_title win {"Mouse O'meter"})
(gtk_widget_set_usize win 200 40)
(gtk_window_set_position win 1)
(gtk_window_set_resizable win 0)
# Prepare async
(gtk_server_connect win "show win")
(gtk_server_timeout 75 win "show")
# The labels
(set 'dlabel (gtk_label_new {"Distance: 0.00 meters."}))
(set 'slabel (gtk_label_new {"Average speed:  0.00 cm/s."}))
# Now arrange widgets on window using boxes
(set 'vbox (gtk_vbox_new 0 0))
(gtk_box_pack_start vbox dlabel 0 0 1)
(gtk_box_pack_start vbox slabel 0 0 1)
(gtk_container_add win vbox)
# Show all widgets
(gtk_widget_show_all win)

...etc...
    

Example with plain KornShell:
Code:
#!/usr/bin/ksh

if [[ ! -f /etc/gtk-server.cfg ]]
then
    print "No GTK-server configfile found! Please install GTK-server..."
    exit 1
elif [[ ! -f $HOME/.gtk4korn || /etc/gtk-server.cfg -nt $HOME/.gtk4korn ]]
then
    while read LINE
    do
        if [[ $LINE == +(*FUNCTION_NAME*) ]]
        then
            TMP=${LINE#*= }
            print "function ${TMP%%,*}" >> $HOME/.gtk4korn
            print "{\nprint -p ${TMP%%,*} \$1 \$2 \$3 \$4 \$5 \$6 \$7 \$8 \$9 \$10" >> $HOME/.gtk4korn
            print "read -p RESULT\n}" >> $HOME/.gtk4korn
        fi
    done < /etc/gtk-server.cfg
fi

# Include the generated '.gtk4korn'-file in the shellscript to use embedded GTK functions
. $HOME/.gtk4korn

# Start GTK-server
gtk-server stdin |&

# Define GUI
gtk_init "NULL NULL"
gtk_window_new 0
WINDOW=$RESULT
gtk_window_set_title $WINDOW "'This is a title'"
gtk_window_set_position $WINDOW 1
gtk_table_new 10 10 1
TABLE=$RESULT
gtk_container_add $WINDOW $TABLE
gtk_button_new_with_label "'Click here!'"
BUTTON=$RESULT
gtk_table_attach_defaults $TABLE $BUTTON 5 9 7 9
gtk_check_button_new_with_label "'Check this \n out!'"
CHECK=$RESULT
gtk_table_attach_defaults $TABLE $CHECK 1 6 1 2
gtk_entry_new
ENTRY=$RESULT
gtk_table_attach_defaults $TABLE $ENTRY 1 6 3 4
gtk_widget_show_all $WINDOW

...etc...
    

In the KornShell example I have to read the result of some GTK-functions explicitely, but that is a problem in KornShell, not in GTK-server. KornShell functions cannot pass back a value calculated in the function.

You can do this for every interpreted language, there are already bindings for Scheme, Scriptbasic, Yabasic, but also KornShell and newLisp.

As you can see, it can look like you are programming GTK directly, after putting a small header on top of your program setting up symbols or functionnames.
Post 30 Sep 2006, 18:25
View user's profile Send private message Reply with quote
DataHunter2009



Joined: 10 Jun 2005
Posts: 144
DataHunter2009
Quote:
As you can see, it can look like you are programming GTK directly, after putting a small header on top of your program setting up symbols or functionnames.

Yes, but why should I have to do that when there are already bindings for my favorite languages that don't require me to setup symbols that point to function names?
Post 30 Sep 2006, 18:45
View user's profile Send private message Reply with quote
Pjot



Joined: 30 Sep 2006
Posts: 4
Pjot
That is true, so short answer: you shouldn't. Even stronger, it is better to use the GTK bindings which are already available for languages like Python and Perl.

The examples for Python, Perl, PHP etc. are there to test, and to prove that the concept of the GTK-server actually works. Still for these languages the GTK-server can be useful, since also XForms can be used as backend, and there will be other backends in the future. I wonder if, for example, Python bindings exist for all these other backends as well.

But that is not the main purpose of the GTK-server concept. For many languages there are no GUI bindings at all, like newLisp, Korn, Scheme, Yabasic etc. and the GTK-server can be a userful and clean alternative, as you do not need to (hard-)code a binding into the sourcecode of an interpreter.
Post 30 Sep 2006, 19:00
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar.

Powered by rwasa.