Skip to content

Instantly share code, notes, and snippets.

@VICTORVICKIE
Created June 28, 2021 03:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • 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
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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