damsenviet.kle package

class Keyboard

Bases: object

Keyboard information.

property metadata

Metadata Information.

Return type

Metadata

property keys

List of Keys.

Return type

List[Key]

classmethod from_json(keyboard_json)

Deserializes a KLE JSON into a Keyboard.

Parameters

keyboard_json (List[Union[Dict, List[Union[str, Dict]]]]) – KLE JSON to parse

Return type

Keyboard

Returns

Keyboard instance

to_json()

Serializes the Keyboard into a KLE JSON.

Return type

List[Union[Dict, List[Union[str, Dict]]]]

Returns

the KLE JSON

class Metadata

Bases: object

Metadata information.

property name

Keyboard name.

Return type

str

property author

Author’s name.

Return type

str

property notes

Author’s Notes.

Return type

str

property background

Background of the keyboard.

Return type

Background

property background_color

Background CSS color.

Return type

str

property radii

CSS border-radius value.

Return type

str

property css

CSS stylesheet.

Return type

str

property switch

Switch information.

Return type

Switch

property is_switches_pcb_mounted

Whether the switches are pcb mounted.

Return type

bool

property include_switches_pcb_mounted

Whether to force include switch pcb mounting in the KLE JSON.

Return type

bool

property is_switches_plate_mounted

Whether switches are plate mounted.

Return type

bool

property include_switches_plate_mounted

Whether to force include switch plate mounting in the KLE JSON.

Return type

bool

class Background

Bases: object

Background information.

property name

Name of the background option.

Return type

str

property style

Background CSS style declaration.

Return type

str

class Key

Bases: object

Key information.

property color

Keycap CSS color.

Return type

str

property labels

12 Labels.

Index to position mapping is displayed below.

Label Positions
Return type

List[Label]

property default_text_color

Default CSS text color.

Only used to optimize the KLE JSON size.

Return type

str

property default_text_size

Default text size.

Only used to optimize the KLE JSON size.

Return type

Union[int, float]

property x

X position of raised primary shape in key units.

Return type

float

property y

Y position of raised primary shape in key units.

Return type

float

property width

Width of raised primary shape in key units.

Return type

float

property height

Height of raised primary shape in key units.

Return type

float

property x2

X position offset of the lowered secondary shape in key units.

Return type

float

property y2

Y position offset of lowered secondary shape in key units.

Return type

float

property width2

Width of lowered secondary shape in key units.

Return type

float

property height2

Height of lowered secondary shape in key units.

Return type

float

property rotation_x

X position of rotation origin in key units.

Return type

float

property rotation_y

Y position of rotation origin in key units.

Return type

float

property rotation_angle

Rotation angle in degrees.

Return type

float

property is_ghosted

Whether the key is rendered partially transparent.

Return type

bool

property is_stepped

Whether the key is stepped.

Return type

bool

property is_homing

Whether the key is a homing key.

Return type

bool

property is_decal

Whether the key is purely decorative.

Return type

bool

property profile_and_row

Keycap profile and row.

Return type

str

property switch

Switch information.

Return type

Switch

class Switch

Bases: object

Switch information.

property mount

Switch mount.

Return type

str

property brand

Switch brand.

Return type

str

property type

Switch type part id.

Return type

str

class Label

Bases: object

Label information.

property text

Text content.

Return type

str

property color

CSS text color.

Return type

str

property size

Font size scale.

Return type

Union[int, float]

json_dump_options = {'allow_nan': True, 'check_circular': True, 'cls': None, 'default': None, 'ensure_ascii': True, 'indent': 2, 'separators': None, 'skipkeys': False, 'sort_keys': False}

Kwargs to be spread into json.dump or json.dumps to match KLE JSON format.

json.dumps(keyboard.to_json(), **json_dump_options)