class visigoth.common.button.Button(text=None, image=None, padding=2, font_height=24, text_attributes={}, url=None, fill='white', push_fill='red', stroke='black', stroke_width=1, r=5, click_value='click')

Create a button

Keyword Arguments
  • text (str) – the text to display in the button

  • image (visigoth.common.Image) – an image element to display in the button

  • padding (int) – define padding around button content in pixels

  • font_height (int) – font size in pixeks

  • text_attributes (dict) – a dict containing SVG name/value attributes

  • url (str) – url to link to from the text

  • fill (str) – the background colour for the button

  • push_fill (str) – the background colour for the button when pushed

  • stroke (str) – the stroke colour for the line around the button

  • stroke_width (int) – the stroke width for the line around the button

  • r (int) – the button corner radius in pixels

  • click_value (str) – the event value emitted when the button is clicked


When pressed the button will generate an event with string value “click” on channel “click”


Screenshot (Link to open SVG for interactive features):


Source Code (Link to Github):

import os
import sys
import argparse

from visigoth.diagram import Diagram
from visigoth.common.button import Button
from visigoth.common.image import Image

if __name__ == "__main__":

    parser = argparse.ArgumentParser()
    parser.add_argument("--outpath", help="path for output SVG", default="example.svg")
    args = parser.parse_args()

    d = Diagram(fill="white")

    folder = os.path.split(sys.argv[0])[0]

    i = Image(mime_type="image/jpeg",content_bytes=open(os.path.join(folder,"..","image","MtCleveland.jpg"),"rb").read(),tooltip="MtCleveland Volcano Eruption")

    svg = d.draw()

    f = open(args.outpath, "wb")