Keyboard

Documentation coming soon.

class keyboard.KeyLabel(**kwargs)

A label that has specific styling and animation for the ScreencastKeys display for keyboard presses.

auto_remove()

Removes itself from the ScreencastKeys display.

trigger_fade()

Internal. Triggers a text fade-out animation.

class keyboard.KeyboardMap(context, **kwargs)

Instancing a KeyboardMap in your class allows that class to map key presses to any function defined in Quantum or your plugin.

Parameters:

context – The parent object of this keyboard.

Variables:
  • _keymap – A dict which maps a keypress tuple to a user-friendly label which represents a function defined by your object.
  • _funcmap – A dict which maps user-friendly function labels to the actual function defined by your object.
  • _keyfuncInternal Combines the _keymap and _funcmap into a single dict. This is what is actually used to execute functions.
  • parent – The object that the KeyboardMap is attached to.
  • _keyboard – The keypress listener.
  • keyboards – A registry that holds all KeyboardMap instances.

Your classes will primarily be using the _keymap and _keyfunc attributes. The choice of user-friendly key labels used to identify your functions is up to you. Here is an example of how you might define some of these maps:

self.kb._keymap = {(96, '`'): 'screen_sweep',
                   (96, '`', 'ctrl'): 'all_sweep'
                   }
self.kb._funcmap = {'screen_sweep': self.console_ui.screen_sweep,
                    'all_sweep': self.all_sweep
                    }

This will map the backtick keypress to the function self.console_ui.screen_sweep(). It also maps the backtick + ctrl keypress to the self.all_sweep() function. Notice that you will need to know the numeric keycodes for each keypress. They are mapped as follows:

keycodes = {
    # specials keys
    'backspace': 8, 'tab': 9, 'enter': 13, 'rshift': 303, 'shift': 304,
    'alt': 308, 'rctrl': 306, 'lctrl': 305,
    'super': 309, 'alt-gr': 307, 'compose': 311, 'pipe': 310,
    'capslock': 301, 'escape': 27, 'spacebar': 32, 'pageup': 280,
    'pagedown': 281, 'end': 279, 'home': 278, 'left': 276, 'up':
    273, 'right': 275, 'down': 274, 'insert': 277, 'delete': 127,
    'numlock': 300, 'print': 144, 'screenlock': 145, 'pause': 19,

    # a-z keys
    'a': 97, 'b': 98, 'c': 99, 'd': 100, 'e': 101, 'f': 102, 'g': 103,
    'h': 104, 'i': 105, 'j': 106, 'k': 107, 'l': 108, 'm': 109, 'n': 110,
    'o': 111, 'p': 112, 'q': 113, 'r': 114, 's': 115, 't': 116, 'u': 117,
    'v': 118, 'w': 119, 'x': 120, 'y': 121, 'z': 122,

    # 0-9 keys
    '0': 48, '1': 49, '2': 50, '3': 51, '4': 52,
    '5': 53, '6': 54, '7': 55, '8': 56, '9': 57,

    # numpad
    'numpad0': 256, 'numpad1': 257, 'numpad2': 258, 'numpad3': 259,
    'numpad4': 260, 'numpad5': 261, 'numpad6': 262, 'numpad7': 263,
    'numpad8': 264, 'numpad9': 265, 'numpaddecimal': 266,
    'numpaddivide': 267, 'numpadmul': 268, 'numpadsubstract': 269,
    'numpadadd': 270, 'numpadenter': 271,

    # F1-15
    'f1': 282, 'f2': 283, 'f3': 284, 'f4': 285, 'f5': 286, 'f6': 287,
    'f7': 288, 'f8': 289, 'f9': 290, 'f10': 291, 'f11': 292, 'f12': 293,
    'f13': 294, 'f14': 295, 'f15': 296,

    # other keys
    '(': 40, ')': 41,
    '[': 91, ']': 93,
    '{': 123, '}': 125,
    ':': 58, ';': 59,
    '=': 61, '+': 43,
    '-': 45, '_': 95,
    '/': 47, '*': 42,
    '?': 47,
    '`': 96, '~': 126,
    '´': 180, '¦': 166,
    '\': 92, '|': 124,
    '"': 34, "'": 39,
    ',': 44, '.': 46,
    '<': 60, '>': 62,
    '@': 64, '!': 33,
    '#': 35, '$': 36,
    '%': 37, '^': 94,
    '&': 38, '¬': 172,
    '¨': 168, '…': 8230,
    'ù': 249, 'à': 224,
    'é': 233, 'è': 232,
}
build_keyfunc()

