def __init__(self, **kwargs):
        self.dwell_color = [eval(n) for n in Config.get('dwell', 'dwell_color').split(',')]
        self.dwell_width = Config.getfloat('dwell', 'dwell_width')
        self.dwell_time  = Config.getfloat('dwell', 'dwell_time')
        self.dwell_jitter_distance_ignore = Config.getfloat('dwell', 'dwell_jitter_distance_ignore')
        self.dwell_initial_wait_period  = Config.getfloat('dwell', 'dwell_initial_wait_period')

        # Add-on hack at the last moment, need the touch info from the dwell
        self.dwell_touch = None
        self.double_tap_touch = None

        super(DwellBase, self).__init__(**kwargs)
Example #2
0
    def add_screen(self, screen):
        self.screen_in.pos = self.screen_out.pos
        self.screen_in.size = self.screen_out.size
        self.manager.real_remove_widget(self.screen_out)

        self.fbo_in = self.make_screen_fbo(self.screen_in)
        self.fbo_out = self.make_screen_fbo(self.screen_out)
        self.manager.canvas.add(self.fbo_in)
        self.manager.canvas.add(self.fbo_out)

        screen_rotation = Config.getfloat('graphics', 'rotation')
        pos = (0, 1)
        if screen_rotation == 90:
            pos = (0, 0)
        elif screen_rotation == 180:
            pos = (-1, 0)
        elif screen_rotation == 270:
            pos = (-1, 1)

        self.render_ctx = RenderContext(fs=self.fs, vs=self.vs)
        with self.render_ctx:
            BindTexture(texture=self.fbo_out.texture, index=1)
            BindTexture(texture=self.fbo_in.texture, index=2)
            Rotate(screen_rotation, 0, 0, 1)
            Rectangle(size=(1, -1), pos=pos)
        self.render_ctx['projection_mat'] = Matrix().\
            view_clip(0, 1, 0, 1, 0, 1, 0)
        self.render_ctx['tex_out'] = 1
        self.render_ctx['tex_in'] = 2
        self.manager.canvas.add(self.render_ctx)
Example #3
0
    def add_screen(self, screen):
        self.screen_in.pos = self.screen_out.pos
        self.screen_in.size = self.screen_out.size
        self.manager.real_remove_widget(self.screen_out)

        self.fbo_in = self.make_screen_fbo(self.screen_in)
        self.fbo_out = self.make_screen_fbo(self.screen_out)
        self.manager.canvas.add(self.fbo_in)
        self.manager.canvas.add(self.fbo_out)

        screen_rotation = Config.getfloat('graphics', 'rotation')
        pos = (0, 1)
        if screen_rotation == 90:
            pos = (0, 0)
        elif screen_rotation == 180:
            pos = (-1, 0)
        elif screen_rotation == 270:
            pos = (-1, 1)

        self.render_ctx = RenderContext(fs=self.fs)
        with self.render_ctx:
            BindTexture(texture=self.fbo_out.texture, index=1)
            BindTexture(texture=self.fbo_in.texture, index=2)
            Rotate(screen_rotation, 0, 0 , 1)
            Rectangle(size=(1, -1), pos=pos)        
        self.render_ctx['projection_mat'] = Matrix().\
            view_clip(0, 1, 0, 1, 0, 1, 0)
        self.render_ctx['tex_out'] = 1
        self.render_ctx['tex_in'] = 2
        self.manager.canvas.add(self.render_ctx)
Example #4
0
__all__ = ('ScrollView', )

from functools import partial
from kivy.config import Config
from kivy.clock import Clock
from kivy.uix.stencilview import StencilView
from kivy.properties import NumericProperty, BooleanProperty, AliasProperty


# When we are generating documentation, Config doesn't exist
_scroll_timeout = _scroll_distance = _scroll_friction = 0
if Config:
    _scroll_timeout = Config.getint('widgets', 'scroll_timeout')
    _scroll_distance = Config.getint('widgets', 'scroll_distance')
    _scroll_friction = Config.getfloat('widgets', 'scroll_friction')


