+"""This module runs continuous updates for R, such as redrawing graphs when
+the plot window is resized. Use the start() and stop() functions to turn
+Importing the module currently starts updates.
from rpy2.rinterface import process_revents
+# If this is True, start updates when the module is imported
+ """The thread for processing R events. Use the module's start() and stop()
+ functions to switch it on and off. If you interact with this class
+ directly, it's up to you to ensure you don't start several of them."""
- def __init__(self
- self.interval =
-def start(interval = 0.2):
- eventthread = _ReventThread(interval)
+_eventthread = _ReventThread()
+ """Start running continuous updates of plots etc. Specifying interval
+ defines how often it will update. The default is every 0.2 seconds.
+ If updates are already running, this will just change the interval."""
+ _eventthread.interval = interval
+ if _eventthread.is_alive():
+ """Stop continuous updates. If updates aren't running, this will do
+ if not _eventthread.is_alive():
+ # Create a new thread so it can be started again
+ _eventthread = _ReventThread()