forked from pool/python-matplotlib
		
	Accepting request 109897 from devel:languages:python
- Cleaned up spec file formatting - Removed tests for obsolete openSUSE versions - Added Qt Designer plugin from Python(x,y) project (forwarded request 109846 from TheBlackCat) OBS-URL: https://build.opensuse.org/request/show/109897 OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/python-matplotlib?expand=0&rev=17
This commit is contained in:
		
				
					committed by
					
						 Git OBS Bridge
						Git OBS Bridge
					
				
			
			
				
	
			
			
			
						parent
						
							c03610cb15
						
					
				
				
					commit
					a33e2683c5
				
			
							
								
								
									
										66
									
								
								matplotlibplugin.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										66
									
								
								matplotlibplugin.py
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,66 @@ | ||||
| # -*- coding: utf-8 -*- | ||||
| # | ||||
| # Copyright © 2009 Pierre Raybaut | ||||
| # Licensed under the terms of the MIT License | ||||
|  | ||||
| from PyQt4.QtGui import QIcon | ||||
| from PyQt4.QtDesigner import QPyDesignerCustomWidgetPlugin | ||||
|  | ||||
| import os | ||||
| from matplotlib import rcParams | ||||
| from matplotlibwidget import MatplotlibWidget | ||||
|  | ||||
| rcParams['font.size'] = 9 | ||||
|  | ||||
| class MatplotlibPlugin(QPyDesignerCustomWidgetPlugin): | ||||
|     def __init__(self, parent=None): | ||||
|         QPyDesignerCustomWidgetPlugin.__init__(self) | ||||
|  | ||||
|         self._initialized = False | ||||
|  | ||||
|     def initialize(self, formEditor): | ||||
|         if self._initialized: | ||||
|             return | ||||
|  | ||||
|         self._initialized = True | ||||
|  | ||||
|     def isInitialized(self): | ||||
|         return self._initialized | ||||
|  | ||||
|     def createWidget(self, parent): | ||||
|         return MatplotlibWidget(parent) | ||||
|  | ||||
|     def name(self): | ||||
|         return "MatplotlibWidget" | ||||
|  | ||||
|     def group(self): | ||||
|         return "Python(x,y)" | ||||
|  | ||||
|     def icon(self): | ||||
|         image = os.path.join(rcParams['datapath'], 'images', 'matplotlib.png') | ||||
|         return QIcon(image) | ||||
|  | ||||
|     def toolTip(self): | ||||
|         return "" | ||||
|  | ||||
|     def whatsThis(self): | ||||
|         return "" | ||||
|  | ||||
|     def isContainer(self): | ||||
|         return False | ||||
|  | ||||
|     def domXml(self): | ||||
|         return '<widget class="MatplotlibWidget" name="mplwidget">\n' \ | ||||
|                '</widget>\n' | ||||
|  | ||||
|     def includeFile(self): | ||||
|         return "matplotlibwidget" | ||||
|  | ||||
|  | ||||
| if __name__ == '__main__': | ||||
|     import sys | ||||
|     from PyQt4.QtGui import QApplication | ||||
|     app = QApplication(sys.argv) | ||||
|     widget = MatplotlibWidget() | ||||
|     widget.show() | ||||
|     sys.exit(app.exec_()) | ||||
							
								
								
									
										124
									
								
								matplotlibwidget.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										124
									
								
								matplotlibwidget.py
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,124 @@ | ||||
| # -*- coding: utf-8 -*- | ||||
| # | ||||
| # Copyright © 2009 Pierre Raybaut | ||||
| # Licensed under the terms of the MIT License | ||||
|  | ||||
| """ | ||||
| MatplotlibWidget | ||||
| ================ | ||||
|  | ||||
| Example of matplotlib widget for PyQt4 | ||||
|  | ||||
| Copyright © 2009 Pierre Raybaut | ||||
| This software is licensed under the terms of the MIT License | ||||
|  | ||||
| Derived from 'embedding_in_pyqt4.py': | ||||
| Copyright © 2005 Florent Rougon, 2006 Darren Dale | ||||
| """ | ||||
|  | ||||
| __version__ = "1.0.0" | ||||
|  | ||||
| from PyQt4.QtGui import QSizePolicy | ||||
| from PyQt4.QtCore import QSize | ||||
|  | ||||
| from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg as Canvas | ||||
| from matplotlib.figure import Figure | ||||
|  | ||||
| from matplotlib import rcParams | ||||
| rcParams['font.size'] = 9 | ||||
|  | ||||
|  | ||||
| class MatplotlibWidget(Canvas): | ||||
|     """ | ||||
|     MatplotlibWidget inherits PyQt4.QtGui.QWidget | ||||
|     and matplotlib.backend_bases.FigureCanvasBase | ||||
|      | ||||
|     Options: option_name (default_value) | ||||
|     -------     | ||||
|     parent (None): parent widget | ||||
|     title (''): figure title | ||||
|     xlabel (''): X-axis label | ||||
|     ylabel (''): Y-axis label | ||||
|     xlim (None): X-axis limits ([min, max]) | ||||
|     ylim (None): Y-axis limits ([min, max]) | ||||
|     xscale ('linear'): X-axis scale | ||||
|     yscale ('linear'): Y-axis scale | ||||
|     width (4): width in inches | ||||
|     height (3): height in inches | ||||
|     dpi (100): resolution in dpi | ||||
|     hold (False): if False, figure will be cleared each time plot is called | ||||
|      | ||||
|     Widget attributes: | ||||
|     ----------------- | ||||
|     figure: instance of matplotlib.figure.Figure | ||||
|     axes: figure axes | ||||
|      | ||||
|     Example: | ||||
|     ------- | ||||
|     self.widget = MatplotlibWidget(self, yscale='log', hold=True) | ||||
|     from numpy import linspace | ||||
|     x = linspace(-10, 10) | ||||
|     self.widget.axes.plot(x, x**2) | ||||
|     self.wdiget.axes.plot(x, x**3) | ||||
|     """ | ||||
|     def __init__(self, parent=None, title='', xlabel='', ylabel='', | ||||
|                  xlim=None, ylim=None, xscale='linear', yscale='linear', | ||||
|                  width=4, height=3, dpi=100, hold=False): | ||||
|         self.figure = Figure(figsize=(width, height), dpi=dpi) | ||||
|         self.axes = self.figure.add_subplot(111) | ||||
|         self.axes.set_title(title) | ||||
|         self.axes.set_xlabel(xlabel) | ||||
|         self.axes.set_ylabel(ylabel) | ||||
|         if xscale is not None: | ||||
|             self.axes.set_xscale(xscale) | ||||
|         if yscale is not None: | ||||
|             self.axes.set_yscale(yscale) | ||||
|         if xlim is not None: | ||||
|             self.axes.set_xlim(*xlim) | ||||
|         if ylim is not None: | ||||
|             self.axes.set_ylim(*ylim) | ||||
|         self.axes.hold(hold) | ||||
|  | ||||
|         Canvas.__init__(self, self.figure) | ||||
|         self.setParent(parent) | ||||
|  | ||||
|         Canvas.setSizePolicy(self, QSizePolicy.Expanding, QSizePolicy.Expanding) | ||||
|         Canvas.updateGeometry(self) | ||||
|  | ||||
|     def sizeHint(self): | ||||
|         w, h = self.get_width_height() | ||||
|         return QSize(w, h) | ||||
|  | ||||
|     def minimumSizeHint(self): | ||||
|         return QSize(10, 10) | ||||
|  | ||||
|  | ||||
|  | ||||
| #=============================================================================== | ||||
| #   Example | ||||
| #=============================================================================== | ||||
| if __name__ == '__main__': | ||||
|     import sys | ||||
|     from PyQt4.QtGui import QMainWindow, QApplication | ||||
|     from numpy import linspace | ||||
|      | ||||
|     class ApplicationWindow(QMainWindow): | ||||
|         def __init__(self): | ||||
|             QMainWindow.__init__(self) | ||||
|             self.mplwidget = MatplotlibWidget(self, title='Example', | ||||
|                                               xlabel='Linear scale', | ||||
|                                               ylabel='Log scale', | ||||
|                                               hold=True, yscale='log') | ||||
|             self.mplwidget.setFocus() | ||||
|             self.setCentralWidget(self.mplwidget) | ||||
|             self.plot(self.mplwidget.axes) | ||||
|              | ||||
|         def plot(self, axes): | ||||
|             x = linspace(-10, 10) | ||||
|             axes.plot(x, x**2) | ||||
|             axes.plot(x, x**3) | ||||
|          | ||||
|     app = QApplication(sys.argv) | ||||
|     win = ApplicationWindow() | ||||
|     win.show() | ||||
|     sys.exit(app.exec_()) | ||||
| @@ -1,3 +1,10 @@ | ||||
| ------------------------------------------------------------------- | ||||
| Fri Mar 16 15:13:32 UTC 2012 - toddrme2178@gmail.com | ||||
|  | ||||
| - Cleaned up spec file formatting | ||||
| - Removed tests for obsolete openSUSE versions | ||||
| - Added Qt Designer plugin from Python(x,y) project | ||||
|  | ||||
| ------------------------------------------------------------------- | ||||
| Tue Jan 10 11:38:24 CET 2012 - kukuk@suse.de | ||||
|  | ||||
|   | ||||
| @@ -15,16 +15,19 @@ | ||||
| # Please submit bugfixes or comments via http://bugs.opensuse.org/ | ||||
| # | ||||
|  | ||||
| Name:           python-matplotlib | ||||
| %define modname matplotlib | ||||
| Name:           python-%{modname} | ||||
| Version:        1.1.0 | ||||
| Release:        0 | ||||
|  | ||||
| Summary:        Plotting Library for Python | ||||
| License:        BSD-2-Clause | ||||
| Group:          Development/Libraries/Python | ||||
| Url:            http://sourceforge.net/projects/matplotlib | ||||
| Source:         matplotlib-%{version}.tar.bz2 | ||||
| Source1:        matplotlib-setup.cfg | ||||
| Url:            http://sourceforge.net/projects/%{modname} | ||||
| Source:         %{modname}-%{version}.tar.bz2 | ||||
| Source1:        %{modname}-setup.cfg | ||||
| Source2:        %{modname}plugin.py | ||||
| Source3:        %{modname}widget.py | ||||
| BuildRoot:      %{_tmppath}/%{name}-%{version}-build | ||||
|  | ||||
| BuildRequires:  fltk-devel | ||||
| @@ -33,6 +36,7 @@ BuildRequires:  gcc-c++ | ||||
| BuildRequires:  gtk2-devel | ||||
| BuildRequires:  libpng-devel | ||||
| BuildRequires:  python-gtk | ||||
| BuildRequires:  python-gtk-devel | ||||
| BuildRequires:  python-numpy-devel >= 1.2.1 | ||||
| BuildRequires:  python-tk | ||||
| BuildRequires:  tcl | ||||
| @@ -44,25 +48,16 @@ Requires:       python-dateutil | ||||
| Requires:       python-numpy >= 1.2.1 | ||||
| Requires:       python-tz | ||||
| %py_requires | ||||
| %if %suse_version > 1130 | ||||
| BuildRequires:  python-wxWidgets | ||||
| BuildRequires:  wxWidgets-devel | ||||
| %else | ||||
| %if 0%{?sles_version} == 11 | ||||
| BuildRequires:  gnome-libs-devel | ||||
| BuildRequires:  python-qt | ||||
| BuildRequires:  python-wxGTK | ||||
| BuildRequires:  wxGTK-devel | ||||
| %endif | ||||
| BuildRequires:  python-gtk-devel | ||||
| %if 0%{?suse_version} >= 1120 | ||||
| BuildRequires:  python-qt4 | ||||
| %else | ||||
| BuildRequires:  python-qt | ||||
| %endif | ||||
| %if 0%{?suse_version} >= 1130 | ||||
| BuildRequires:  libgnome-devel | ||||
| %else | ||||
| BuildRequires:  gnome-libs-devel | ||||
| %endif | ||||
| %if %suse_version > 1130 | ||||
| BuildRequires:  python-qt4 | ||||
| BuildRequires:  python-wxWidgets | ||||
| BuildRequires:  wxWidgets-devel | ||||
| %define _use_internal_dependency_generator 0 | ||||
| %define __find_requires %wx_requires | ||||
| %endif | ||||
| @@ -81,26 +76,40 @@ scripts, the python and ipython shell (ala matlab or mathematica), web | ||||
| application servers, and six graphical user interface toolkits. | ||||
|  | ||||
| %package tk | ||||
| Summary:        Tk backend for python-matplotlib | ||||
| Summary:        Tk backend for %{name} | ||||
| Group:          Development/Libraries/Python | ||||
| Requires:       %{name} = %{version} | ||||
| Requires:       python-tk | ||||
|  | ||||
| %description tk | ||||
| Tk backend for python-matplotlib plotting package | ||||
| Tk backend for %{name} plotting package | ||||
|  | ||||
| %package wx | ||||
| Summary:        Wx backend for python-matplotlib | ||||
| Summary:        Wx backend for %{name} | ||||
| Group:          Development/Libraries/Python | ||||
| Requires:       %{name} = %{version} | ||||
| Requires:       python-wxGTK | ||||
|  | ||||
| %description wx | ||||
| wxWidgets backend for python-matplotlib plotting package | ||||
| wxWidgets backend for %{name} plotting package | ||||
|  | ||||
| %package designer | ||||
| Summary:        %{name} widget for Qt Designer | ||||
| Group:          Development/Libraries/Python | ||||
| License:        MIT | ||||
| Requires:       %{name} = %{version} | ||||
| Requires:       python-qt4 | ||||
| Requires:       qt-creator | ||||
|  | ||||
| %description designer | ||||
| This is a plugin and widget to let you use %{name}  | ||||
| plots as widget in PyQt4 GUIs using Qt Designer | ||||
|  | ||||
| This plugin comes from Python(x,y) | ||||
|  | ||||
| %prep | ||||
| %setup -n matplotlib-%{version} | ||||
| chmod -x lib/matplotlib/mpl-data/images/*.svg | ||||
| chmod -x lib/%{modname}/mpl-data/images/*.svg | ||||
|  | ||||
| %build | ||||
| cp %{SOURCE1} ./setup.cfg | ||||
| @@ -109,36 +118,45 @@ python setup.py build | ||||
| %install | ||||
| python setup.py install --root=%{buildroot} \ | ||||
| 	--record-rpm=INSTALLED_FILES --prefix=%{_prefix} | ||||
| mkdir -p %{buildroot}%{_libdir}/qt4/PyQt4/plugins/ | ||||
| cp -v %{SOURCE2} %{buildroot}%{_libdir}/qt4/PyQt4/plugins/ | ||||
| cp -v %{SOURCE3} %{buildroot}%{py_sitedir}/%{modname}/ | ||||
|  | ||||
| %clean | ||||
| rm -rf %{buildroot} | ||||
|  | ||||
| %files | ||||
| %defattr(-,root,root,-) | ||||
| %doc README.txt CHANGELOG INSTALL | ||||
| %doc README.txt CHANGELOG | ||||
| %doc PKG-INFO TODO CXX examples  | ||||
| %{py_sitedir}/* | ||||
| %exclude %{py_sitedir}/matplotlib/backends/backend_tkagg.* | ||||
| %exclude %{py_sitedir}/matplotlib/backends/tkagg.* | ||||
| %exclude %{py_sitedir}/matplotlib/backends/_tkagg.so | ||||
| %exclude %{py_sitedir}/matplotlib/backends/backend_wx.* | ||||
| %exclude %{py_sitedir}/matplotlib/backends/backend_wxagg.* | ||||
| %if %suse_version <= 1020 | ||||
| %exclude %{py_sitedir}/matplotlib/backends/_wxagg.so | ||||
| %endif | ||||
| %{py_sitedir}/%{modname}-%{version}-py%{py_ver}.egg-info | ||||
| %{py_sitedir}/%{modname}/ | ||||
| %{py_sitedir}/mpl_toolkits | ||||
| %{py_sitedir}/pylab.py | ||||
| %{py_sitedir}/pylab.pyc | ||||
| %exclude %{py_sitedir}/%{modname}/backends/backend_tkagg.* | ||||
| %exclude %{py_sitedir}/%{modname}/backends/tkagg.* | ||||
| %exclude %{py_sitedir}/%{modname}/backends/_tkagg.so | ||||
| %exclude %{py_sitedir}/%{modname}/backends/backend_wx.* | ||||
| %exclude %{py_sitedir}/%{modname}/backends/backend_wxagg.* | ||||
| %exclude %{py_sitedir}/%{modname}/%{modname}widget.py | ||||
|  | ||||
| %files tk | ||||
| %defattr(-,root,root,-) | ||||
| %{py_sitedir}/matplotlib/backends/backend_tkagg.* | ||||
| %{py_sitedir}/matplotlib/backends/tkagg.* | ||||
| %{py_sitedir}/matplotlib/backends/_tkagg.so | ||||
| %{py_sitedir}/%{modname}/backends/backend_tkagg.* | ||||
| %{py_sitedir}/%{modname}/backends/tkagg.* | ||||
| %{py_sitedir}/%{modname}/backends/_tkagg.so | ||||
|  | ||||
| %files wx | ||||
| %defattr(-,root,root,-) | ||||
| %{py_sitedir}/matplotlib/backends/backend_wx.* | ||||
| %{py_sitedir}/matplotlib/backends/backend_wxagg.* | ||||
| %if %suse_version <= 1020 | ||||
| %{py_sitedir}/matplotlib/backends/_wxagg.so | ||||
| %endif | ||||
|  | ||||
| %files designer | ||||
| %defattr(-,root,root,-) | ||||
| %dir %{_libdir}/qt4/PyQt4 | ||||
| %dir %{_libdir}/qt4/PyQt4/plugins | ||||
| %{_libdir}/qt4/PyQt4/plugins/%{modname}plugin.py | ||||
| %{py_sitedir}/%{modname}/%{modname}widget.py | ||||
|  | ||||
| %changelog | ||||
|   | ||||
		Reference in New Issue
	
	Block a user