Re: PerlGTK with GTK module written in C ?




On Jul 16, 2004, at 2:26 PM, Nagappan wrote:

Is there a way in which I can integrate at-least Perl / Python. Then that will be of great.

yes, it is very possible. gaim embeds several languages in its plugins. i dug through the perl manual to figure out the attached example, but gaim has some code which may be illustrative (their perl support predates gtk2-perl, as far as i can tell, and has a mini-binding for the important bits of glib that gaim plugins need): http://cvs.sourceforge.net/viewcvs.py/gaim/gaim/plugins/perl/perl.c? rev=1.39&view=auto


 What do you suggest me.

you will have to embed a perl/python interpreter in your plugins.

this is actually really easy with perl. i figured it out in only a little while (granted i've been doing a lot of perlxs so i had an idea of i was doing) from the excellent tutorial in the perlembed manpage. the stuff i don't know really at all is the gtk module stuff.

attached is a simple example of how you'd do it. i don't know how to tell gtk to load modules that aren't in the system gtk+ modules dir (e.g. /usr/lib/gtk-2.0/modules/) so you'll have to have root access to try it out (unless you installed gtk+ to a sandbox ;-). the example uses a perl interpreter to load Gtk2 and create a new dialog 1 second after the app starts, without any changes to the app at all. i didn't try to figure out how to communicate between the module and the app; that's your job. :-)

i imagine that python would be very similar.

(by the way, you don't have to use the module with the included foo program, it also works with any gtk+ program (it was pretty cool to see it pop up over the gimp).)

Attachment: embed.tar.gz
Description: GNU Zip compressed data



--
That's it! It's one thing for a ghost to scare my children, but it's another to play my theremin!
  - Homer Simpson


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