diff --git a/examples/test_backend.py b/examples/test_backend.py index cda9b60..e872c03 100644 --- a/examples/test_backend.py +++ b/examples/test_backend.py @@ -1,11 +1,11 @@ import matplotlib -matplotlib.use('module://kivy.garden.matplotlib.backend_kivy') +matplotlib.use('module://kivy_garden.matplotlib.backend_kivy') from matplotlib.figure import Figure from numpy import arange, sin, pi from kivy.app import App import numpy as np -from kivy.garden.matplotlib.backend_kivyagg import FigureCanvas,\ +from kivy_garden.matplotlib.backend_kivyagg import FigureCanvas,\ NavigationToolbar2Kivy from kivy.uix.floatlayout import FloatLayout from kivy.uix.boxlayout import BoxLayout diff --git a/examples/test_events.py b/examples/test_events.py index 3a3c84d..42aadd5 100644 --- a/examples/test_events.py +++ b/examples/test_events.py @@ -4,7 +4,7 @@ import numpy as np import matplotlib.pyplot as plt -from kivy.garden.matplotlib.backend_kivyagg import FigureCanvas +from kivy_garden.matplotlib.backend_kivyagg import FigureCanvas def enter_axes(event): diff --git a/examples/test_plt.py b/examples/test_plt.py index 0d2a68c..eb31cf7 100644 --- a/examples/test_plt.py +++ b/examples/test_plt.py @@ -1,7 +1,7 @@ #!/usr/bin/env python # a bar plot with errorbars import matplotlib -matplotlib.use('module://kivy.garden.matplotlib.backend_kivy') +matplotlib.use('module://kivy_garden.matplotlib.backend_kivy') #matplotlib.use('Gtk') import numpy as np diff --git a/__init__.py b/kivy_garden/matplotlib/__init__.py similarity index 75% rename from __init__.py rename to kivy_garden/matplotlib/__init__.py index 481154e..0f73702 100644 --- a/__init__.py +++ b/kivy_garden/matplotlib/__init__.py @@ -1,8 +1,8 @@ -from kivy.garden.matplotlib.backend_kivy import FigureCanvasKivy,\ +from .backend_kivy import FigureCanvasKivy,\ FigureManagerKivy, RendererKivy,\ GraphicsContextKivy, NavigationToolbar2Kivy,\ MPLKivyApp -from kivy.garden.matplotlib.backend_kivyagg import FigureCanvasKivyAgg +from .backend_kivyagg import FigureCanvasKivyAgg __all__ = (FigureCanvasKivy.__name__, FigureManagerKivy.__name__, RendererKivy.__name__, GraphicsContextKivy.__name__, diff --git a/backend_kivy.py b/kivy_garden/matplotlib/backend_kivy.py similarity index 99% rename from backend_kivy.py rename to kivy_garden/matplotlib/backend_kivy.py index 66352f5..52d4c32 100644 --- a/backend_kivy.py +++ b/kivy_garden/matplotlib/backend_kivy.py @@ -352,7 +352,8 @@ class Show(ShowBase): '''mainloop needs to be overwritten to define the show() behavior for kivy framework. ''' - def mainloop(self): + @classmethod + def mainloop(cls): app = App.get_running_app() if app is None: app = MPLKivyApp(figure=my_canvas, toolbar=toolbar) @@ -401,7 +402,7 @@ def __init__(self, widget): self.dpi = widget.figure.dpi self._markers = {} # Can be enhanced by using TextToPath matplotlib, textpath.py - self.mathtext_parser = MathTextParser("Bitmap") + self.mathtext_parser = MathTextParser("path") self.list_goraud_triangles = [] self.clip_rectangles = [] self.labels_inside_plot = [] diff --git a/backend_kivyagg.py b/kivy_garden/matplotlib/backend_kivyagg.py similarity index 98% rename from backend_kivyagg.py rename to kivy_garden/matplotlib/backend_kivyagg.py index 742b566..1048b7e 100644 --- a/backend_kivyagg.py +++ b/kivy_garden/matplotlib/backend_kivyagg.py @@ -93,7 +93,7 @@ def my_callback(event): from kivy.base import EventLoop from kivy.uix.floatlayout import FloatLayout from kivy.core.image import Image -from kivy.garden.matplotlib.backend_kivy import FigureCanvasKivy,\ +from .backend_kivy import FigureCanvasKivy,\ FigureManagerKivy, show, new_figure_manager,\ NavigationToolbar2Kivy @@ -152,7 +152,8 @@ class Show(ShowBase): '''mainloop needs to be overwritten to define the show() behavior for kivy framework. ''' - def mainloop(self): + @classmethod + def mainloop(cls): global my_canvas global toolbar app = App.get_running_app() diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..c215c6e --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,28 @@ +[build-system] +requires = ["setuptools >= 40.6.0", "wheel"] +build-backend = "setuptools.build_meta" + +[project] +name = "kivy_garden.matplotlib" +authors = [ {name = "Kivy", email = "kivy@kivy.org"} ] +version = "0.1.0" +description = "Matplotlib backends using kivy" +readme = "README.md" +requires-python = ">=3.8" +keywords = ["Kivy", "kivy-garden"] +license = {text = "MIT"} +classifiers = [ + "Intended Audience :: Developers", + "Topic :: Software Development :: Libraries", + "License :: OSI Approved :: MIT License", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3", +] + +dependencies = ["matplotlib >= 3.0.0"] + +[tool.setuptools] +packages = ["kivy_garden.matplotlib"]