spacepaste

  1.  
  2. import sys
  3. from glob import glob
  4. from os.path import join, dirname
  5. from kivy.uix.scatter import Scatter
  6. from kivy.app import App
  7. from kivy.graphics.svg import Svg
  8. from kivy.core.window import Window
  9. from kivy.uix.floatlayout import FloatLayout
  10. class SvgWidget(Scatter):
  11. def __init__(self, filename, **kwargs):
  12. super(SvgWidget, self).__init__(**kwargs)
  13. with self.canvas:
  14. svg = Svg(filename)
  15. self.size = svg.width, svg.height
  16. class SvgApp(App):
  17. def build(self):
  18. self.root = FloatLayout()
  19. filenames = ['temp.svg']
  20. for filename in filenames:
  21. with open(filename,'r') as fp:
  22. whole_file_text = fp.read()
  23. with open(filename,'w') as fp:
  24. text_to_write=whole_file_text.replace('pt"','"')
  25. fp.write(text_to_write)
  26. svg = SvgWidget(filename, size_hint=(None, None))
  27. self.root.add_widget(svg)
  28. svg.scale = 5.
  29. svg.center = Window.center
  30. if __name__ == '__main__':
  31. SvgApp().run()
  32.