VKeyboard: Virtual keyboard with custom layout support
Bases: pymt.ui.widgets.scatter.MTScatterWidget
MTVKeyboard is an onscreen keyboard with multitouch support. Its layout is entirely customizable and you can switch between available layouts using a button in the bottom right of the widget.
| Parameters : |
|
|---|---|
| Events : |
|
List of internal actions available :
Add a custom layout class on MTVKeyboard
Clear the text
Return the key + size info on the current layout, at the coordinate (x, y)
Get/set mode of vkeyboard (NORMAL, SHIFT...)
Get/set text string on vkeyboard
Bases: object
Base for all Keyboard Layout
Bases: pymt.ui.widgets.composed.vkeyboard.KeyboardLayout
Implementation of QWERTY Layout
Bases: pymt.ui.widgets.composed.vkeyboard.KeyboardLayout
Implementation of AZERTY Layout
File ui_widgets_composed_vkeyboardspellcheck.py
from pymt import *
m = MTTextInput(keyboard=MTSpellVKeyboard(), font_size=42)
runTouchApp(m)
File ui_widgets_composed_vkeyboard_numerical.py
from pymt import *
# create a custom layout, a numerical one
class NumericKeyboardLayout(KeyboardLayout):
ID = 'numeric'
TITLE = 'Numeric keyboard'
DESCRIPTION = ''
SIZE = (4, 4)
NORMAL_1 = [
('7', '7', None, 1), ('8', '8', None, 1), (u'9', u'9', None, 1),
(u'\u2a2f', None, 'escape', 1),
]
NORMAL_2 = [
('4', '4', None, 1), ('5', '5', None, 1), (u'6', u'6', None, 1),
]
NORMAL_3 = [
('1', '1', None, 1), ('2', '2', None, 1), (u'3', u'3', None, 1),
(u'\u232b', None, 'backspace', 1),
]
NORMAL_4 = [
('0', '0', None, 1), (',', ',', None, 2),
(u'\u23ce', None, 'enter', 1)
]
# create a keyboard, with our custom layout
k = MTVKeyboard(layout=NumericKeyboardLayout(), size=(400, 300))
# create a instance of textinput, with this keyboard by default
m = MTTextInput(keyboard=k)
runTouchApp(m)
File ui_widgets_composed_vkeyboard.py
from pymt import *
keyboard = MTVKeyboard()
@keyboard.event
def on_key_down(*largs):
print 'key down:', largs
@keyboard.event
def on_key_up(*largs):
print 'key up:', largs
@keyboard.event
def on_text_change(*largs):
print 'text change', largs
runTouchApp(keyboard)