Skip to content

Instantly share code, notes, and snippets.

@VICTORVICKIE
Created June 28, 2021 03:35
Show Gist options
  • Save VICTORVICKIE/986a4f1ea11afd26a76bf32fd3f15eb4 to your computer and use it in GitHub Desktop.
Save VICTORVICKIE/986a4f1ea11afd26a76bf32fd3f15eb4 to your computer and use it in GitHub Desktop.
SVG
Display the source blob
Display the rendered blob
Raw
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" width="24" height="24" viewBox="0 0 24 24"><path d="M11,7A2,2 0 0,0 9,9V17H11V13H13V17H15V9A2,2 0 0,0 13,7H11M11,9H13V11H11V9Z" /></svg>
from kivy.lang import Builder
from kivymd.app import MDApp
from kivy.clock import Clock
import threading
from kivymd.uix.boxlayout import MDBoxLayout
KV = '''
<SVG>:
md_bg_color: 1,1,1,1
pos_hint:{"center_x":0.5, "center_y":0.5}
MDScreen:
SVG:
id:svg
svg:"alpha-a.svg"
size_hint: None, None
'''
from kivg import Kivg
class SVG(MDBoxLayout):
pass
class Example(MDApp):
def build(self):
return Builder.load_string(KV)
def show_button_icon(self, *args):
b = self.root.ids.svg
s = Kivg(b)
setattr(b, "s", s)
self.draw_path(s, b.svg)
def on_start(self):
t = threading.Thread(target=self.show_button_icon)
Clock.schedule_once(lambda *args: t.start())
def draw_path(self, s, icon):
s.draw(icon, fill=False, line_width=1)
Example().run()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment