keyboardlayout package

Submodules

keyboardlayout.common module

class keyboardlayout.common.KeyInfo(margin: int, color: Union[pygame.Color, keyboardlayout.common.TkinterColor], txt_color: Union[pygame.Color, keyboardlayout.common.TkinterColor], txt_font: Union[pygame.font.SysFont, tkinter.font.Font], txt_padding: Tuple[int, int])[source]

Bases: object

The needed key inputs for KeyboardLayout

Parameters
  • margin – the gap between keys in pixels. this should be an even number

  • color – the key background color

  • txt_color – the color used for key text

  • txt_font – the font used to write key text

  • txt_padding – x, y padding in pixes from the edges of the key background rectangle

class keyboardlayout.common.KeyboardInfo(position: Tuple[int, int], padding: int, color: Optional[Union[pygame.Color, keyboardlayout.common.TkinterColor]] = None)[source]

Bases: object

The needed keyboard inputs for KeyboardLayout

Parameters
  • position – x, y top left position in pixels

  • padding – the padding used on all sides in pixels

  • color – the background color to use

class keyboardlayout.common.KeyboardLayoutInterface(layout_name: keyboardlayout.layouts.LayoutName, keyboard_info: keyboardlayout.common.KeyboardInfo, letter_key_size: Tuple[int], key_info: keyboardlayout.common.KeyInfo, overrides: Optional[Dict[str, keyboardlayout.common.KeyInfo]] = None)[source]

Bases: abc.ABC

abstract get_key(event: Union[tk.Event, pygame.event.EventType]) → Optional[keyboardlayout.key.Key][source]

Gets the Key which was pressed from an event

abstract update_key(key: keyboardlayout.key.Key, key_info: keyboardlayout.common.KeyInfo)[source]

Update key’s image using key_info

class keyboardlayout.common.Rect(x: int, y: int, width: int, height: int)[source]

Bases: object

This class is internally used by keyboardlayout to store rectangles

Parameters
  • x – the left x position in pixels

  • y – the top y position in pixels

  • width – the width in pixels

  • height – the height in pixels

class keyboardlayout.common.TkinterColor[source]

Bases: str

class keyboardlayout.common.TxtBase[source]

Bases: object

keyboardlayout.pygame module

class keyboardlayout.pygame.KeyboardLayout(layout_name: keyboardlayout.layouts.LayoutName, keyboard_info: keyboardlayout.common.KeyboardInfo, letter_key_size: Tuple[int], key_info: keyboardlayout.common.KeyInfo, overrides: Optional[Dict[str, keyboardlayout.common.KeyInfo]] = None)[source]

Bases: pygame.sprite.Group, keyboardlayout.common.KeyboardLayoutInterface

Makes a frame that stores a keyboard layout

Parameters
  • master – the root frame

  • layout_name – must be a string in the LayoutName enum

  • keyboard_info – the settings for the keyboard

  • letter_key_size – the horizontal and vertical size in px of letter keys

  • key_info – the settings for the keys

  • overrides – Optional; a dict that lets one override key settings

_key_to_sprite_group

a dict that goes from Key to pygame.sprite.Group instances

Type

dict

get_key(event: Event) → Optional[keyboardlayout.key.Key][source]

Gets the Key which was pressed from an event

update_key(key: keyboardlayout.key.Key, key_info: keyboardlayout.common.KeyInfo)[source]

Update key’s image using key_info

keyboardlayout.tkinter module

class keyboardlayout.tkinter.KeyboardLayout(layout_name: keyboardlayout.layouts.LayoutName, keyboard_info: keyboardlayout.common.KeyboardInfo, letter_key_size: Tuple[int], key_info: keyboardlayout.common.KeyInfo, *, master: Union[tkinter.Frame, tkinter.Tk], overrides: Optional[Dict[str, keyboardlayout.common.KeyInfo]] = None)[source]

Bases: tkinter.Frame, keyboardlayout.common.KeyboardLayoutInterface

Makes a sprite group that stores a keyboard layout image

Parameters
  • layout_name – must be a string in the LayoutName enum

  • keyboard_info – the settings for the keyboard

  • letter_key_size – the horizontal and vertical size in px of letter keys

  • key_info – the settings for the keys

  • overrides – Optional; a dict that lets one override key settings

_key_name_to_sprite_group

a dict that goes from key_name (str) to pygame.sprite.Group instances

Type

dict

get_key(event: tkinter.Event) → Optional[keyboardlayout.key.Key][source]

keysym_num is set on most keys and is platform independent If keysym_num is 0, we should use keycode which is platform-dependent

update_key(key: keyboardlayout.key.Key, key_info: keyboardlayout.common.KeyInfo)[source]

Update key_name’s image using key_info

keyboardlayout.layouts module

class keyboardlayout.layouts.HorizontalAnchor(value)[source]

Bases: enum.Enum

Enums used to set horizontal text location

CENTER = 'c'
LEFT = 'l'
RIGHT = 'r'
class keyboardlayout.layouts.LayoutConstant[source]

Bases: object

Constants used to acces data in keyboard layout yaml files

KEYS = 'keys'
KEY_SIZE = 'key_size'
LOCATION = 'location'
NAME = 'name'
ROWS = 'rows'
SIZE = 'size'
TXT_INFO = 'txt_info'
class keyboardlayout.layouts.LayoutName(value)

Bases: str, enum.Enum

An enum that holds the allowed layout names

AZERTY_LAPTOP = 'azerty_laptop'
QWERTY = 'qwerty'
class keyboardlayout.layouts.VerticalAnchor(value)[source]

Bases: enum.Enum

Enums used to set vertical text location

BOTTOM = 'b'
MIDDLE = 'm'
TOP = 't'
keyboardlayout.layouts.get_layout(layout_name: keyboardlayout.layouts.LayoutName) → Dict[source]

Module contents