From: <ds...@us...> - 2008-11-29 21:14:33
|
Revision: 6457 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6457&view=rev Author: dsdale Date: 2008-11-29 21:14:26 +0000 (Sat, 29 Nov 2008) Log Message: ----------- added support for leave_notify_event in backend_qt4 Modified Paths: -------------- trunk/matplotlib/lib/matplotlib/backends/backend_qt4.py Modified: trunk/matplotlib/lib/matplotlib/backends/backend_qt4.py =================================================================== --- trunk/matplotlib/lib/matplotlib/backends/backend_qt4.py 2008-11-29 02:20:56 UTC (rev 6456) +++ trunk/matplotlib/lib/matplotlib/backends/backend_qt4.py 2008-11-29 21:14:26 UTC (rev 6457) @@ -105,6 +105,9 @@ def __timerEvent(self, event): # hide until we can test and fix self.mpl_idle_event(event) + + def leaveEvent(self, event): + FigureCanvasBase.leave_notify_event(self, event) def mousePressEvent( self, event ): x = event.pos().x() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ds...@us...> - 2008-12-02 22:04:45
|
Revision: 6478 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6478&view=rev Author: dsdale Date: 2008-12-02 22:04:41 +0000 (Tue, 02 Dec 2008) Log Message: ----------- removed lingering print statement Modified Paths: -------------- trunk/matplotlib/lib/matplotlib/backends/backend_qt4.py Modified: trunk/matplotlib/lib/matplotlib/backends/backend_qt4.py =================================================================== --- trunk/matplotlib/lib/matplotlib/backends/backend_qt4.py 2008-12-02 20:09:44 UTC (rev 6477) +++ trunk/matplotlib/lib/matplotlib/backends/backend_qt4.py 2008-12-02 22:04:41 UTC (rev 6478) @@ -110,7 +110,6 @@ FigureCanvasBase.enter_notify_event(self, event) def leaveEvent(self, event): - print event FigureCanvasBase.leave_notify_event(self, event) def mousePressEvent( self, event ): This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ry...@us...> - 2010-04-20 19:42:11
|
Revision: 8252 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8252&view=rev Author: ryanmay Date: 2010-04-20 19:42:05 +0000 (Tue, 20 Apr 2010) Log Message: ----------- Add TimerQT and new_timer() method. Modified Paths: -------------- trunk/matplotlib/lib/matplotlib/backends/backend_qt4.py Modified: trunk/matplotlib/lib/matplotlib/backends/backend_qt4.py =================================================================== --- trunk/matplotlib/lib/matplotlib/backends/backend_qt4.py 2010-04-20 19:41:38 UTC (rev 8251) +++ trunk/matplotlib/lib/matplotlib/backends/backend_qt4.py 2010-04-20 19:42:05 UTC (rev 8252) @@ -7,7 +7,8 @@ from matplotlib import verbose from matplotlib.cbook import is_string_like, onetrue from matplotlib.backend_bases import RendererBase, GraphicsContextBase, \ - FigureManagerBase, FigureCanvasBase, NavigationToolbar2, IdleEvent, cursors + FigureManagerBase, FigureCanvasBase, NavigationToolbar2, IdleEvent, \ + cursors, TimerBase from matplotlib._pylab_helpers import Gcf from matplotlib.figure import Figure from matplotlib.mathtext import MathTextParser @@ -83,6 +84,46 @@ return manager +class TimerQT(TimerBase): + ''' + Subclass of :class:`backend_bases.TimerBase` that uses Qt4 timer events. + + Attributes: + * interval: The time between timer events in milliseconds. Default + is 1000 ms. + * single_shot: Boolean flag indicating whether this timer should + operate as single shot (run once and then stop). Defaults to False. + * callbacks: Stores list of (func, args) tuples that will be called + upon timer events. This list can be manipulated directly, or the + functions add_callback and remove_callback can be used. + ''' + def __init__(self): + from PyQt4.QtCore import QObject, SIGNAL, QTimer + TimerBase.__init__(self) + + # Create a new timer and connect the timeout() signal to the + # _on_timer method. + self._timer = QTimer() + QObject.connect(self._timer, SIGNAL('timeout()'), self._on_timer) + + def __del__(self): + # Probably not necessary in practice, but is good behavior to disconnect + TimerBase.__del__(self) + QObject.disconnect(self._timer , SIGNAL('timeout()'), self._on_timer) + + def _timer_set_single_shot(self): + self._timer.setSingleShot(self._single) + + def _timer_set_interval(self): + self._timer.setInterval(self._interval) + + def _timer_start(self): + self._timer.start() + + def _timer_stop(self): + self._timer.stop() + + class FigureCanvasQT( QtGui.QWidget, FigureCanvasBase ): keyvald = { QtCore.Qt.Key_Control : 'control', QtCore.Qt.Key_Shift : 'shift', @@ -190,6 +231,14 @@ return key + def new_timer(self): + """ + Creates a new backend-specific subclass of + :class:`backend_bases.TimerBase`. This is useful for getting periodic + events through the backend's native event loop. + """ + return TimerQT() + def flush_events(self): Qt.qApp.processEvents() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ry...@us...> - 2010-04-20 19:58:16
|
Revision: 8255 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8255&view=rev Author: ryanmay Date: 2010-04-20 19:58:10 +0000 (Tue, 20 Apr 2010) Log Message: ----------- Use global import of PyQt4 instead of a local one. Modified Paths: -------------- trunk/matplotlib/lib/matplotlib/backends/backend_qt4.py Modified: trunk/matplotlib/lib/matplotlib/backends/backend_qt4.py =================================================================== --- trunk/matplotlib/lib/matplotlib/backends/backend_qt4.py 2010-04-20 19:43:01 UTC (rev 8254) +++ trunk/matplotlib/lib/matplotlib/backends/backend_qt4.py 2010-04-20 19:58:10 UTC (rev 8255) @@ -98,18 +98,19 @@ functions add_callback and remove_callback can be used. ''' def __init__(self): - from PyQt4.QtCore import QObject, SIGNAL, QTimer TimerBase.__init__(self) # Create a new timer and connect the timeout() signal to the # _on_timer method. - self._timer = QTimer() - QObject.connect(self._timer, SIGNAL('timeout()'), self._on_timer) + self._timer = QtCore.QTimer() + QtCore.QObject.connect(self._timer, QtCore.SIGNAL('timeout()'), + self._on_timer) def __del__(self): # Probably not necessary in practice, but is good behavior to disconnect TimerBase.__del__(self) - QObject.disconnect(self._timer , SIGNAL('timeout()'), self._on_timer) + QtCore.QObject.disconnect(self._timer , QtCore.SIGNAL('timeout()'), + self._on_timer) def _timer_set_single_shot(self): self._timer.setSingleShot(self._single) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <md...@us...> - 2010-06-15 13:01:29
|
Revision: 8436 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8436&view=rev Author: mdboom Date: 2010-06-15 13:01:22 +0000 (Tue, 15 Jun 2010) Log Message: ----------- Support the "Enter" key event in the Qt4 backend. Modified Paths: -------------- trunk/matplotlib/lib/matplotlib/backends/backend_qt4.py Modified: trunk/matplotlib/lib/matplotlib/backends/backend_qt4.py =================================================================== --- trunk/matplotlib/lib/matplotlib/backends/backend_qt4.py 2010-06-14 05:51:06 UTC (rev 8435) +++ trunk/matplotlib/lib/matplotlib/backends/backend_qt4.py 2010-06-15 13:01:22 UTC (rev 8436) @@ -129,6 +129,7 @@ keyvald = { QtCore.Qt.Key_Control : 'control', QtCore.Qt.Key_Shift : 'shift', QtCore.Qt.Key_Alt : 'alt', + QtCore.Qt.Key_Return : 'enter' } # left 1, middle 2, right 3 buttond = {1:1, 2:3, 4:2} @@ -314,16 +315,19 @@ self.window._destroying = False self.toolbar = self._get_toolbar(self.canvas, self.window) - self.window.addToolBar(self.toolbar) - QtCore.QObject.connect(self.toolbar, QtCore.SIGNAL("message"), - self.window.statusBar().showMessage) + if self.toolbar is not None: + self.window.addToolBar(self.toolbar) + QtCore.QObject.connect(self.toolbar, QtCore.SIGNAL("message"), + self.window.statusBar().showMessage) + tbs_height = self.toolbar.sizeHint().height() + else: + tbs_height = 0 # resize the main window so it will display the canvas with the # requested size: cs = canvas.sizeHint() - tbs = self.toolbar.sizeHint() sbs = self.window.statusBar().sizeHint() - self.window.resize(cs.width(), cs.height()+tbs.height()+sbs.height()) + self.window.resize(cs.width(), cs.height()+tbs_height+sbs.height()) self.window.setCentralWidget(self.canvas) @@ -335,7 +339,8 @@ def notify_axes_change( fig ): # This will be called whenever the current axes is changed - if self.toolbar != None: self.toolbar.update() + if self.toolbar is not None: + self.toolbar.update() self.canvas.figure.add_axobserver( notify_axes_change ) def _widgetclosed( self ): This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ef...@us...> - 2010-08-27 07:13:20
|
Revision: 8664 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8664&view=rev Author: efiring Date: 2010-08-27 07:13:14 +0000 (Fri, 27 Aug 2010) Log Message: ----------- backend_qt4: don't make app if ipython already made it; patch by Brian Granger Modified Paths: -------------- trunk/matplotlib/lib/matplotlib/backends/backend_qt4.py Modified: trunk/matplotlib/lib/matplotlib/backends/backend_qt4.py =================================================================== --- trunk/matplotlib/lib/matplotlib/backends/backend_qt4.py 2010-08-26 03:49:17 UTC (rev 8663) +++ trunk/matplotlib/lib/matplotlib/backends/backend_qt4.py 2010-08-27 07:13:14 UTC (rev 8664) @@ -50,11 +50,16 @@ if QtGui.QApplication.startingUp(): if DEBUG: print "Starting up QApplication" global qApp - qApp = QtGui.QApplication( [" "] ) - QtCore.QObject.connect( qApp, QtCore.SIGNAL( "lastWindowClosed()" ), - qApp, QtCore.SLOT( "quit()" ) ) - #remember that matplotlib created the qApp - will be used by show() - _create_qApp.qAppCreatedHere = True + app = QtGui.QApplication.instance() + if app is None: + qApp = QtGui.QApplication( [" "] ) + QtCore.QObject.connect( qApp, QtCore.SIGNAL( "lastWindowClosed()" ), + qApp, QtCore.SLOT( "quit()" ) ) + #remember that matplotlib created the qApp - will be used by show() + _create_qApp.qAppCreatedHere = True + else: + qApp = app + _create_qApp.qAppCreatedHere = False _create_qApp.qAppCreatedHere = False This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ef...@us...> - 2011-02-06 07:47:49
|
Revision: 8952 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8952&view=rev Author: efiring Date: 2011-02-06 07:47:43 +0000 (Sun, 06 Feb 2011) Log Message: ----------- backend_qt4.py: eliminate unnecessary import of Qt; closes [3108017] Modified Paths: -------------- trunk/matplotlib/lib/matplotlib/backends/backend_qt4.py Modified: trunk/matplotlib/lib/matplotlib/backends/backend_qt4.py =================================================================== --- trunk/matplotlib/lib/matplotlib/backends/backend_qt4.py 2011-02-06 05:06:46 UTC (rev 8951) +++ trunk/matplotlib/lib/matplotlib/backends/backend_qt4.py 2011-02-06 07:47:43 UTC (rev 8952) @@ -18,7 +18,7 @@ import matplotlib.backends.qt4_editor.figureoptions as figureoptions try: - from PyQt4 import QtCore, QtGui, Qt + from PyQt4 import QtCore, QtGui except ImportError: raise ImportError("Qt4 backend requires that PyQt4 is installed.") @@ -248,7 +248,7 @@ return TimerQT(*args, **kwargs) def flush_events(self): - Qt.qApp.processEvents() + QtGui.qApp.processEvents() def start_event_loop(self,timeout): FigureCanvasBase.start_event_loop_default(self,timeout) @@ -272,13 +272,13 @@ # http://old.nabble.com/Qt4-backend:-critical-bug-with-PyQt4-v4.6%2B-td26205716.html # Once a release of Qt/PyQt is available without the bug, the version check # below can be tightened further to only be applied in the necessary versions. -if Qt.PYQT_VERSION_STR.startswith('4.6'): +if QtCore.PYQT_VERSION_STR.startswith('4.6'): class FigureWindow(QtGui.QMainWindow): def __init__(self): super(FigureWindow, self).__init__() def closeEvent(self, event): super(FigureWindow, self).closeEvent(event) - self.emit(Qt.SIGNAL('destroyed()')) + self.emit(QtCore.SIGNAL('destroyed()')) else: FigureWindow = QtGui.QMainWindow # /end pyqt hackish bugfix This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |