Python

I wrote this python code that I want to use in a FvwmScript, but i need to maintain an instance of my object. In addition, when someone clicks on a certain menu item, associated with the button that’s swallowing my script, I want it to invoke a specific method of my instance. How the heck do I do either of these things: maintain an instance of my class in FvwmScript (in PeriodicTasks) and call methods of the instances through fvwm menu selection?

Doing ‘Exec ./foo.py’ won’t work, unless i can somehow receive menu messages from Fvwm and send ChangeTitle/ChangeIcon messages back to Fvwm.

thanks

You could use the fvwmscript protocol and keep a backend python process running… or is that what you do already?

are you talking about just executing the python process and reading and writing to it’s output and input? if so, this essentially would work, but how would I handle menu selections?

thanks

It’s a bit more complex than that. You create a FIFO in $FVWM_USERDIR and then communicate with the backend using the SendMsgAndGet command in the FvwmScript and by reading and writing to the fifo from the python end. Then you can send arbitary commands from FvwmScript to your backend and send back what ever information seems called for.

It’s in the manual for FvwmScript under A COMMUNICATION PROTOCOL. There’s an example of it in /usr/share/fvwm. Or look at the clock applet I wrote for the new default desktop. Both of 'em in Perl, alas.

thanks, that helps out. where is your clock script located and what’s it called? also, is it possible to send a message from a menu to this “backend process” that’s been executed by FvwmScript?

It’s in the tarballs in this thread: http://fvwm.lair.be/viewtopic.php?t=205.

First of all, I’ve stick the FvwmScript and the perl script that accompanies it into a tarball. Stick 'em both in $HOME/.fvwm and start the script with FvwmScript as per normal.

If you want to see what it looks (mainly its colourful) like or get a bit of background, see here

Second: That all depends. Are you talking about the menus implemented as part of the FvwmScript? If so you can send messages from there using the SendMsgAndGet command.

If you mean from FvwmMenus, it gets a bit more complicated. You’ll need to define a widget that accepts messages; send a message to the widget using SendToModule; and then from the widget’s message section, use SendMsgAndGet as before

once again, very helpful. though, both links were incorrect

Thanks. Try these instead:

thread
tarball