This maps functions to key presses.

class keyboard.ScreencastKeys

This widget displays the mouse and keystrokes on screen as they happen. It is implemented as a singleton.

To use, set main.screencast = True

Variables:
  • instance – An instance of __ScreencastKeys
  • ignored_objects – The set of objects to ignore while screencasting.
Class __ScreencastKeys:
 

A nested class that gets instanced and assigned to instance in order to make a singleton. This nested class defines the behavior for the screencast keys display.

TODO: Need a better way to register/deregister ignored objects that does not require rebinding everything.

classmethod deregister_ignored_object(obj)

This removes an object from our ignored set so that ScreencastKeys will remain active when the object obj has focus.

TODO: How do we tell all instances to unbind from deregistered objects?

classmethod register_ignored_object(obj)

When ignored objects have focus, ScreencastKeys will deactivate. This function registers a new ignored object for tracking its focus.

Typography

Kivy uses bb code to determine font styling and variations. But writing these tags throughout the code will quickly become unmanageable; especially if a consistent style is desired throughout the app. Imagine if you had to write [font='Helvetica'][b][size='20sp'][/size][/b][/font] every time you needed to render a title. Now if you wanted to update the look of titles, you would need to locate every instance where this occurs and change them all.

The purpose of the Typography module is to alleviate this problem by serving as a centralized control for typography used within Quantum. Here, we define all the fonts that we may need as well as convenience functions that will allow us to reproduce the same styles throughout the app. By defining the styles in one location, we can also easily make updates to the look of the app by changing them here.

class typography.MarkupFactory(**kwargs)

A callable class that wraps text with appropriate bbcode to control display formatting. You can create instances of MarkupFactory to define different styles. For example:

>>> header = MarkupFactory(size=20, bold=True)
>>> body = MarkupFactory(size=10, font='Helvetica', bold=False)
>>> header('My Title')
[size=20][b]My Title[/b][/size]
>>> body('The quick brown fox ate a mouse')
[size=10][font='Helvetica']The quick brown fox ate a mouse[/font][/size]
class typography.Styles

This is a registry class to store common markup styles used in Quantum to permit a uniform look and feel throughout the application.

Variables:
  • title_cat – Used for category text in panel titles.
  • title_name – Used for panel names in panel titles.
  • title_icon – Used for panel icons in the title bar.
  • loading – Used for the loading status message.
  • category – Used for category text in cell titles.
  • cell_title – Used for names of cells in cell titles.
  • context_title – Used for the context menu.
  • code – Used for fixed width text.
  • quantum – Used for the ‘Quantum’ banner on the loading screen.
  • cell_id – Used in for the cell_id in the cell titles.
  • menu_item – Used for context menu.
classmethod color(text, col)

Wraps text in a color tag using a particular color of your choosing.

Parameters:
  • text (String) – The text to color.
  • col (String) – The desired color to render. This should be a hex code.
classmethod icon(text, fnt)

Wraps text in a font tag with the font of your choice. Intended to be used for icon fonts where you need to convert a single character to an icon.

Parameters:
  • text (String) – The character(s) to convert to icons.
  • fnt (String) – The icon font name.
classmethod title(text)

A convenience function to construct a cell title. It assumes the title category is separated from the cell name by a space and the category is a single word.

Parameters:text (String) – The title text.

Example:

>>> Styles.title("Example My Title")
[font='Exo2'][b][size='15sp']Example[/size][/b][/font] [font='Exo2'][size='15sp']My Title[/size][/font]

Galaxy Effect

This module provides objects that allow you to manage the glsl screen effects.

class galaxy_effect.GalaxyEffect(*args, **kwargs)

Creates a Galaxy image

class galaxy_effect.GalaxyWidget(**kwargs)

Renders GLSL code.

class galaxy_effect.GradientEffect(*args, **kwargs)

Creates a Gradient image

class galaxy_effect.ImageEffect(*args, **kwargs)

Displays an image

class galaxy_effect.LoadingEffect(*args, **kwargs)

