forked from albertz/music-player
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTraits.py
55 lines (45 loc) · 1.59 KB
/
Traits.py
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
# MusicPlayer, https://github.com/albertz/music-player
# Copyright (c) 2012, Albert Zeyer, www.az2000.de
# All rights reserved.
# This code is under the 2-clause BSD license, see License.txt in the root directory of this project.
from contextlib import contextmanager
class TraitType: pass
# These types just say what a property/UserAttrib/object should behave like, i.e. what protocol it should support.
# This is not really defined yet/strictly. It is used for now by the GUI.
class List(TraitType):
def onInsert(self, index, value): pass
def onRemove(self, index): pass
def onClear(self): pass
@property
@contextmanager
def lock(self): yield
def insert(self, index, value): pass
def remove(self, index): pass
def clear(self): pass
def __getitem__(self, index): pass
def __len__(self): pass
class Table(List):
def __init__(self, keys, **kwargs):
self.keys = keys
self.formaters = {}
for key,value in kwargs.items():
if key.startswith("format_") and key[len("format_"):] in keys:
self.formaters[key[len("format_"):]] = value
else:
assert False, "%s argument unknown" % key
class Real(TraitType):
def __init__(self, min=None, max=None):
self.min = min
self.max = max
class EditableText(TraitType): pass
class OneLineText(TraitType): pass
class ClickableLabel(TraitType): pass
class Enum(TraitType):
def __init__(self, enums):
self.enums = enums
class Object(TraitType): pass
class Action(TraitType): pass
class Image(TraitType): pass
# For now, it's just easier to have the song display (song thumbnail + play cursor)
# as a special type.
class SongDisplay(TraitType): pass