packages = ["whl/schemdraw-0.19-py3-none-any.whl", "whl/ziamath-0.11-py3-none-any.whl", "whl/ziafont-0.9-py3-none-any.whl", "pyparsing" ]

Loading...

Logic Gates by Schemdraw

Enter a logic expression

Expression
Gate Height
=






import asyncio from pyscript import document, display from js import console, window, Uint8Array, File, URL from io import BytesIO from schemdraw.parsing import logicparse def drawit(*args): expr = document.querySelector("#expression").value outlabel = document.querySelector("#outlabel").value gateH = float(document.querySelector("#height").value) d = logicparse(expr, outlabel=outlabel, gateH=gateH) display(d, target='schematic', append=False) async def file_save(*args): expr = document.querySelector("#expression").value outlabel = document.querySelector("#outlabel").value gateH = float(document.querySelector("#height").value) img = logicparse(expr, outlabel=outlabel, gateH=gateH).get_imagedata() stream = BytesIO(img) js_array = Uint8Array.new(len(img)) js_array.assign(stream.getbuffer()) file = File.new([js_array], "schemdraw_logic.svg", {type: "text/plain"}) url = URL.createObjectURL(file) hidden_link = document.createElement("a") hidden_link.setAttribute("download", "schemdraw_logic.svg") hidden_link.setAttribute("href", url) hidden_link.click() drawit()