TXLWizard.TXLWriter¶
Controller class for generating TXL / SVG / HTML output.
Here we can add structures (definitions and content) which will be rendered in the output.
Classes¶
TXLWriter (**kwargs) |
Controller class for generating TXL / SVG / HTML output. |
-
class
TXLWizard.TXLWriter.
TXLWriter
(**kwargs)[source]¶ Bases:
object
Controller class for generating TXL / SVG / HTML output.
Here we can add structures (definitions and content) which will be rendered in the output.
Optionally, a coordinate system grid is drawn.
Parameters: - ShowGrid (bool, optional) –
Show the coordinate system grid or not.
Defaults to True
- GridWidth (int, optional) –
Full width of the coordinate system grid in um.
Defaults to 800
- GridHeight (int, optional) –
Full height of the coordinate system grid in um.
Defaults to 800
- GridSpacing (int, optional) –
Coordinate Sytem Grid Spacing in um.
Defaults to 100
- SubGridSpacing (int, optional) –
Coordinate System Sub-Grid Spacing in um.
Defaults to 10
- Precision (int, optional) –
Number of digits for float to str conversion / Resolution of TXL file.
Defaults to 4
Examples
Import required Modules
>>> import TXLWizard.TXLWriter
Initialize TXLWriter
>>> TXLWriter = TXLWizard.TXLWriter.TXLWriter( ... ShowGrid=True, GridWidth=800, GridHeight=800 ... )
Add a definition structure and add a pattern of type Circle
>>> MyDefinitionStructure = TXLWriter.AddDefinitionStructure('MyDefinition') >>> MyDefinitionStructure.AddPattern('Circle', Center=[0,0], Radius=20, Layer=3) <TXLWizard.Patterns.Circle.Circle object at 0x...>
Add a content structure with a pattern Reference to reuse the definition structure.
>>> MyContentStructure = TXLWriter.AddContentStructure('MySuperCircle') >>> MyContentStructure.AddPattern( ... 'Reference', ... ReferencedStructureID=MyDefinitionStructure.ID, ... OriginPoint=[20,50] ... ) <TXLWizard.Patterns.Reference.Reference object at 0x...>
Generate the Output files with name Example_TXLWriter.(txl|html|svg) to the folder Tests/Results
>>> TXLWriter.GenerateFiles('Tests/Results/TXLWriter/Example_TXLWriter')
-
AddContentStructure
(ID, **kwargs)[source]¶ Add content structure. A content structure can hold patterns that will render in the output.
A structure corresponds to the “STRUCT” command in the TXL file format.
Parameters: - ID (str) – Unique identification of the structure. Must be used when referencing to this structure.
- kwargs (dict) – Keyword arguments passed to the structure constructor. See
TXLWizard.Patterns.Structure.Structure
Returns: Return type: TXLWizard.Patterns.Structure.Structure
structure instance
-
AddDefinitionStructure
(ID, **kwargs)[source]¶ Add definition structure. A definition structure can be referenced by a content structure.
A structure corresponds to the “STRUCT” command in the TXL file format.
Parameters: - ID (str) – Unique identification of the structure. Must be used when referencing to this structure.
- kwargs (dict) – Keyword arguments passed to the structure constructor. See
TXLWizard.Patterns.Structure.Structure
Returns: Return type: TXLWizard.Patterns.Structure.Structure
structure instance
-
GenerateFiles
(Filename, TXL=True, SVG=True, HTML=True, TargetFolder=None)[source]¶ Generate the output files (.txl, .svg, .html).
Parameters: - Filename (str) – Path / Filename without extension. The corresponding path will be created if it does not exist
- TXL (bool, optional) –
Enable TXL Output.
Defaults to True
- SVG (bool, optional) –
Enable SVG Output.
Defaults to True
- HTML (bool, optional) –
Enable HTML Output. If set to True, also SVG needs to be set to True
Defaults to True
- TargetFolder (str, optional) –
If given, the generated files are stored in the folder specified.
If not given, the generated files are stored in the path specified in Filename
Defaults to None.
-
ImportTXLFile
(Filename, LayersToProcess=[])[source]¶ Import an existing TXL file for further processing.
The content structures can be accessed with self._ContentStructures (read-only!).
The order of the content structures is stored in self._ContentStructuresIndexList (read-only!).
The definition structures are stored in self._Definitions.Structures
Parameters: - Filename (str) – Path / Filename of the .txl file to be imported
- LayersToProcess (list of int, optional) –
if given, only layers in this list are processed / shown.
Defaults to []
Examples
Import required modules
>>> import TXLWizard.TXLWriter >>> import TXLWizard.ShapeLibrary.Label
Initialize TXLWriter
>>> TXLWriter = TXLWizard.TXLWriter.TXLWriter()
import TXL file myPath/mask_orig.txl
>>> TXLWriter.ImportTXLFile('Tests/SampleFiles/Example_Simple_Original.txl', LayersToProcess=[1,3,4])
Get an existing structure and add a pattern to it
>>> MyStructure = TXLWriter._ContentStructures['MyCircleArray'] >>> MyStructure.AddPattern( ... 'Circle', ... Center=[-100, 0], ... Radius=50, ... Layer=1 ... ) <TXLWizard.Patterns.Circle.Circle object at 0x...>
Add a label
>>> SampleLabelObject = TXLWizard.ShapeLibrary.Label.GetLabel( ... TXLWriter, ... Text='This is my text', ... OriginPoint=[ ... -200, 300 ... ], ... FontSize=150, ... StrokeWidth=20 ... )
Generate the Output files with name ExampleSimple_Modified.(txl|html|svg) to the folder Tests/Results
>>> TXLWriter.GenerateFiles('Tests/Results/TXLWriter/Example_Simple_Modified')
- ShowGrid (bool, optional) –