Created
June 28, 2021 03:35
-
-
Save VICTORVICKIE/986a4f1ea11afd26a76bf32fd3f15eb4 to your computer and use it in GitHub Desktop.
SVG
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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