Skip to main content

A python library to display different keyboards

Project description

keyboardlayout

A python library to display different keyboards. The keyboard layouts are created with pygame sprites. PRs with additional layouts or graphics backends are welcome.

If you need to show your users a graphic that shows a specific keyboard layout or a portion of a keyboard, this is the library for you.

Features:

  • qwerty + azerty included
  • dynamically generate a pygame sprite group showing a keyboard
  • customize the keyboard with sizes, colors, key margin, padding, font, location, etc
  • update a specific key with update_key

Documentation

https://spacether.github.io/keyboardlayout/

Examples

qwerty with colors

qwerty colored

qwerty

qwerty

azerty laptop

azerty_laptop

Installation

Make sure that you are using Python3

pip install keyboardlayout

Samples

Usage

import keyboardlayout as kl
import pygame

layout_name = 'qwerty'
pygame.init()

key_size = 60
grey = pygame.Color('grey')
keyboard_info = kl.KeyboardInfo(
    position=(0, 0),
    padding=2,
    color=~grey
)
key_info = kl.KeyInfo(
    margin=10,
    color=grey,
    txt_color=~grey,  # invert grey
    txt_font=pygame.font.SysFont('Arial', key_size//4),
    txt_padding=(key_size//6, key_size//10)
)
letter_key_size = (key_size, key_size),  # width, height
keyboard_layout = kl.KeyboardLayout(
    layout_name,
    keyboard_info,
    letter_key_size,
    key_info
)

screen = pygame.display.set_mode(
    (keyboard_layout.rect.width, keyboard_layout.rect.height))
screen.fill(pygame.Color('black'))

keyboard_layout.draw(screen)
pygame.display.update()

running = True
while running:
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            pygame.display.quit()
            running = False

pygame.quit()

Local Installation

# make and activate virtual env
python3 -m venv venv
source venv/bin/activate

# if you want to edit the program and have the library use your edits
make develop

# to install separately in your virtual environment
make install

Test

make test

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

keyboardlayout-1.0.0.tar.gz (8.6 kB view details)

Uploaded Source

Built Distribution

keyboardlayout-1.0.0-py3-none-any.whl (8.6 kB view details)

Uploaded Python 3

File details

Details for the file keyboardlayout-1.0.0.tar.gz.

File metadata

  • Download URL: keyboardlayout-1.0.0.tar.gz
  • Upload date:
  • Size: 8.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.8.6

File hashes

Hashes for keyboardlayout-1.0.0.tar.gz
Algorithm Hash digest
SHA256 1d5b1f050b6fa7b346d6173f4704bbefa64a2674c6b4a39f568028c218a86225
MD5 6ec49cea92b4d7ebb14e5e48d80bb69d
BLAKE2b-256 e55caa22e4d0688087871798854880244a0304f64a2bd23cc9f82b3a9521e724

See more details on using hashes here.

File details

Details for the file keyboardlayout-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: keyboardlayout-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 8.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.8.6

File hashes

Hashes for keyboardlayout-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 99dff168445f2ff7232628b7fd3abbcf7f75ed2dae203e0815811ecc12f963be
MD5 462bc283e40735fabf65ceb5a3e7d962
BLAKE2b-256 59c1d797b4aeef9ca43b83dd52a1c2437d9878ffdd203b2628a5a8dd4c54d608

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page