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

Martin Elff elff at uni-mannheim.de
Mon Jun 28 01:21:20 CEST 2004


Am Sonntag, 27. Juni 2004 19:09 schrieb James Wettenhall:
> 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.  
Maybe these have their own event loops ...
> 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!

I 've been playing around with an R-Python interface
that doesn't segfault with Python 2.3 on Linux and also with
an wxPython interface. I found the following
trick from tcltk.c working ...

Hope that helps ...

Martin

>
> Regards,
> James
>
> _______________________________________________
> R-SIG-GUI mailing list
> R-SIG-GUI at stat.math.ethz.ch
> https://www.stat.math.ethz.ch/mailman/listinfo/r-sig-gui
-------------- next part --------------
A non-text attachment was scrubbed...
Name: wxRPyApp.py
Type: application/x-python
Size: 289 bytes
Desc: not available
Url : https://www.stat.math.ethz.ch/pipermail/r-sig-gui/attachments/20040628/cb50b3e7/wxRPyApp.bin
-------------- next part --------------
A non-text attachment was scrubbed...
Name: wxAppProc.c
Type: text/x-csrc
Size: 4559 bytes
Desc: not available
Url : https://www.stat.math.ethz.ch/pipermail/r-sig-gui/attachments/20040628/cb50b3e7/wxAppProc.bin


More information about the R-SIG-GUI mailing list