Hi, I've been playing with an R-inteface to wxPython which has potential to be more powerful than Tcl/Tk. Currently it works on Windows, but so far, I haven't succeeded in getting it to work on Linux. I haven't tried MacOS X. http://bioinf.wehi.edu.au/folders/james/wxPython/ After I got back from useR!2004, I thought rather than emailing out straight away to let people know that my R-wxPython talk slides are available on the web, I would just wait until I got R-wxPython working on Linux (as well as Windows). "It should only take a day or two", I thought. Now, a few weeks later, I feel like I am still making progress, but it is very slow progress, so if there are any Linux-minded people out there who feel like collaborating, I would be very happy to work with you. On Windows, you can just install Python, wxPython and RSPython from binaries, but it's a different story on Linux :-( Here's how to get as far as I've got to date on Linux for R-wxPython: 1. Install R with the shared library enabled. (This can be done with "configure --enable-shlib" when installing R from source. The shared library will normally appear in /usr/local/lib/R/bin/libR.so) 2. Install Python 2.2.x from source. (RSPython doesn't seem to like 2.3.x, so don't install that. The reason I say to install from source, is that you will need to create a python shared library: libpython2.2.so, and this doesn't seem to be distributed in the python RPM.) 3. Install RSPython 0.5-3 or later, being careful to link it with the shared Python library, not a static library. Check that RSPython.so depends on libpython2.2.so using "ldd RSPython.so", and check that you have an RSInternal.so symbolic link to RSPython.so in the R/library/RSPython/libs/ directory. To get RSPython to link to libpython2.2.so, you may have to override the automatic configure script, e.g. "mv configure DONTconfigure" and manually edit Makefile, Makevars, src/Makevars etc. 4. Build wxPython 2.5.x from source (by first building wxWidgets, distributed with wxPythonSrc). You need to modify wxPython/config.py as follows: (i) Change self.root = "" to self.root = None (ii) Change newLFLAGS=[] to newLFLAGS = ['libpython2.2.so'] Copy libpython2.2.so to the wxPythonSrc/wxPython directory. Note that you probably don't need all of the optional-extras like OpenGL support, so you can build with "python setup.py build CORE_ONLY=1" or "python setup.py install CORE_ONLY=1" to just install the essentials. 5. Make sure that the new shared libraries are included in LD_LIBRARY_PATH and have been registered with /sbin/ldconfig. Some Linux systems allow you to do this without root privileges, while others don't. I don't have a root password, so I work mostly in my home area: ~/usr/ etc. but occasionally I need to ask for help from root. 6. Run ldd on the wxPython shared libraries in /usr/local/lib/python2.2/site-packages/wx/ or wherever, to check that they depend on libpython2.2.so, otherwise you will get errors like "Undefined symbol PyExc_IOError". In R, type: library(RSPython) Ignore the following warning: "the Python callback manager has been registered implicitly using the defaults (referenceManager())!" [We will use the wxPython 2.4.x method of importing the wx module. In order understand the difference between importPythonModule("wxPython.wx") and importPythonModule("wx"), please read: http://www.wxpython.org/migrationguide.php ] Try importing the wxPython.wx module: importPythonModule("wxPython.wx") If it returns NULL with no errors, then it succeeded. If it cannot be found, check your PYTHONPATH environment variable, and if necessary, modify the Python search path within R as follows: importPythonModule("sys") .Python("path",.module="sys") # Check the current Python path. path <- "/usr/local/lib/python2.2/site-packages/wx" .PythonEval(paste("path.append('",path,"')",sep=""),.module="sys") # Repeat for other paths you want to add. Now create a simple wxPython module, testRwxPy.py : ----------------------------- import wxPython.wx from wxPython.wx import * def wxRPyApp(): app = wxApp() return app ----------------------------- Make sure testRwxPy.py can be found in your Python search path, (using the technique above) and try: .Python("wxRPyApp",.module="testRwxPy") When running under R -d gdb, I get a segmentation fault which appears to come from gdk_init_check(). :-( A few clues from Googling "gdk_init_check segmentation fault" and from running strace on R, suggested that it could make a difference whether I am running X11 from a remote Linux machine or actually sitting in front of the Linux machine. I normally run Linux with XWin32 from Windows. I am also trying to do some testing on a Linux machine which I am actually sitting in front of directly, but haven't been able to run ldconfig without root access. I will ask my administrator to do it when he has a chance. I hope this is of interest to a least some people on the list. Regards, James -------------------------------------------------------------------------- James Wettenhall Tel: (+61 3) 9345 2629 Division of Genetics and Bioinformatics Fax: (+61 3) 9347 0852 The Walter & Eliza Hall Institute E-mail: wettenhall@wehi.edu.au of Medical Research, Mobile: (+61 / 0 ) 438 527 921 1G Royal Parade, Parkville, Vic 3050, Australia http://www.wehi.edu.au
[R-gui] R-wxPython
24 messages · Dirk Eddelbuettel, Vaidotas Zemlys, Duncan Temple Lang +3 more
1 day later
Hi,
1. Install R with the shared library enabled. (This can be
done with "configure --enable-shlib" when installing R
from source. The shared library will normally appear in
/usr/local/lib/R/bin/libR.so)
In Debian this library comes with R package.
2. Install Python 2.2.x from source. (RSPython doesn't seem to
like 2.3.x, so don't install that. The reason I say to
install from source, is that you will need to create a
python shared library: libpython2.2.so, and this doesn't
seem to be distributed in the python RPM.)
I'm running Debian Sid and on my system python2.1, python2.2 and python2.3 are installed with their respective so libraries.
3. Install RSPython 0.5-3 or later, being careful to link it
with the shared Python library, not a static library.
Check that RSPython.so depends on libpython2.2.so using
"ldd RSPython.so", and check that you have an
RSInternal.so symbolic link to RSPython.so in the
R/library/RSPython/libs/ directory. To get RSPython
to link to libpython2.2.so, you may have to override the
automatic configure script, e.g.
"mv configure DONTconfigure" and manually edit Makefile,
Makevars, src/Makevars etc.
Fortunately I didn't have to change anything, except changing symlin /usr/bin/ python to point to /usr/bin/python2.2.
4. Build wxPython 2.5.x from source (by first building
wxWidgets, distributed with wxPythonSrc). You need to modify
wxPython/config.py as follows:
(i) Change self.root = "" to self.root = None
(ii) Change newLFLAGS=[] to
newLFLAGS = ['libpython2.2.so']
Copy libpython2.2.so to the wxPythonSrc/wxPython directory.
Note that you probably don't need all of the
optional-extras like OpenGL support, so you can build with
"python setup.py build CORE_ONLY=1" or
"python setup.py install CORE_ONLY=1" to just install the
essentials.
I've installed everything by using python2.2 setup.py install --root=/usr/local/ WX_CONFIG=$WX_CONFIG WXPORT=gtk2 UNICODE=1 and then copying respective files to /usr/local/lib/python2.2/site-packages/, because contrary to manual in http://www.wxpython.org/INSTALL.html everything was installed in directory /usr/local/usr/ instead of /usr/local.
5. Make sure that the new shared libraries are included in
LD_LIBRARY_PATH and have been registered with
/sbin/ldconfig. Some Linux systems allow you to do this
without root privileges, while others don't. I don't
have a root password, so I work mostly in my home area:
~/usr/ etc. but occasionally I need to ask for help from
root.
6. Run ldd on the wxPython shared libraries in
/usr/local/lib/python2.2/site-packages/wx/ or wherever,
to check that they depend on libpython2.2.so, otherwise you
will get errors like "Undefined symbol PyExc_IOError".
In R, type:
library(RSPython)
Ignore the following warning:
"the Python callback manager has been registered implicitly
using the defaults (referenceManager())!"
[We will use the wxPython 2.4.x method of importing the wx
module. In order understand the difference between
importPythonModule("wxPython.wx") and importPythonModule("wx"),
please read:
http://www.wxpython.org/migrationguide.php ]
Try importing the wxPython.wx module:
importPythonModule("wxPython.wx")
If it returns NULL with no errors, then it succeeded. If it
cannot be found, check your PYTHONPATH environment variable,
and if necessary, modify the Python search path within R
as follows:
importPythonModule("sys")
.Python("path",.module="sys") # Check the current Python path.
path <- "/usr/local/lib/python2.2/site-packages/wx"
.PythonEval(paste("path.append('",path,"')",sep=""),.module="sys")
# Repeat for other paths you want to add.
In my case .Python("path",.module="sys") produced
[1] "/usr/local/lib/R/site-library/RSPython/Python"
[2] "/usr/local/lib/R/site-library/RSPython/libs"
[3] "/usr/lib/python2.2"
[4] "/usr/lib/python2.2/plat-linux2"
[5] "/usr/lib/python2.2/lib-tk"
[6] "/usr/lib/python2.2/lib-dynload"
[7] "/usr/local/lib/python2.2/site-packages"
[8] "/usr/lib/python2.2/site-packages"
[9] "/usr/lib/python2.2/site-packages/Numeric"
[10] "/usr/lib/python2.2/site-packages/gtk-2.0"
[11] "/usr/lib/site-python"
and importPythonModule("wxPython.wx") worked, without changing anything.
Now create a simple wxPython module, testRwxPy.py :
-----------------------------
import wxPython.wx
from wxPython.wx import *
def wxRPyApp():
app = wxApp()
return app
-----------------------------
Make sure testRwxPy.py can be found in your Python search path,
(using the technique above) and try:
.Python("wxRPyApp",.module="testRwxPy")
When running under R -d gdb, I get a segmentation fault which
appears to come from gdk_init_check(). :-(
I got Failing in conversion from Python object: Unhandled case! NULL and no segmentation fault. Is this suppose to happen or not? Feel free to ask for any details. Hope this report helps somehow. Vaidotas Zemlys
Hi Vaidotas, Thanks very much for your report about installing R, wxPython etc. on Debian. I should mention that I have also been discussing this on the wxPython-users mailing list. I've included a recent post by Robin Dunn below. I'll definitely follow this up soon, but I'm a little busy at the moment, preparing for a microarray workshop at IBC in Cairns. Best regards, James Date: Tue, 15 Jun 2004 12:32:25 -0700 To: wxPython-users@lists.wxwidgets.org From: Robin Dunn <robin@alldunn.com> Subject: Re: [wxPython-users] R-wxPython, gdk_init_check() seg. fault Message-ID: <40CF4EC9.5070805@alldunn.com>
James Wettenhall wrote:
Now I can import the Python module wxPython.wx (or wx) without errors, but when I try to run a trivial application which just starts a wxApp() and does nothing else, I get a segmentation
fault.
import wxPython.wx
from wxPython.wx import *
def wxRPyApp():
app = wxApp()
return app
Running R in debug mode (R -d gdb) reveals that
gdk_init_check()
from libgdk-1.2.so.0 is crashing with a segmentation fault.
I have an idea of what the problem may be, but I need you to confirm it since I can't duplicate the symptom here. Please place a debugger breakpoint in the wxPyApp::_BootstrapApp function and step down to the call to wxEntryStart. Is the value of argv NULL? -- Robin Dunn Software Craftsman http://wxPython.org Java give you jitters? Relax with wxPython!
4 days later
Hi guys,
I'm making very small progress with R-wxPython on Linux, but I
think my latest progression is quite significant - I can now
load:
library(wxPython)
which initializes a wxPython application and a wxPython frame,
and I can then create wx message boxes from the R command line,
from e.g.
wxMessageBox("Hello!")
The problem I was having before appears to be a bug in
wxPythonSrc-2.5.1.5/wxPython/src/helpers.cpp
In the function
wxPyApp::_BootstrapApp()
the value of argv passed to wxEntryStart was NULL.
A quick and dirty fix which worked for me was:
//PyObject* sysargv = PySys_GetObject("argv");
PyObject* sysargv = Py_BuildValue("[s]", "");
All I can do is message boxes so far. I'm getting some other
errors, but I should start making more rapid progress now!
Best regards,
James
James,
On Sun, Jun 20, 2004 at 11:51:09PM +1000, James Wettenhall wrote:
Hi guys,
I'm making very small progress with R-wxPython on Linux, but I
think my latest progression is quite significant - I can now
load:
library(wxPython)
which initializes a wxPython application and a wxPython frame,
and I can then create wx message boxes from the R command line,
from e.g.
wxMessageBox("Hello!")
The problem I was having before appears to be a bug in
wxPythonSrc-2.5.1.5/wxPython/src/helpers.cpp
In the function
wxPyApp::_BootstrapApp()
the value of argv passed to wxEntryStart was NULL.
A quick and dirty fix which worked for me was:
//PyObject* sysargv = PySys_GetObject("argv");
PyObject* sysargv = Py_BuildValue("[s]", "");
All I can do is message boxes so far. I'm getting some other
errors, but I should start making more rapid progress now!
Very, very nice. I'd love to help but am quite tied up. I also saw Vaidotas email regarding some success on Debian. Keep it coming, hopefully I'll have some more time to help with tests at some point. Dirk
FEATURE: VW Beetle license plate in California
2 days later
Hi,
I'm making very small progress with R-wxPython on Linux, but I
think my latest progression is quite significant - I can now
load:
library(wxPython)
which initializes a wxPython application and a wxPython frame,
and I can then create wx message boxes from the R command line,
from e.g.
wxMessageBox("Hello!")
The problem I was having before appears to be a bug in
wxPythonSrc-2.5.1.5/wxPython/src/helpers.cpp
In the function
wxPyApp::_BootstrapApp()
the value of argv passed to wxEntryStart was NULL.
A quick and dirty fix which worked for me was:
//PyObject* sysargv = PySys_GetObject("argv");
PyObject* sysargv = Py_BuildValue("[s]", "");
All I can do is message boxes so far. I'm getting some other
errors, but I should start making more rapid progress now!
I've applied your patch recompiled and reinstalled wxPython (only wxPython, not wx library). This time I used debug support: python2.2 setup.py build_ext --inplace --debug WX_CONFIG=/usr/local/share/ wx/2.5/bin/wx-config WXPORT=gtk2 UNICODE=1 Now
.Python("wxRPyApp",.module="testRwxPy")
in R results in 18:20:39: Debug: Adding duplicate image handler for 'Windows bitmap file' 18:20:39: Debug: Adding duplicate image handler for 'Windows bitmap file' Failing in conversion from Python object: Unhandled case! NULL Is this suppose to happen? Vaidotas
Vaidotas Zemlys wrote:
Hi,
I'm making very small progress with R-wxPython on Linux, but I
think my latest progression is quite significant - I can now
load:
library(wxPython)
which initializes a wxPython application and a wxPython frame,
and I can then create wx message boxes from the R command line,
from e.g.
wxMessageBox("Hello!")
The problem I was having before appears to be a bug in
wxPythonSrc-2.5.1.5/wxPython/src/helpers.cpp
In the function
wxPyApp::_BootstrapApp()
the value of argv passed to wxEntryStart was NULL.
A quick and dirty fix which worked for me was:
//PyObject* sysargv = PySys_GetObject("argv");
PyObject* sysargv = Py_BuildValue("[s]", "");
All I can do is message boxes so far. I'm getting some other
errors, but I should start making more rapid progress now!
I've applied your patch recompiled and reinstalled wxPython (only wxPython, not wx library). This time I used debug support: python2.2 setup.py build_ext --inplace --debug WX_CONFIG=/usr/local/share/ wx/2.5/bin/wx-config WXPORT=gtk2 UNICODE=1 Now
.Python("wxRPyApp",.module="testRwxPy")
in R results in 18:20:39: Debug: Adding duplicate image handler for 'Windows bitmap file' 18:20:39: Debug: Adding duplicate image handler for 'Windows bitmap file' Failing in conversion from Python object: Unhandled case! NULL Is this suppose to happen?
Yes and no. It is happening in the interface between Python and R and it means that it is dealing with transferring a Python object back to R. In this particular case, it is one of the "less usual" but basic types and the current RSPython code says that it is not prepared to deal with that. Can either of you tell me the Python type of the object being converted? (You can put a break point in fromPython() in RPythonConverters.c at the appropriate line (116 in my version).) That would help me a great deal as a I can probably easily add code for that case but want to know what it is and I am in the middle of some other work right now so don't have the time to set this up to debug it.
Vaidotas
_______________________________________________ R-SIG-GUI mailing list R-SIG-GUI@stat.math.ethz.ch https://www.stat.math.ethz.ch/mailman/listinfo/r-sig-gui
Duncan Temple Lang duncan@wald.ucdavis.edu 371, Kerr Hall University of California at Davis Phone: (530) 752-4782 FAX: (530) 752-7099
Hi,
Yes and no. It is happening in the interface between Python and R and it means that it is dealing with transferring a Python object back to R. In this particular case, it is one of the "less usual" but basic types and the current RSPython code says that it is not prepared to deal with that. Can either of you tell me the Python type of the object being converted? (You can put a break point in fromPython() in RPythonConverters.c at the appropriate line (116 in my version).) That would help me a great deal as a I can probably easily add code for that case but want to know what it is and I am in the middle of some other work right now so don't have the time to set this up to debug it.
I set up the breakpoint and got to it. How do I check the Python type of the object? I know nothing about Python. Vaidotas
Hi,
Can either of you tell me the Python type of the object being converted? (You can put a break point in fromPython() in RPythonConverters.c at the appropriate line (116 in my version).) That would help me a great deal as a I can probably easily add code for that case but want to know what it is and I am in the middle of some other work right now so don't have the time to set this up to debug it.
Is this it?
(gdb) print *pyobj
$2 = {ob_refcnt = 3, ob_type = 0x92f9684}
Vaidotas
Hi,
Yes and no. It is happening in the interface between Python and R and it means that it is dealing with transferring a Python object back to R. In this particular case, it is one of the "less usual" but basic types and the current RSPython code says that it is not prepared to deal with that. Can either of you tell me the Python type of the object being converted? (You can put a break point in fromPython() in RPythonConverters.c at the appropriate line (116 in my version).) That would help me a great deal as a I can probably easily add code for that case but want to know what it is and I am in the middle of some other work right now so don't have the time to set this up to debug it.
I set up the breakpoint and got to it. How do I check the Python type of the object? I know nothing about Python.
For the poor souls googling out there, the answer is (gdb) print *(pyobj->ob_type) Vaidotas
Hi Vaidotas,
Duncan may have answered your question already, but you should
be aware of the .convert argument of the .Python() function.
Using .convert=FALSE in .Python() should help to avoid errors
from RSPython like "Failing in conversion..."
An R-Tcl/Tk analogy is the following:
result <- tkmessageBox(message="Hello")
After clicking OK, result is an object of class "tclObj", and we
can find its value ("ok") using tclvalue(result).
So
result <- tkmessageBox(message="Hello")
is similar to using .convert=FALSE in RSPython's .Python()
and
result <- tclvalue(tkmessgaeBox(message="Hello"))
is similar to using .convert=TRUE in RSPython's .Python()
Hope this helps,
James
P.S. I really should come up with a better "patch" to
helpers.cpp than then one I mentioned before. Rather than
overwriting sysargv no matter what, I should only overwrite it
if its Python value is NULL.
Hi, I've mentioned before that when trying to run R-wxPython in Linux, you very quickly run up against some nasty dynamic linking issues, where RSPython can't find certain Python symbols in the wxPython shared libraries, so I had to rebuild wxPython linking against a Python shared library libpython2.2.so. But then if you want to use shared libraries distributed with Python, such as parser.so, you need to be aware that they are not linked against a libpython2.2.so by default either, so it is possible to get undefined Python symbols there as well. One workaround I am investigating is linking RSPython with: -Wl,-whole-archive -lpython -Wl,-no-whole-archive But I can't give R-wxPython much time this week, so I'd be happy if anyone else wants to start playing around with this idea before I do. Regards, James
Hi, Just forwarding from the wxPython-users list, Robin Dunn's reply to my confirmation that argv was NULl in wxPyApp::_BootstrapApp in helpers.cpp, so he will work out the best way to handle this case and possibly include a patch in the next version of wxPython. Regards, James ------------------------------ Date: Tue, 22 Jun 2004 10:54:59 -0700 To: wxPython-users@lists.wxwidgets.org From: Robin Dunn <robin@alldunn.com> Subject: Re: [wxPython-users] R-wxPython and gdk_init_check() seg. fault Message-ID: <40D87273.2090408@alldunn.com>
James Wettenhall wrote:
Hi Robin,
place a debugger breakpoint in the wxPyApp::_BootstrapApp function and step down to the call to wxEntryStart. Is the value of argv NULL?
Yes! Thanks so much!
Thanks for checking that for me. I've added an item to my ToDo to check for that situation and handle it properly. -- Robin Dunn Software Craftsman http://wxPython.org Java give you jitters? Relax with wxPython!
Hi,
I've mentioned before that when trying to run R-wxPython in Linux, you very quickly run up against some nasty dynamic linking issues, where RSPython can't find certain Python symbols in the wxPython shared libraries, so I had to rebuild wxPython linking against a Python shared library libpython2.2.so.
Could you please provide an example when this situation arises? I would gladly test it. Vaidotas
Hi Vaidotas,
On Wed, 23 Jun 2004, Vaidotas Zemlys wrote:
Could you please provide an example when this situation arises? I would gladly test it.
After building wxPython 2.5.1.5 from source on Fedora Linux, without editing config.py and adding libpython2.2.so to the newLFLAGS, I got an error like: "Undefined Symbol: PyExc_IOError" when I tried to import the wx module when Python was embedded within R. I tried building RSPython with a shared (instead of static) library, but this didn't seem to help, so I built wxPython linking against libpython2.2.so as well (editing config.py's newLFLAGS to inclue libpython2.2.so), and then I could import wx into Python embedded in R without problems. But now, when I try to run some code from my preliminary R-wxPython package at: http://bioinf.wehi.edu.au/folders/james/wxPython/ I get undefined symbols errors when I try to import the parser module, which is actually a shared library, see: rpm -ql python | grep "\\.so" /usr/lib/python2.2/lib-dynload/parsermodule.so OR I think it might be called "parser.so" rather than "parsermodule.so", depending on your Python version. Currently in my R-wxPython package, the parser module is used by the wxDialogPython() function which is called by: getMethod("wxShow","wxDialog") When I use "import parser", I get errors like: Error in Python call: /home/users/lab0605/wettenhall/usr/local/lib/python2.2/lib-dynload/parser.so: undefined symbol: _Py_TrueStruct One solution is just to remove all instances of "import parser". The only reason I use it is to use the Python 'exec' function to try register widgets/controls in a way that R can later access them, e.g. after creating a dialog, you might want to disable a particular checkbox from within R. Unfortunately, this widget-registering mechanism is not working yet, maybe due to my lack of understanding of RSPython and foreign object references, so I could just remove all instances of "import parser", but it would be nice to know why I get undefined symbol errors. I still haven't really had time to test building RSPython against python statically but using the whole-archive options to include as many symbols as possible in RSPython/libs/RSPython.so Regards, James
On Wed, 23 Jun 2004, Vaidotas Zemlys wrote:
Hi,
I've mentioned before that when trying to run R-wxPython in Linux, you very quickly run up against some nasty dynamic linking issues, where RSPython can't find certain Python symbols in the wxPython shared libraries, so I had to rebuild wxPython linking against a Python shared library libpython2.2.so.
Could you please provide an example when this situation arises? I would gladly test it. Vaidotas
_______________________________________________ R-SIG-GUI mailing list R-SIG-GUI@stat.math.ethz.ch https://www.stat.math.ethz.ch/mailman/listinfo/r-sig-gui
-------------------------------------------------------------------------- James Wettenhall Tel: (+61 3) 9345 2629 Division of Genetics and Bioinformatics Fax: (+61 3) 9347 0852 The Walter & Eliza Hall Institute E-mail: wettenhall@wehi.edu.au of Medical Research, Mobile: (+61 / 0 ) 438 527 921 1G Royal Parade, Parkville, Vic 3050, Australia http://www.wehi.edu.au
Hi,
But now, when I try to run some code from my preliminary R-wxPython package at: http://bioinf.wehi.edu.au/folders/james/wxPython/ I get undefined symbols errors when I try to import the parser module, which is actually a shared library, see: rpm -ql python | grep "\\.so" /usr/lib/python2.2/lib-dynload/parsermodule.so OR I think it might be called "parser.so" rather than "parsermodule.so", depending on your Python version. Currently in my R-wxPython package, the parser module is used by the wxDialogPython() function which is called by: getMethod("wxShow","wxDialog")
I've installed wxPython package and issued loaded wxPython library and called aforementioned function, here is an output that R gave me:
library(wxPython)
Creating a new generic function for "print" in "wxPython" Loading required package: RSPython Initialized R-Python interface package. Examples are available by typing: wxPythonUserManual() Warning message: the Python callback manager has been registered implicitly using the defaults (referenceManager())!
getMethod("wxShow","wxDialog")
Method Definition (Class "MethodDefinition"):
function (frm, ...)
{
.local <- function (frm, envir = parent.frame(n = 2))
{
frm <- wxDialogPython(frm, modal = FALSE)
wxRegisterWindow(frm, envir = envir)
return(frm)
}
.local(frm, ...)
}
<environment: 0x90a1d64>
Signatures:
frm
target "wxDialog"
defined "wxDialog"
No errors. Or there shouldn't be any?
When I use "import parser", I get errors like: Error in Python call: /home/users/lab0605/wettenhall/usr/local/lib/python2.2/lib-dynload/parser. so: undefined symbol: _Py_TrueStruct
How do you use "import parser"? What should I type into R to issue such kind of command? Vaidotas
Hi,
But now, when I try to run some code from my preliminary R-wxPython package at: http://bioinf.wehi.edu.au/folders/james/wxPython/ I get undefined symbols errors when I try to import the parser module, which is actually a shared library, see: rpm -ql python | grep "\\.so" /usr/lib/python2.2/lib-dynload/parsermodule.so OR I think it might be called "parser.so" rather than "parsermodule.so", depending on your Python version. Currently in my R-wxPython package, the parser module is used by the wxDialogPython() function which is called by: getMethod("wxShow","wxDialog")
Ok, I got some errors after all:) This excerpt from R-wxPython User Manual gave me the error that you was talking about:
dlg <- wxDlg(size=wxSize(200,160)) dlg <- wxAdd(dlg,cb=wxCheckBox(label="Use wxPython",name="usewxPython", pos=wxPoint(40,50))) dlg <- wxBind(dlg,"cb",function(checked)cbVal<<-checked,
+ event="EVT_CHECKBOX",eventMethod="Checked")
cbVal <- 0 # We haven't specified initial state of checkbox so by default it will be unchecked dlg <- wxShow(dlg)
Error in .PythonEval(paste("import ", dlg@PythonModule, "; reload(",
dlg@PythonModule, :
Error in Python call: /usr/lib/python2.2/lib-dynload/parser.so:
undefined symbol: _Py_TrueStruct
I'll try to recompile RSPython with the flags you suggested and report the
outcome.
Vaidotas
On Wed, 23 Jun 2004, Vaidotas Zemlys wrote:
getMethod("wxShow","wxDialog")
<snip>
No errors. Or there shouldn't be any?
No. There shouldn't be any errors. The only reason I mentioned
'getMethod' is that people on this list may not be familiar with
S4 object-oriented programming in R, using the methods package.
The R-wxPython interface I've been working on uses S4 methods,
so for example, when you type:
wxShow(dlg)
the method (i.e. function) called depends on the class of the
object "dlg". If dlg is of class "wxDialog", then the method called
will be the one described by getMethod("wxShow","wxDialog").
When you first start using S4 methods it can be difficult to
know how to see the code of an R method. (Usually you can just
type a function name and press Enter to see its code in R.) But
if it is an S4 method, then you have to use something like
'getMethod' to see the R code for that function.
Hope this explains my last email a bit better.
Regards,
James
Hi, After a bit of discussion about how to build Python from source so that parser.so etc. depend on libpython2.2.so, I now have a simpler next-step-forward for people interested in playing with R-wxPython - I've removed all dependency to the Python parser module in wxPython 2.2 at: http://bioinf.wehi.edu.au/folders/james/wxPython/ (One other change - I've replaced the "print" generic functions with "show". "show" is more S4-style.) There are certainly still some problems, maybe partly due to the fact that I'm trying to make an object-oriented GUI toolkit look imperative from the R command-line user's perspective. But aside from the problems, there's also some interesting progress! With R-wxPython 2.2, now I can run the "Choose GUI toolkit" example from the documentation, including a listbox with scrollbars, and two buttons. It doesn't actually appear straight away, but when I issue another wxPython command afterwards, like wxMessageBox("Hello"), then it appears (one command too late), but the buttons don't work. Same with the "Text Editor" example - if I follow it with a call to wxMessageBox() then it appears after the wxMessageBox() call, but at least it appears, so that's something! It's a bit hard to destroy these late-appearing windows/widgets - wxClose, wxDestroy don't seem to work yet on R-wxPython with Gtk/Linux, probably because of this 'delay' problem. But for me, running X11 from Windows via XWin32, there's always "End Task" from the Windows Task Manager to kill a window, (and similar for other OS's)! :) Regards, James -------------------------------------------------------------------------- James Wettenhall Tel: (+61 3) 9345 2629 Division of Genetics and Bioinformatics Fax: (+61 3) 9347 0852 The Walter & Eliza Hall Institute E-mail: wettenhall@wehi.edu.au of Medical Research, Mobile: (+61 / 0 ) 438 527 921 1G Royal Parade, Parkville, Vic 3050, Australia http://www.wehi.edu.au
2 days later
Hi,
Does anyone know a good way to get rid of warnings like:
Warning message:
calling par(new=) with no plot
when using an R plot function which calls plot.new()
(e.g. coplot) from within tkrplot?
For example:
library(tkrplot)
tt <- tktoplevel()
plotFun <- function() {
data(quakes)
coplot(lat ~ long | depth, data = quakes)
}
img <- tkrplot(tt,fun=plotFun)
Warning message:
calling par(new=) with no plot
tkpack(img)
The plot looks fine in the Tk window, but I'm just
wondering whether I can get rid of the warning message.
On a similar subject, does anyone have any general advice on
whether it is best to pass main="Plot Title" directly to the
plot function or whether it is best to use title() for ploting
within tkrplot? Or doesn't it matter? I'm having trouble
finding a reproducible example now, but I have experienced
errors like:
"Cannot set parameter main in high-level plot function",
and I wonder whether these errors are related to using tkrplot
and R2HTML's HTMLplot, rather than the regular R graphics device.
Regards,
James
James Wettenhall <wettenhall@wehi.edu.au> writes:
Hi,
Does anyone know a good way to get rid of warnings like:
Warning message:
calling par(new=) with no plot
when using an R plot function which calls plot.new()
(e.g. coplot) from within tkrplot?
For example:
library(tkrplot)
tt <- tktoplevel()
plotFun <- function() {
data(quakes)
coplot(lat ~ long | depth, data = quakes)
}
img <- tkrplot(tt,fun=plotFun)
Warning message:
calling par(new=) with no plot
tkpack(img)
The plot looks fine in the Tk window, but I'm just
wondering whether I can get rid of the warning message.
Hmm, the same wart appears if you just plot to a freshly opened X11 device (X11(); coplot(....)), nothing specific to tkrplot. I think I've seen this reported before, but I have forgotten what the recommended action was.
On a similar subject, does anyone have any general advice on whether it is best to pass main="Plot Title" directly to the plot function or whether it is best to use title() for ploting within tkrplot? Or doesn't it matter? I'm having trouble finding a reproducible example now, but I have experienced errors like: "Cannot set parameter main in high-level plot function",
Well, title just splats some text at a defined position on the plot, whereas main= requires cooperation from the high-level plot function. I can't recall examples of uncooperative plot functions either, but you should probably consider if there's a reason why those plots might not *want* to have a title...
and I wonder whether these errors are related to using tkrplot and R2HTML's HTMLplot, rather than the regular R graphics device.
Both are generic, I think.
O__ ---- Peter Dalgaard Blegdamsvej 3 c/ /'_ --- Dept. of Biostatistics 2200 Cph. N (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~~~~~~~~~ - (p.dalgaard@biostat.ku.dk) FAX: (+45) 35327907
1 day later
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
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@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
Hi,
On Mon, 14 Jun 2004, James Wettenhall wrote:
progress, but it is very slow progress, so if there are any Linux-minded people out there who feel like collaborating, I
It just occurred to me that after mentioning a desire for collaboration from "Linux-minded" people on the list, I got some very useful posts from Vaidotas Zemlys and Martin Elff, (and of course Robin Dunn on the wxPython-users mailing list). But now I have had a request for new features in R-wxPython on Windows (which is already quite advanced), but I've been spending all the time I have available for this project on porting to Linux (and eventually MacOS X?). So let me add that assistance is certainly welcome from "Windows-minded" people as well. The Windows version is already quite advanced. Would you like to help to add new features/documented examples such as Multiple Document Interfaces (MDI), or more advanced geometry management (widget layout) methods? I'm not worried about sharing credit for authoring the R-wxPython package. If you send me some useful reliable-looking code or documented examples, I be happy to add the code to the package, add your name as an author, and look forward to receiving more code snippets from you. Regards, James