KnittingPatternSet Module

A set of knitting patterns that can be dumped and loaded.

class knittingpattern.KnittingPatternSet.KnittingPatternSet(type_, version, patterns, parser, comment=None)[source]

Bases: object

This is the class for a set of knitting patterns.

The knitting patterns all have an id and can be accessed from here. It is possible to load this set of knitting patterns from various locations, see the knittingpattern module. You rarely need to create such a pattern yourself. It is easier to create the pattern by loading it from a file.

__init__(type_, version, patterns, parser, comment=None)[source]

Create a new knitting pattern set.

This is the class for a set of knitting patterns.

  • type (str) – the type of the knitting pattern set, see the specification.
  • version (str) – the version of the knitting pattern set. This is not the version of the library but the version of the specification.
  • patterns – a collection of patterns. This should be a IdCollection of KnittingPatterns.
  • comment – a comment about the knitting pattern

list of weak references to the object (if defined)

add_new_pattern(id_, name=None)[source]

Add a new, empty knitting pattern to the set.

  • id_ – the id of the pattern
  • name – the name of the pattern to add or if None, the id_ is used

a new, empty knitting pattern

Return type:



The comment about the knitting pattern.

Returns:the comment for the knitting pattern set or None, see __init__().

The first element in this set.

Return type:knittingpattern.KnittingPattern.KnittingPattern

The pattern contained in this set.

Returns:the patterns of the knitting pattern, see __init__()
Return type:knittingpattern.IdCollection.IdCollection

The patterns can be accessed by their id.


Convert the knitting pattern to a png.

Returns:a dumper to save this pattern set as png for the AYAB software
Return type:knittingpattern.convert.AYABPNGDumper.AYABPNGDumper


>>> knitting_pattern_set.to_ayabpng().temporary_path()

Create an SVG from the knitting pattern set.

Parameters:zoom (float) – the height and width of a knit instruction
Returns:a dumper to save the svg to
Return type:knittingpattern.Dumper.XMLDumper


>>> knitting_pattern_set.to_svg(25).temporary_path(".svg")

The type of the knitting pattern.

Returns:the type of the knitting pattern, see __init__()
Return type:str

The version of the knitting pattern specification.

Returns:the version of the knitting pattern, see __init__()
Return type:str