Creates a random loading screen

Themeable Module

Provides widgets with theme config integration.

class themeable.Themeable(config_title=None, **kwargs)

Inherit from Themeable to parameterize and integrate widget colors with Quantum’s config system. Your widget is automatically registered with Themeable colors at instantiation if you inherit from this class.

Parameters:config_title – A string that will be used as the config title display name as well as the section title in the ini file. You can omit this from a particular instance to disallow color configurations for that instance.

Suppose your Themeable object is defined like this:

class MyClass(Themeable):
    def __init__(self, **kwargs):
        super().__init__(**kwargs)
        self.foreground = 'FFFFFFFF'
        self.background = '000000FF'

If your class is a singleton, you can provide a config_title at instantiation since you know there will only ever be one instance:

def __init__(self, **kwargs):
    super().__init__(self, config_title='My Class', **kwargs)
    # ... yada, yada
    # You will then need to provide your mappings:
    self.add_picker('fg', 'Foreground Color', 'The foreground.')
    self.add_attribute('fg', 'foreground')

That’s it!

If you have a more common situation where you may have multiple instances of your class, then you probably want to have a different config_title for each instance. In that case, you could define the initialization function in the following manner:

def __init__(self, config_title=None, **kwargs):
    super().__init__(config_title=config_title, **kwargs)
    # ... yada, yada

Each time you instance your class, you could provide the config_title for that instance. If you want the same color picker options for each instance, you could map them in the __init__() using the Themeable.add_picker() and Themeable.add_attribute() functions. Otherwise, you will want to map each instance on a case-by-case basis. If you omit the config_title, config options will be disabled for that instance.

If you are instantiating your class from a kv file, you can provide the config_title value in the kv file like so:

MyClass:
    id: my_class1
    config_title: None

MyClass:
    id: my_class2
    config_title: 'My Class 2'

In this case, my_class1 will not have configurable colors because we have set the config_title to None. The second instance will have configurable colors and appear under section titled My Class 2.

Tip

In some cases, you may need to wait until your object is allocated before you register your object with config settings. If this is the case, you can do so by scheduling the _post_init() function with Clock or simply calling the function after you have an instance of your class:

def __init__(self, **kwargs):
    super().__init__(**kwargs)
    # ... yada, yada
    Clock.schedule_once(super()._post_init, 0)

This is usually neccessary when you are assiging the config_title from a kv file because the config_title will not be set until after the object is allocated into memory.

add_attribute(key, attr)

Associate a key to the color attribute of your widget. This tells Quantum which key changes what color component. Themeable also remembers what was the original color format of each attribute so that it will correctly output back to that format when it assigns colors from saved config settings.

Parameters:
  • key – A unique string identifier for an attribute that exists in your client object.
  • attr – The exact string name of the attribute in your object.
add_attributes(attributes)

Add several attribute maps at once in a single dict. The keys and attribute names should be strings.

Parameters:attributes

Additional attributes to be added to the mapping.

Example format:

{'fg': 'foreground',
 'bg': 'background'}
add_picker(key, name, desc)

Add a color picker to the config screens.

Parameters:
  • key – A unique identifier for a color config option.
  • name – The display name of a config option associated with the unique key.
  • desc – A long description of the config option.
add_pickers(pickers)

Add several color pickers to config screens in a single dict. The keys should be strings and the values should be a 2-tuple.

Parameters:pickers

Additional pickers to add formatted as a dict.

Example format:

{'fg': ('Foreground', 'Color of the foreground.'),
 'bg': ('Background', 'Color of the background.')}
static json(config)

Documentation coming soon.

json_data

Documentation coming soon.

pickers

Documentation coming soon.

static refresh_colors()

Documentation coming soon.

register(*largs)

Documentation coming soon.

section_title

Documentation coming soon.

Quantum Settings

Provides additional settings control widgets.

class quantum_settings.SettingColorPicker(**kwargs)

Implementation of a string setting on top of a SettingItem. It is visualized with a Label widget that, when clicked, will open a Popup with a Textinput so the user can enter a custom value.

popup

(internal) Used to store the current popup when it’s shown.

popup is an ObjectProperty and defaults to None.

textinput

(internal) Used to store the current textinput from the popup and to listen for changes.

popup is an ObjectProperty and defaults to None.