[R-gui] wxPython R GUI toolkit
James Wettenhall
wettenhall at wehi.edu.au
Wed May 5 13:38:08 CEST 2004
Greg and others,
Sorry if this seems like rehashing the past, but I'm trying to
at least cite actual examples, compilers etc. not just discuss
general GUI philosophies for the future...
Thanks very much for the tips on building wxWindows without
MS Visual C++. I was just put off initially by my failed
attempts to build wxWindows source code with MinGW from the
command-line.
In terms of using pre-built binaries and going through
Python, I think I'd now contradict my last email and look more
favorably upon wxPython (Python interface to wxWindows/wxWidgets),
as Dirk and Greg and others suggested. It has features FOX
doesn't yet have like Unicode and doesn't seem to crash as often
in my (very preliminary and extremely ignorant) tests. So I've
changed the email subject-line to wxPython.
Of course bringing in another scripting language (Python) is not
optimal, but it just seems like such a daunting task for anyone
to develop a direct R-wxWindows or R-FOX or R-... interface.
So going through Python (or similar) doesn't seem too bad
as a first step (as we can learn from R-Tcl/Tk).
So despite my initial pains of trying to build wxWindows from
source, I did find it quite easy to call a wxPython script
from RSPython:
library(RSPython)
importPythonModule("wxPython.wx")
.Python("wxHello",.module="wxHello")
[ "Hello World" WX window appears succesfully! ]
where the wxHello.py module is a GUI Hello-World wxPython
script within my python search path.
The python search path can be found with:
importPythonModule("sys")
.Python("path",.module="sys")
=================================================
wxHello.py
=================================================
from wxPython.wx import wxPySimpleApp, wxFrame
def wxHello():
app = wxPySimpleApp()
frame = wxFrame(None, -1, "Hello World")
frame.Show(1)
app.MainLoop()
=================================================
HOWEVER, I haven't had any luck so far with doing this step by
step from R. An example of what I tried is included below.
If anyone else feels like playing with RSPython / wxPython
and has any ideas, I would be most appreciative.
Regards,
James
Sys.putenv(PYTHONPATH="C:\\Python22")
library(RSPython)
# The first command I run in RSPython 0.4-0 (latest
# Win32 binary) always fails no matter what it is.
importPythonModule("wxPython.wx")
# Error in .PythonInit(warn = T) : Error in python call: A
# Python Exception Occurred.
importPythonModule("wxPython.wx")
app <- .Python("wxPySimpleApp",.module="wxPython.wx",.convert=F)
frame <- .PythonEval("wxFrame(None,-1,\"Hello World\")",
.module="wxPython.wx",.convert=F)
frame <- .Python("wxFrame",.module="wxPython.wx",.convert=F)
.PythonMethod(app,"SetTopWindow",(frame["id"]),.module="wxPython.wx",.convert=F)
.PythonMethod(frame,"Show",1,.module="wxPython.wx",.convert=F)
.PythonMethod(app,"MainLoop",.module="wxPython.wx",.convert=F)
# NOTHING HAPPENS :
# app.MainLoop() exits instantly with no apparent error, and
# without showing the "Hello World" window.
More information about the R-SIG-GUI
mailing list