[R-gui] R-wxPython and Gtk event loop (small progress)

James Wettenhall wettenhall at wehi.edu.au
Sun Jun 27 19:09:42 CEST 2004


Hi,

I just thought I'd mention that I haven't given up on R-wxPython 
in Gtk/Linux, but I'm still finding it pretty tough.  I 
mentioned recently that I had message boxes working in Gtk/Linux 
but not much else.  That was because I was using ShowModal for 
the message boxes so they had a valid event loop, but I didn't 
have an "overall" valid wxGTK event loop, so the wxShow methods 
didn't work.  For now, I've changed all of the dialog 
examples in the documentation to use ShowModal instead of Show, 
but of course this doesn't work for frames (and I have a few 
dialogs in the documentation without Close/OK/Cancel buttons, 
which needs to be fixed now that they are modal, i.e. I don't 
have an R command-line cursor where I can type "wxClose(dlg)").

0.2.4 is at
http://bioinf.wehi.edu.au/folders/james/wxPython/

Since my last post, I have progressed (in Gtk/Linux) from 
only message boxes to only modal dialogs (including message 
dialogs).  I now have working modal dialog examples 
including list boxes, radio buttons and check boxes 
(see the documentation).

Of course this is so far avoiding the real solution.
wxPython wants you to define all of your dialog and frame 
classes and then run a MainLoop() method on a wxApp object, and 
I have had some success with this on Windows, but not at all on 
Gtk/Linux yet.  When I try to run my MainLoop, the R session 
just seems to hang.

The basic idea is that instead of typing R commands to say 
"define frame", then "show frame" directly at the R 
command-line, you would include them in an R function called 
wxApp() which would be called by RSPython's RS.call from within 
a Python application module.

On Windows, I have succeeded in running an application module 
like the one described with the same RS.call call to different 
versions of a wxApp R function within the same R session, but on 
Gtk/Linux, I have the feeling that I can only run one wx 
application per R-wxPython session.

If I avoid constructing a wx application in .First.lib and 
postpone it to a call to a MainLoop method later on, then I'll 
break all of the modal dialog code which is working now (they 
will give errors about Gtk not being initialized).

For some reason, wxPython on Windows allows you to use Show 
methods on frames and dialogs even when there is no official wx 
event loop running.  wxGTK is more strict about requiring an 
official event loop.

Hopefully, I'll be able to find a nice solution to these event 
loop issues and report its success soon!

Regards,
James



More information about the R-SIG-GUI mailing list