aboutsummaryrefslogtreecommitdiffstats
path: root/tagit/__init__.py
blob: 8c4285a372b10fc4b58b181b40b5fac2cc86efe8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
"""Tagit standalone user interfaces.

Tagit contains several submodules:
* apps: Launchable standalone applications.
* windows: Compositions of various UI functionality.
* widgets: Individual UI components and core functions.
* dialogues: Pop-up dialogues.
* actions: Single actions that can be performed on widgets.
* tiles: Display a digestible amount of information.

Additional core functionality is provided by some generic
modules (utils, parsing, config, etc.).

Part of the tagit module.
A copy of the license is provided with the project.
Author: Matthias Baumgartner, 2022
"""
# standard imports
import collections
import os
import typing

import kivy.config
kivy.config.Config.set('input', 'mouse', 'mouse,disable_multitouch')

# kivy imports
from kivy.resources import resource_add_path
import kivy

# constants
T_VERSION_INFO = collections.namedtuple('T_VERSION_INFO', ('major', 'minor', 'micro'))
version_info = T_VERSION_INFO(0, 0, 1)

# exports
__all__: typing.Sequence[str] = []


## code ##

# check kivy version
kivy.require('1.9.1')

# add resources
resource_add_path(os.path.join(os.path.dirname(__file__), 'assets', 'icons', 'kivy'))
resource_add_path(os.path.join(os.path.dirname(__file__), 'assets', 'fonts', 'kivy'))
resource_add_path(os.path.join(os.path.dirname(__file__), 'assets', 'themes'))
resource_add_path(os.path.join(os.path.dirname(__file__), 'assets'))

# load font
from kivy.core.text import LabelBase
LabelBase.register(name='Unifont', fn_regular='Unifont.ttf')

# logging
# the default logger is quite verbose. Should be restricted by the app.
import logging
from . import logger
loghandler = logger.logger_config(
    handler=logging.StreamHandler(),
    colors=logger.ColorsTerminal,
    config=dict(
        level='DEBUG',
        fmt='[{levelname}] [{module:<12}] {title}{message}',
        title='[{title}] ',
        filter=['tagit'],
        )
    )

termlogger = logging.getLogger(__name__)
termlogger.addHandler(loghandler)
termlogger.setLevel(logging.DEBUG)

# console logging fix:
# kivy adds an extra whitespace in front of tagit log entries.
# Adding a carriage return in front of the log fixes this bug.
# This is only needed for the console log handler, not others.
# Note that this mechanism is repeated in apps/gui to
# achieve the same for user-defined log handlers.
loghandler.formatter.prefix = '\r'

## EOF ##