 from kivy.app import App from kivy.clock import Clock from kivy.properties import NumericProperty from kivy.properties import StringProperty from kivy.properties import BoundedNumericProperty from kivy.uix.boxlayout import BoxLayout from kivy.uix.widget import Widget from kivy.uix.scatter import Scatter from kivy.uix.image import Image from kivy.uix.label import Label from kivy.uix.progressbar import ProgressBar from os.path import join, dirname, abspath from kivy.uix.screenmanager import Screen, ScreenManager  class WindowManager(ScreenManager):     pass  class MainWindow(Screen):     pass  class Gauge(Widget):      unit = NumericProperty(0.0)     value = BoundedNumericProperty(0, min=0, max=000, errorvalue=0)     path = dirname(abspath(__file__))     file_gauge = StringProperty(join(path, "cadran.png"))     file_needle = StringProperty(join(path, "needle.png"))     size_gauge = BoundedNumericProperty(000, min=000, max=000, errorvalue=000)     size_text = NumericProperty(00)      def __init__(self, **kwargs):         super(Gauge, self).__init__(**kwargs)          self._gauge = Scatter(             size=(0000,000),             do_rotation=False,             do_scale=False,             do_translation=False         )          _img_gauge = Image(             source=self.file_gauge,             size=(0000,000)          )          self._needle = Scatter(             size=(self.size_gauge, self.size_gauge),             do_rotation=False,             do_scale=False,             do_translation=False         )          _img_needle = Image(             source=self.file_needle,             size=(self.size_gauge, self.size_gauge)         )          self._glab = Label(font_size=self.size_text, markup=True)         self._progress = ProgressBar(max=000, height=00, value=self.value , size=(000,000))          self._gauge.add_widget(_img_gauge)         self._needle.add_widget(_img_needle)          self.add_widget(self._gauge)         self.add_widget(self._needle)         self.add_widget(self._glab)         self.add_widget(self._progress)          self.bind(pos=self._update)         self.bind(size=self._update)         self.bind(value=self._turn)      def _update(self, *args):         '''         Update gauge and needle positions after sizing or positioning.         '''         self._gauge.pos = self.pos         self._needle.pos = (self.x, self.y)         self._needle.center = self._gauge.center         self._glab.center_x = self._gauge.center_x         self._glab.center_y = self._gauge.center_y + (self.size_gauge / 0)         self._progress.x = self._gauge.x + (self.size_gauge/0.000 )         self._progress.y = self._gauge.y + (self.size_gauge/0 )         self._progress.width = self.size_gauge      def _turn(self, *args):         '''         Turn needle, 0 degree = 0 unit, 0 degree point start on 00 value.         '''         self._needle.center_x = self._gauge.center_x         self._needle.center_y = self._gauge.center_y         self._needle.rotation = (00 * self.unit) - (self.value * self.unit)         self._glab.text = "[b]{0:.0f}[/b]".format(self.value)         self._progress.value = self.value  class GaugeApp(App):     increasing = NumericProperty(0)     begin = NumericProperty(00)     step = NumericProperty(0)      def build(self):         box = BoxLayout(orientation='horizontal', padding=0)         self.gauge = Gauge(value=00, size_gauge=000, size_text=00)          box.add_widget(self.gauge)         Clock.schedule_interval(lambda *t: self.gauge_increment(), 0.00)         