-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
94 lines (73 loc) · 3.12 KB
/
main.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
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
from kivy.app import App
from kivy.uix.image import Image
from kivy.properties import ObjectProperty
from kivy.uix.listview import ListView, SimpleListAdapter
from kivy.uix.label import Label
from imagemodel import ImageModel
from kivy.uix.button import Button
from kivy.factory import Factory
from buttonmodel import ButtonModel
from labelmodel import LabelModel
from kivy.core.window import Window
class ButtonWithModel(Button):
def __init__(self,model, **kwargs):
self.model = model
super().__init__(**kwargs)
class LabelWithModel(Label):
def __init__(self,model, **kwargs):
self.model = model
super().__init__(**kwargs)
class ImageWithModel(Image):
def __init__(self,model, **kwargs):
self.model = model
super().__init__(**kwargs)
class MainApp(App):
image = ObjectProperty()
exif = ObjectProperty()
def build(self):
Window.bind(on_keyboard=self.on_keyboard)
self.start_app()
def on_keyboard(self, window, key, scancode, codepoint, modifier):
if modifier == ['ctrl'] and codepoint == 'r':
self.image.model.rotate_right()
if modifier == ['ctrl'] and codepoint == 'l':
self.image.model.rotate_left()
if modifier == ['ctrl'] and codepoint == 'o':
self.exif.model.open_image()
if modifier == ['ctrl'] and codepoint == 'e':
self.exif.model.get_exif_data()
if modifier == ['ctrl'] and codepoint == 'n':
self.exif.model.next_image()
if modifier == ['ctrl'] and codepoint == 'p':
self.exif.model.previous_image()
if modifier == ['ctrl'] and codepoint == 'g':
self.exif.model.get_location()
def start_app(self):
labels = [LabelModel() for _ in range(100)]
self.image = Factory.MainImage(ImageModel())
self.root.ids.image_box.add_widget(self.image)
self.exif = Factory.GetExifData(ButtonModel(image=self.image, labels=labels))
self.root.ids.button_box.add_widget(self.exif)
right = Factory.RotateRight(self.exif.model)
self.root.ids.button_box.add_widget(right)
left = Factory.RotateLeft(self.exif.model)
self.root.ids.button_box.add_widget(left)
loc = Factory.GetLocation(self.exif.model)
self.root.ids.button_box.add_widget(loc)
next = Factory.NextImage(self.exif.model)
self.root.ids.cycle_box.add_widget(next)
prev = Factory.PreviousImage(self.exif.model)
self.root.ids.cycle_box.add_widget(prev)
get = Factory.OpenImage(self.exif.model)
self.root.ids.button_box.add_widget(get)
lab = Factory.ExifLabel(LabelModel())
self.root.ids.exif_container.add_widget(lab)
list_adapter = SimpleListAdapter(
data=labels,
args_converter=lambda row, model: {'model': model,
'size_hint_y': None,
'height':100},
cls=Factory.ExifTags)
self.root.ids.exif_container.add_widget(ListView(adapter=list_adapter))
if __name__ == "__main__":
MainApp().run()