-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
269 lines (251 loc) · 5.79 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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
import time
from kivy.uix.boxlayout import BoxLayout
from kivy.uix.floatlayout import FloatLayout
from kivy.uix.anchorlayout import AnchorLayout
from kivy.uix.pagelayout import PageLayout
from kivy.uix.gridlayout import GridLayout
from kivy.properties import ObjectProperty
from kivy.core.image import Image
from kivy.uix.button import Button
from kivy.uix.label import Label
from kivy.lang import Builder
from kivy.app import App
from kivy.uix.screenmanager import Screen, ScreenManager , FadeTransition
#from kivy.uix.camera import Camera
from plyer.facades import camera
from kivy.core.window import Window
from kivy.core.audio import SoundLoader
Builder.load_string(
'''
<StartScreen>:
GridLayout:
cols: 2
Button:
# text: "Button 1"
on_press: root.manager.current = "camera"
background_color: (0,1,0,0.5)
BoxLayout:
pos: self.parent.pos
size: self.parent.size
Image:
source: 'icon/icon.png'
pos: self.pos
size: self.size
Button:
# text: "Button 2"
on_press: root.manager.current = "audio"
background_color: (0,1,0,0.5)
BoxLayout:
pos: self.parent.pos
size: self.parent.size
Image:
source: 'icon/music_icon.png'
pos: self.pos
size: self.size
Button:
# text: "Button 3"
background_color: (0,1,0,0.5)
on_press: root.manager.current = "gallery"
BoxLayout:
pos: self.parent.pos
size: self.parent.size
Image:
source: 'icon/gallery.png'
pos: self.pos
size: self.size
Button:
text: ""
background_color: (0,1,0,0.5)
BoxLayout:
pos: self.parent.pos
size: self.parent.size
Image:
source: 'icon/credit.png'
pos: self.pos
size: self.size
<CameraScreen>:
BoxLayout:
orientation: "vertical"
Camera:
id: camera
resolution: (1024, 1024)
Button:
size_hint: None,None
width: '80dp'
height: '80dp'
pos: self.pos
background_color: 0, 1, 0, 0.5
on_press: root.manager.current = "start"
BoxLayout:
pos: self.parent.pos
size: self.parent.size
Image:
source: 'icon/back.png'
pos: self.pos
size: self.size
Button:
# text: "Capture photo"
size_hint: None, None
width: '80dp'
height: '80dp'
background_color: 255, 255, 255, 0.3
on_press: root.click_pic()
# pos_hint: 0.25
# pos: self.parent.x*0.25, self.parent.y
BoxLayout:
pos: self.parent.pos
size: self.parent.size
Image:
source: 'icon/capture.png'
pos: self.pos
size: self.size
<GalleryScreen>:
GridLayout:
orientation: 'vertical'
cols: 1
GridLayout:
cols: 2
padding: 5
spacing: 400
size_hint_y: None
height: self.minimum_height
Label:
text: "Gallery"
font_size: 40
Button:
text: "back"
on_press: root.manager.current = "start"
size_hint: None, None
height: '40dp'
width: '40dp'
ScrollView:
id: scroller
# size_hint:None, None
# size: 500, 320
# pos_hint: {'center_x': .5, 'center_y': .5},
# do_scroll_x:False
GridLayout:
cols: 4
padding: 10
spacing: 10
size_hint_y: None
height: self.minimum_height
id: gallery_layout
Image:
source: 'pics/yash.jpg'
size_hint_y: None
height: '40dp'
Image:
source: 'pics/yash.jpg'
size_hint_y: None
height: '240dp'
Image:
source: 'pics/yash.jpg'
size_hint_y: None
height: '240dp'
Image:
source: 'pics/yash.jpg'
size_hint_y: None
height: '240dp'
Image:
source: 'pics/yash.jpg'
size_hint_y: None
height: '240dp'
Image:
source: 'pics/yash.jpg'
size_hint_y: None
height: '240dp'
height: '240dp'
Image:
source: 'pics/yash.jpg'
size_hint_y: None
height: '240dp'
Image:
source: 'pics/yash.jpg'
size_hint_y: None
height: '240dp'
Image:
source: 'pics/yash.jpg'
size_hint_y: None
height: '240dp'
Image:
source: 'pics/yash.jpg'
size_hint_y: None
height: '240dp'
Image:
source: 'pics/yash.jpg'
size_hint_y: None
height: '240dp'
Image:
source: 'pics/yash.jpg'
size_hint_y: None
height: '240dp'
Image:
source: 'pics/yash.jpg'
size_hint_y: None
height: '240dp'
Image:
source: 'pics/yash.jpg'
size_hint_y: None
height: '240dp'
Image:
source: 'pics/yash.jpg'
size_hint_y: None
height: '240dp'
Image:
source: 'pics/yash.jpg'
size_hint_y: None
# Button:
# on_press: root.AddImage()
<AudioScreen>:
GridLayout:
cols: 1
Button:
text: "hello"
on_press: root.define()
Button:
id: btn
text: "press"
''')
camera = ObjectProperty(None)
gallery_layout = ObjectProperty(None)
class StartScreen(Screen):
pass
class AudioScreen(Screen):
def define(self):
print "entered into define"
btn = self.ids['btn']
btn.bind(on_press=self.playmusic)
def playmusic(self,*args):
print "played"
s = SoundLoader.load('example.wav')
print "hey executed"
# sound.volume = 0.5
# sound.play()
class CameraScreen(Screen):
# def changei(x):
# return str(int(x) + 1)
def click_pic(self):
camera = self.ids['camera']
timestr = time.strftime("%d-%m-%Y_%H:%M:%S")
camera.export_to_png("IMG_" + timestr)
print "Captured"
print time.strftime("%d%m%Y_%H%M%S")
class GalleryScreen(Screen):
# def __init__(self):
# self.AddImage()
def AddImage(self):
gallery_layout = self.ids['gallery_layout']
# for i in range(0,11):
# im = Image(source='gallery.png')
# gallery_layout.add_widget(im)
sm = ScreenManager(transition=FadeTransition())
sm.add_widget(StartScreen(name="start"))
sm.add_widget(CameraScreen(name="camera"))
sm.add_widget(GalleryScreen(name="gallery"))
sm.add_widget(AudioScreen(name="audio"))
class CameraApp(App):
sm.current = "gallery"
def build(self):
return sm
CameraApp().run()