Re: [matplotlib-devel] Qt4 support for matplotlib
Oops. The earlier patch was reversed by accident. Here is the fixed patch. On Wednesday 05 July 2006 22:30, you wrote: > Hi all >I ported the QtAgg backend over to Qt4 and created a patch for adding > this backend to matplotlib with the name, Qt4Agg. I include it here, for > anyone interested. I also noticed an earlier message like this, seemingly > without resolution. Is there other- maybe, better- code for Qt4 available > somewhere? > > Kevin Mueller > Dept. Atmospheric Science, Univ. Illinois Urbana-Qt4Champaign diff -Naur matplotlib-0.87.3.old/lib/matplotlib/__init__.py matplotlib-0.87.3/lib/matplotlib/__init__.py --- matplotlib-0.87.3.old/lib/matplotlib/__init__.py 2006-07-05 22:02:14.0 -0500 +++ matplotlib-0.87.3/lib/matplotlib/__init__.py 2006-07-05 22:04:59.0 -0500 @@ -467,8 +467,8 @@ def validate_backend(s, fail_on_err = True): s=s.lower() backends = ['Agg2', 'Agg', 'Aqt', 'Cairo', 'CocoaAgg', 'EMF', 'GD', 'GDK', 'GTK', -'GTKAgg', 'GTKCairo', 'FltkAgg', 'Paint', 'Pdf', 'PS', 'QtAgg', 'SVG', -'Template', 'TkAgg', 'WX', 'WXAgg', ] +'GTKAgg', 'GTKCairo', 'FltkAgg', 'Paint', 'Pdf', 'PS', 'QtAgg', +'Qt4Agg', 'SVG', 'Template', 'TkAgg', 'WX', 'WXAgg', ] for i in backends: if s == i.lower(): return i if fail_on_err: raise ValueError('Backend must be %s, or %s'% \ diff -Naur matplotlib-0.87.3.old/lib/matplotlib/backends/__init__.py matplotlib-0.87.3/lib/matplotlib/backends/__init__.py --- matplotlib-0.87.3.old/lib/matplotlib/backends/__init__.py 2006-07-05 22:02:14.0 -0500 +++ matplotlib-0.87.3/lib/matplotlib/backends/__init__.py 2006-07-05 22:07:13.0 -0500 @@ -4,8 +4,8 @@ __all__ = ['backend','show','draw_if_interactive', 'new_figure_manager', 'backend_version'] -interactive_bk = ['GTK', 'GTKAgg', 'GTKCairo', 'FltkAgg', 'QtAgg', 'TkAgg', - 'WX', 'WXAgg', 'CocoaAgg', 'Aqt'] +interactive_bk = ['GTK', 'GTKAgg', 'GTKCairo', 'FltkAgg', 'QtAgg', 'Qt4Agg', + 'TkAgg', 'WX', 'WXAgg', 'CocoaAgg', 'Aqt'] non_interactive_bk = ['Agg2', 'Agg', 'Cairo', 'EMF', 'GD', 'GDK', 'Paint', 'Pdf', 'PS', 'SVG', 'Template'] all_backends = interactive_bk + non_interactive_bk diff -Naur matplotlib-0.87.3.old/lib/matplotlib/backends/backend_qt4.py matplotlib-0.87.3/lib/matplotlib/backends/backend_qt4.py --- matplotlib-0.87.3.old/lib/matplotlib/backends/backend_qt4.py 1969-12-31 18:00:00.0 -0600 +++ matplotlib-0.87.3/lib/matplotlib/backends/backend_qt4.py 2006-07-05 22:07:55.0 -0500 @@ -0,0 +1,340 @@ +from __future__ import division +import math +import os +import sys + +import matplotlib +from matplotlib import verbose +from matplotlib.numerix import asarray, fromstring, UInt8, zeros, \ + where, transpose, nonzero, indices, ones, nx +import matplotlib.numerix as numerix +from matplotlib.cbook import is_string_like, enumerate, onetrue +from matplotlib.font_manager import fontManager +from matplotlib.backend_bases import RendererBase, GraphicsContextBase, \ + FigureManagerBase, FigureCanvasBase, NavigationToolbar2, cursors +from matplotlib._pylab_helpers import Gcf +from matplotlib.figure import Figure +from matplotlib.mathtext import math_parse_s_ft2font + +from PyQt4 import QtCore, QtGui + +backend_version = "0.9.1" +def fn_name(): return sys._getframe(1).f_code.co_name + +DEBUG = False + +cursord = { +cursors.MOVE : QtCore.Qt.PointingHandCursor, +cursors.HAND : QtCore.Qt.WaitCursor, +cursors.POINTER : QtCore.Qt.ArrowCursor, +cursors.SELECT_REGION : QtCore.Qt.CrossCursor, +} + +def draw_if_interactive(): +""" +Is called after every pylab drawing command +""" +if matplotlib.is_interactive(): +figManager = Gcf.get_active() +if figManager != None: +figManager.canvas.draw() + +def show( mainloop=True ): +""" +Show all the figures and enter the qt main loop +This should be the last line of your script +""" +for manager in Gcf.get_all_fig_managers(): +manager.window.show() + +if DEBUG: print 'Inside show' +figManager = Gcf.get_active() +if figManager != None: +figManager.canvas.draw() +#if ( createQApp ): +# qtapplication.setMainWidget( figManager.canvas ) + +if mainloop and createQApp: +QtCore.QObject.connect( qtapplication, QtCore.SIGNAL( "lastWindowClosed()" ), +qtapplication, QtCore.SLOT( "quit()" ) ) +qtapplication.exec_() + + +def new_figure_manager( num, *args, **kwargs ): +""" +Create a new figure manager instance +""" +thisFig = Figure( *args, **kwargs ) +canvas = FigureCanvasQT( thisFig ) +manager = FigureManagerQT( canvas, num ) +return manager + + +class FigureCanvasQT( QtGui.QWidget, FigureCanvasBase ): +keyvald = { QtCore.Qt.Key_Control : 'control', +
[matplotlib-devel] Qt4 support for matplotlib
Hi all I ported the QtAgg backend over to Qt4 and created a patch for adding this backend to matplotlib with the name, Qt4Agg. I include it here, for anyone interested. I also noticed an earlier message like this, seemingly without resolution. Is there other- maybe, better- code for Qt4 available somewhere? Kevin Mueller Dept. Atmospheric Science, Univ. Illinois Urbana-Qt4Champaign diff -Naur matplotlib-0.87.3/lib/matplotlib/__init__.py matplotlib-0.87.3.old/lib/matplotlib/__init__.py --- matplotlib-0.87.3/lib/matplotlib/__init__.py 2006-07-05 22:04:59.0 -0500 +++ matplotlib-0.87.3.old/lib/matplotlib/__init__.py 2006-07-05 22:02:14.0 -0500 @@ -467,8 +467,8 @@ def validate_backend(s, fail_on_err = True): s=s.lower() backends = ['Agg2', 'Agg', 'Aqt', 'Cairo', 'CocoaAgg', 'EMF', 'GD', 'GDK', 'GTK', -'GTKAgg', 'GTKCairo', 'FltkAgg', 'Paint', 'Pdf', 'PS', 'QtAgg', -'Qt4Agg', 'SVG', 'Template', 'TkAgg', 'WX', 'WXAgg', ] +'GTKAgg', 'GTKCairo', 'FltkAgg', 'Paint', 'Pdf', 'PS', 'QtAgg', 'SVG', +'Template', 'TkAgg', 'WX', 'WXAgg', ] for i in backends: if s == i.lower(): return i if fail_on_err: raise ValueError('Backend must be %s, or %s'% \ diff -Naur matplotlib-0.87.3/lib/matplotlib/backends/__init__.py matplotlib-0.87.3.old/lib/matplotlib/backends/__init__.py --- matplotlib-0.87.3/lib/matplotlib/backends/__init__.py 2006-07-05 22:07:13.0 -0500 +++ matplotlib-0.87.3.old/lib/matplotlib/backends/__init__.py 2006-07-05 22:02:14.0 -0500 @@ -4,8 +4,8 @@ __all__ = ['backend','show','draw_if_interactive', 'new_figure_manager', 'backend_version'] -interactive_bk = ['GTK', 'GTKAgg', 'GTKCairo', 'FltkAgg', 'QtAgg', 'Qt4Agg', - 'TkAgg', 'WX', 'WXAgg', 'CocoaAgg', 'Aqt'] +interactive_bk = ['GTK', 'GTKAgg', 'GTKCairo', 'FltkAgg', 'QtAgg', 'TkAgg', + 'WX', 'WXAgg', 'CocoaAgg', 'Aqt'] non_interactive_bk = ['Agg2', 'Agg', 'Cairo', 'EMF', 'GD', 'GDK', 'Paint', 'Pdf', 'PS', 'SVG', 'Template'] all_backends = interactive_bk + non_interactive_bk diff -Naur matplotlib-0.87.3/lib/matplotlib/backends/backend_qt4.py matplotlib-0.87.3.old/lib/matplotlib/backends/backend_qt4.py --- matplotlib-0.87.3/lib/matplotlib/backends/backend_qt4.py 2006-07-05 22:07:55.0 -0500 +++ matplotlib-0.87.3.old/lib/matplotlib/backends/backend_qt4.py 1969-12-31 18:00:00.0 -0600 @@ -1,340 +0,0 @@ -from __future__ import division -import math -import os -import sys - -import matplotlib -from matplotlib import verbose -from matplotlib.numerix import asarray, fromstring, UInt8, zeros, \ - where, transpose, nonzero, indices, ones, nx -import matplotlib.numerix as numerix -from matplotlib.cbook import is_string_like, enumerate, onetrue -from matplotlib.font_manager import fontManager -from matplotlib.backend_bases import RendererBase, GraphicsContextBase, \ - FigureManagerBase, FigureCanvasBase, NavigationToolbar2, cursors -from matplotlib._pylab_helpers import Gcf -from matplotlib.figure import Figure -from matplotlib.mathtext import math_parse_s_ft2font - -from PyQt4 import QtCore, QtGui - -backend_version = "0.9.1" -def fn_name(): return sys._getframe(1).f_code.co_name - -DEBUG = False - -cursord = { -cursors.MOVE : QtCore.Qt.PointingHandCursor, -cursors.HAND : QtCore.Qt.WaitCursor, -cursors.POINTER : QtCore.Qt.ArrowCursor, -cursors.SELECT_REGION : QtCore.Qt.CrossCursor, -} - -def draw_if_interactive(): -""" -Is called after every pylab drawing command -""" -if matplotlib.is_interactive(): -figManager = Gcf.get_active() -if figManager != None: -figManager.canvas.draw() - -def show( mainloop=True ): -""" -Show all the figures and enter the qt main loop -This should be the last line of your script -""" -for manager in Gcf.get_all_fig_managers(): -manager.window.show() - -if DEBUG: print 'Inside show' -figManager = Gcf.get_active() -if figManager != None: -figManager.canvas.draw() -#if ( createQApp ): -# qtapplication.setMainWidget( figManager.canvas ) - -if mainloop and createQApp: -QtCore.QObject.connect( qtapplication, QtCore.SIGNAL( "lastWindowClosed()" ), -qtapplication, QtCore.SLOT( "quit()" ) ) -qtapplication.exec_() - - -def new_figure_manager( num, *args, **kwargs ): -""" -Create a new figure manager instance -""" -thisFig = Figure( *args, **kwargs ) -canvas = FigureCanvasQT( thisFig ) -manager = FigureManagerQT( canvas, num ) -return manager - - -class FigureCanvasQT( QtGui.QWidget, FigureCanvasBase ): -keyvald = { QtCore.Qt.Key_Control : 'control', -QtCore.Qt.Key_Shift : 'shift', -QtCore.Qt.Key_Alt : 'alt', - } -# left 1, middle 2, right 3 -
Re: [matplotlib-devel] Qt4 support for matplotlib
Hi Kevin, On Wednesday 05 July 2006 23:30, Kevin Mueller wrote: > Hi all >I ported the QtAgg backend over to Qt4 and created a patch for adding > this backend to matplotlib with the name, Qt4Agg. I include it here, for > anyone interested. I also noticed an earlier message like this, seemingly > without resolution. Is there other- maybe, better- code for Qt4 available > somewhere? There is a qt4agg backend in svn version of matplotlib. The svn version of ipython also includes support for qt4. Darren Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 ___ Matplotlib-devel mailing list Matplotlib-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-devel