Skip to main content

MathKeyboardEngine provides the logic for a highly customizable virtual math keyboard. It is intended for use together with any LaTeX typesetting library.

Project description

latest release

MathKeyboardEngine for Python

MathKeyboardEngine for Python provides the logic for a highly customizable virtual math keyboard. It is intended for use together with any LaTeX typesetting library (for example matplotlib.mathtext).

Also available:

An execution timeline

todo. For now, see the JavaScript repo.

Let me test it now!

Live examples can be tested at MathKeyboardEngine.GitHub.io.

Pros and cons?

Unique about MathKeyboardEngine:

  • it supports (almost?) all math mode LaTeX, including matrices. (Please share if you know anything that is not supported.)
  • its syntax tree consists of very few different parts: the StandardLeafNode, StandardBranchingNode, AscendingBranchingNode and DescendingBranchingNode can be used for almost all LaTeX, including fractions, powers, combinations, subscript, etc. with ready-to-use up/down/left/right navigation.
  • it can be used with any LaTeX math typesetting library you like.

A con:

  • this library will never be able to handle setting the cursor with the touch of a finger on a typeset formula. (But it DOES support up/down/left/right navigation and has a selection mode via arrow keys.)

More pros:

  • you have full control over what you display on the virtual keyboard keys and what a virtual key press actually does.
  • customize the editor output at runtime: dot or comma as decimal separator, cross or dot for multiplication, cursor style, colors, etc.
  • this library also supports handling input from a physical keyboard, where - for example - the forward slash "/" key can be programmed to result in encapsulating a previously typed number as the numerator of a fraction. (See the examples.)
  • almost forgotten: it's open source, free to use, free to modify (please fork this repo)!

How to use this library

This library has been distributed via PyPi.

Install Python and VS Code.

For installing a specific version of mathkeyboardengine - for example 0.1.0-alpha.12 - run the following command in the VS Code Terminal:

py -m pip install mathkeyboardengine==0.1.0a12

Then create a new folder 'MathKeyboardEngineTest' and open it in VS Code. Add a file main.py with the following content:

from mathkeyboardengine import *

k = KeyboardMemory()
latexconfiguration = LatexConfiguration()

insert(k, DigitNode('2'))
insert_with_encapsulate_current(k, AscendingBranchingNode('', '^{', '}'))
insert(k, StandardLeafNode('x'))

print(get_edit_mode_latex(k, latexconfiguration))

Press the play button in the upper-right corner of VS Code. The result that is displayed in the Terminal:

2^{x\blacksquare}

Documentation

todo. For now, see the JavaScript repo.

How to use this repo

Follow these steps to set up (and verify) a development environment for this repository:

  1. Install the latest version of Python via https://www.python.org/downloads. The download includes pip.
  2. Open the Terminal in VS Code and run
    py -m pip install -U pytest.
  3. Run all tests via
    py -m pytest.
  4. See code coverage:
    py -m pip install pytest-cov
    py -m pytest --cov=src --cov-report term-missing.
  5. Run all tests for multiple versions of python and multiple operating systems:
    py -m pip install --upgrade nox
    py -m nox (this uses noxfile.py from the root of the repository).
  6. If you're interested all the release steps, see _disthelper/release_steps.txt.

Ask or contribute

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

mathkeyboardengine-0.1.0a23.tar.gz (13.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mathkeyboardengine-0.1.0a23-py3-none-any.whl (24.9 kB view details)

Uploaded Python 3

File details

Details for the file mathkeyboardengine-0.1.0a23.tar.gz.

File metadata

  • Download URL: mathkeyboardengine-0.1.0a23.tar.gz
  • Upload date:
  • Size: 13.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.1

File hashes

Hashes for mathkeyboardengine-0.1.0a23.tar.gz
Algorithm Hash digest
SHA256 2d8bad26cf24203c12929dd55f6a0198a12a33dc5c6a3e4efb72d19169cb0f81
MD5 cba37118d8a1dce02ab5d5df7bd83283
BLAKE2b-256 1d0ee29ab3965d3dcc48c155f46cc7c11791fb95441161de7fd712d18dfc78de

See more details on using hashes here.

File details

Details for the file mathkeyboardengine-0.1.0a23-py3-none-any.whl.

File metadata

File hashes

Hashes for mathkeyboardengine-0.1.0a23-py3-none-any.whl
Algorithm Hash digest
SHA256 d39f346ba37c056d34460593d3023fd4afe41f54a189899c87d229a754105bb4
MD5 dfd4f5fca1cfac2987c371d822a0c46e
BLAKE2b-256 97e2d28de8db34ce85ce0fb613d0f984dcdc724e93db7f0617f9ae1818d18168

See more details on using hashes here.

Supported by

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