Re: [gtk-list] ANNOUNCE: python-gtk version 0.1



Neil Schemenauer wrote:

> import gtk
> def hello():
>         print 'hello world'
> 
> w = gtk.Window()
> b = gtk.Button(label='Hello')
> b.connect('clicked', hello)
> w.add(b)
> b.show()
> w.show()
> gtk.main()

I don't think that it is wise to change the names of all functions. Try
using gtk.defs to create the stubs! There is a discussion between the
makers of the Perl bindings and the Guile bindings to unify any bindings
to every another language. Please try to find a consens with them so
that every foreign binding works in the same way. Additionaly I think it
is *very* important that you use the same function names in Python. This
makes it *much* easier for the people to read and write programs! And
you do not need your own tutorial or your own reference manual. I for
myself can use the C examples to write Guile programs, because they are
exactly the same:

Hello World in C
----------------

#include "gtk/gtk.h"

void exit_program()
{
  printf("Hello World from C!\n");
  gtk_exit(0);
}

void make_main_window()
{
  static GtkWidget *window = NULL;
  GtkWidget *button;

  window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
  button = gtk_button_new_with_label("Hello World");

  gtk_container_border_width(GTK_CONTAINER(window), 10);
  gtk_container_add(GTK_CONTAINER(window), button);
  gtk_signal_connect(GTK_OBJECT(button), "clicked",
		     (GtkSignalFunc) exit_program,
		     &window);
  gtk_widget_show(button);
  gtk_widget_show(window);
}

int main (int argc, char *argv[])
{
  gtk_init(&argc, &argv);
  make_main_window();
  gtk_main();
  return 0;
}

Hello World in Guile
--------------------

#! /usr/bin/guile-gtk -s
-*- scheme -*-
!#

(define-module (hello-world)
  :use-module (toolkits gtk))

(define (make-main-window)
  (let ((window (gtk-window-new 'toplevel))
	(button (gtk-button-new-with-label "Hello World")))
    (gtk-container-border-width window 10)
    (gtk-container-add window button)
    (gtk-signal-connect button "clicked"
			(lambda ()
			  (display "Hello World from Guile!\n")
			  (gtk-exit)))
    (gtk-widget-show button)
    (gtk-widget-show window)))

(make-main-window)
(gtk-main)

I think this is very important for every language binding. Perhaps you
can contact Marius <mvo@zagadka.ping.de>. He will help you with the
"gtk.defs" definitions which are currently used by the Guile bindings
and the Perl bindings. And he will include some information if you need
it for Python.



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]