class ScrollView(StencilView):
    '''ScrollView class. See module documentation for more information.
    '''

    def __init__(self, **kwargs):
        self._viewport = None
        self._touch = False
        self._tdx = self._tdy = self._ts = self._tsn = 0
        self._scroll_y_mouse = 0
        super(ScrollView, self).__init__(**kwargs)
        self.bind(scroll_x=self.update_from_scroll,
                  scroll_y=self.update_from_scroll,
                  pos=self.update_from_scroll,
Example #5
0
from kivy.animation import Animation
from kivy.config import Config
from kivy.clock import Clock
from kivy.uix.stencilview import StencilView
from kivy.properties import NumericProperty, BooleanProperty, AliasProperty, \
    ObjectProperty, ListProperty

# When we are generating documentation, Config doesn't exist
_scroll_moves = _scroll_timeout = _scroll_stoptime = \
    _scroll_distance = _scroll_friction = 0
if Config:
    _scroll_timeout = Config.getint('widgets', 'scroll_timeout')
    _scroll_stoptime = Config.getint('widgets', 'scroll_stoptime')
    _scroll_distance = Config.getint('widgets', 'scroll_distance')
    _scroll_moves = Config.getint('widgets', 'scroll_moves')
    _scroll_friction = Config.getfloat('widgets', 'scroll_friction')


class FixedList(list):
    '''A list. In addition, you can specify the maximum length.
    This will save memory.
    '''
    def __init__(self, maxlength=0, *args, **kwargs):
        super(FixedList, self).__init__(*args, **kwargs)
        self.maxlength = maxlength

    def append(self, x):
        super(FixedList, self).append(x)
        self._cut()

    def extend(self, L):
Example #6
0
 def __init__(self):
     self.jitterdist = Config.getfloat('postproc', 'jitter_distance')
     ignore_devices = Config.get('postproc', 'jitter_ignore_devices')
     self.ignore_devices = ignore_devices.split(',')
     self.last_touches = {}
Example #7
0
 def __init__(self):
     self.jitterdist = Config.getfloat('postproc', 'jitter_distance')
     ignore_devices = Config.get('postproc', 'jitter_ignore_devices')
     self.ignore_devices = ignore_devices.split(',')
     self.last_touches = {}
Example #8
0
__all__ = ("ScrollView",)

from functools import partial
from kivy.animation import Animation
from kivy.config import Config
from kivy.clock import Clock
from kivy.uix.stencilview import StencilView
from kivy.properties import NumericProperty, BooleanProperty, AliasProperty, ObjectProperty, ListProperty


# When we are generating documentation, Config doesn't exist
_scroll_timeout = _scroll_distance = _scroll_friction = 0
if Config:
    _scroll_timeout = Config.getint("widgets", "scroll_timeout")
    _scroll_distance = Config.getint("widgets", "scroll_distance")
    _scroll_friction = Config.getfloat("widgets", "scroll_friction")


class ScrollView(StencilView):
    """ScrollView class. See module documentation for more information.
    """

    def __init__(self, **kwargs):
        self._touch = False
        self._tdx = self._tdy = self._ts = self._tsn = 0
        self._scroll_y_mouse = 1
        super(ScrollView, self).__init__(**kwargs)
        self.bind(
            scroll_x=self.update_from_scroll,
            scroll_y=self.update_from_scroll,
            pos=self.update_from_scroll,
Example #9
0
class Kpritz(App):
    bookname = StringProperty(Config.get('Kpritz', 'lastbook'))
    speed = NumericProperty(Config.getint('Kpritz', 'speed'))
    bg_color = ListProperty(
        map(float,
            Config.get('Kpritz', 'bg_color').split()))
    fg_color = ListProperty(
        map(float,
            Config.get('Kpritz', 'fg_color').split()))
    hl_color = ListProperty(
        map(float,
            Config.get('Kpritz', 'hl_color').split()))
    text_size = NumericProperty(Config.getfloat('Kpritz', 'text_size'))
    default_path = StringProperty(Config.get('Kpritz', 'default_path'))
    text = ListProperty([])
    position = NumericProperty(0)

    def build(self):
        root = Builder.load_string(KV)
        if self.bookname:
            try:
                self.open('', self.bookname)
            except IOError:
                self.bookname = ''

        return root

    def save_position(self):
        Config.set('Kpritz', self.bookname, self.position)

    def open(self, path, filename):
        if self.position:
            self.save_position()

        f = join(path, filename)
        Config.set('Kpritz', 'lastbook', f)
        self.bookname = f

        try:
            if f.endswith('.epub'):
                self.text = dump(f).split()

            elif f.endswith('.html'):
                h = html2text.HTML2Text()
                h.ignore_links = True
                h.unicode_snob = True
                h.ignore_images = True
                h.ignore_emphasis = True
                h.skip_internal_links = True
                with open(f) as fd:
                    self.text = h.handle(fd.read()).split()

            else:
                with open(f) as fd:
                    self.text = [
                        unicode(w, 'utf-8') for w in fd.read().split()
                    ]

        except Exception, e:
            p = Factory.ErrorPopup().open()
            p.message = str(e)

        try:
            self.position = Config.getint('Kpritz', f)
        except NoOptionError:
            self.position = 0
Example #10
0
from kivy.uix.slider import Slider
from kivy.uix.switch import Switch
from kivy.uix.widget import Widget

CHUNKSIZE = 2048
RATE = 44100

avatar = None
plot_widget = None

Config.read("concept.rc")
Config.adddefaultsection("avatar")
Config.setdefault("avatar", "volume", .5)
Config.write()

volume = Config.getfloat("avatar", "volume")

figure = matplotlib.figure.Figure()
lines = []

axs = figure.subplots(2, 1)

lines.extend(axs[0].plot(np.zeros(CHUNKSIZE)))
axs[0].set_xlim((0, CHUNKSIZE))
axs[0].set_ylim((-.2, .2))

FFT_CHUNK = 10 * CHUNKSIZE

fftfreq = np.fft.fftfreq(FFT_CHUNK, d=RATE / CHUNKSIZE / 1000000)
lines.extend(axs[1].plot(fftfreq[:FFT_CHUNK // 2], np.zeros(FFT_CHUNK // 2)))
axs[1].plot([0, FFT_CHUNK], [1, 1], "r-")