merrimanind / drawpyo Goto Github PK
View Code? Open in Web Editor NEWA Python library for programmatically generating Draw.io charts.
Home Page: https://pypi.org/project/drawpyo/
License: MIT License
A Python library for programmatically generating Draw.io charts.
Home Page: https://pypi.org/project/drawpyo/
License: MIT License
I know it's not your main goal, biut given you instructed a new structured format, maybe you are far away.
Draw.io allows users to see the style attribute for any shape. This should be an option for parse any style attribute string into its component properties and generate a Draw.pyo BasicObject with those properties.
This will be a bigger task to get to eventually and for at least awhile there will be Draw.io features not supported in Draw.pyo. But it would be useful eventually to be able to generate a Python object from a Draw.io file and modify it.
Add a custom diagram type for working with FlowCharts.
Sub classes should include:
It would be nice to be able to define an object with the formatting desired then create new objects that mirror the formatting by passing the template in as an argument.
@rlespinasse created a useful Docker image with an export drawpyo file action. This could be integrated to drawpyo to support exporting a diagram to another file.
https://github.com/rlespinasse/drawio-export
There's also a Github action that can be integrated into build scripts for generating documentation! Ain't that cool.
https://github.com/rlespinasse/drawio-export-action?tab=readme-ov-file
Sequence diagrams are common in system interaction and user interface design. Adding some kind of automated graph support for this would be useful!
These are some HTML type escapes that may work:
xmlize = {}
xmlize[">"] = ">"
xmlize["<"] = "<"
xmlize["\n"] = "
"
Starting in 3.11, Python started shipping tomllib as a standard library. Prior to that, a library had to be imported with the best option being toml. Currently, drawpyo has no dependencies except this library so it would be nice to preserve that independence. However, it would also be nice to have compatibility with Python pre 3.11.
The way it's currently handled is with a version check and a conditional import:
if version_info.minor < 11:
import toml
data = toml.load(file_name)
else:
import tomllib
with open(file_name, "rb") as f:
data = tomllib.load(f)
But this won't work with builds and releases. It has to be seen if a conditional dependency can be set based on major Python version for a build.
Currently I have the EdgeStyle parameters only supporting rounded = 0 or 1. This is actually a miss as in Draw.io you have a three menu dropdown for Sharp (no rounded style at all), Rounded (rounded=1), or Curved (rounded=0,orthogonalLoop=1).
This can be a simple subclass of the basic TreeDiagram but enforcing only two children, renaming some objects to left and right, and prestyling it
Such as A4, US-Legal, etc.
It would be helpful to have screenshots from Draw.io showing the effects of various formatting choices.
Thanks for the repo first.
If I only add with the ellipse, then the page only displays the basic object without ellipse
item_from_lib = drawpyo.diagram.object_from_library( page=page, library="general", obj_name="ellipse", value="ellipse" )
I have to add one more line to make it working.
item_from_lib.apply_style_string("ellipse;")
This is a low priority since Draw.io doesn't care about white space and as soon as the file is opened and saved in Draw.io the formatting is cleaned up. But the current XML output doesn't have pretty whitespace and it bothers me.
A new diagram type for creating actual family trees would be useful for geneological work. This could be mostly a subclass of TreeDiagrams. But it will need some added complexity to support pairs of parents as parent nodes.
ResourceWarning: unclosed file <_io.TextIOWrapper name='test_out\\extra\\Scenario3.5\\plx_253114.drawio' mode='w' encoding='utf-8'>
This appears to be due to you missing brackets:
file.close
vs file.close()
Line 139 in ec35335
It might also be a good opportunity to instead use with
, which automatically closes the file for you.
with open(path.join(self.file_path, self.file_name), write_mode, encoding="utf-8") as f:
f.write(self.xml)
Thank you for this great library - it has been hugely helpful.
Not sure how this package wound up in the dependencies of the wheel but it's not necessary and should be removed.
The Draw.io app supports importing and exporting from an XML file format. This should be supported.
Also, if the base libraries that ship with the Draw.io app are saved in this format then this could supplant the TOML defs for the built in libraries.
Obvious in hindsight
This doesn't need to be inherited since it makes no use of other class-owned data or functions. Move it to its own function and fix all callers.
I feel very stupid but I am not able to run even the example:
import drawpyo
file = drawpyo.File()
Gives me:
file = drawpyo.File()
AttributeError: partially initialized module 'drawpyo' has no attribute 'File' (most likely due to a circular import)
I just installed drawpyo in version 0.1.3 that should be fine?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.