Skip to content

Commit aeffcd2

Browse files
committed
Merge branch 'master' of git://github.com/tito/kivy into pdf
2 parents 7c208d5 + 40b6032 commit aeffcd2

17 files changed

+83
-17
lines changed

examples/demo/showcase/main.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
from kivy.uix.label import Label
1717
from kivy.uix.popup import Popup
1818
from kivy.uix.accordion import Accordion, AccordionItem
19+
from kivy.uix.filechooser import FileChooserIconView, FileChooserListView
1920

2021

2122
class Showcase(FloatLayout):
@@ -60,22 +61,20 @@ def attach_node(text, n):
6061
n = create_tree('Buttons')
6162
attach_node('Standard buttons', n)
6263
attach_node('Options buttons', n)
63-
n = create_tree('Sliders')
6464
attach_node('Horizontal sliders', n)
6565
attach_node('Vertical sliders', n)
66-
n = create_tree('Scatter')
6766
attach_node('Scatter with image', n)
6867
attach_node('Scatter with buttons', n)
69-
n = create_tree('Textinput')
7068
attach_node('Monoline textinput', n)
7169
attach_node('Multiline textinput', n)
72-
n = create_tree('TreeView')
7370
attach_node('Standard treeview', n)
7471
attach_node('Treeview without root', n)
75-
n = create_tree('Others')
7672
attach_node('Accordion', n)
7773
attach_node('Popup', n)
7874
attach_node('Switch', n)
75+
n = create_tree('Experimentals')
76+
attach_node('Filechooser icon', n)
77+
attach_node('Filechooser list', n)
7978
root.add_widget(tree)
8079
self.content = content = BoxLayout()
8180
root.add_widget(content)
@@ -192,6 +191,12 @@ def show_accordion(self):
192191
col.add_widget(root)
193192
return col
194193

194+
def show_filechooser_icon(self):
195+
return FileChooserIconView()
196+
197+
def show_filechooser_list(self):
198+
return FileChooserListView()
199+
195200

196201
if __name__ in ('__main__', '__android__'):
197202
ShowcaseApp().run()

kivy/core/camera/__init__.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010

1111
import sys
1212

13-
from kivy.clock import Clock
1413
from kivy.event import EventDispatcher
1514
from kivy.logger import Logger
1615
from kivy.core import core_select_lib
@@ -58,7 +57,7 @@ def __init__(self, **kwargs):
5857
super(CameraBase, self).__init__()
5958

6059
self.register_event_type('on_load')
61-
self.register_event_type('on_frame')
60+
self.register_event_type('on_texture')
6261

6362
self.init_camera()
6463

@@ -101,13 +100,10 @@ def init_camera(self):
101100
def start(self):
102101
'''Start the camera acquire'''
103102
self.stopped = False
104-
Clock.unschedule(self._update)
105-
Clock.schedule_interval(self._update, 1. / 30)
106103

107104
def stop(self):
108105
'''Release the camera'''
109106
self.stopped = True
110-
Clock.unschedule(self._update)
111107

112108
def _update(self, dt):
113109
'''Update the camera (internal)'''
@@ -120,9 +116,9 @@ def _copy_to_gpu(self):
120116
return
121117
self._texture.blit_buffer(self._buffer, colorfmt=self._format)
122118
self._buffer = None
123-
self.dispatch('on_frame')
119+
self.dispatch('on_texture')
124120

125-
def on_frame(self):
121+
def on_texture(self):
126122
pass
127123

128124
def on_load(self):

kivy/core/camera/camera_gstreamer.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
__all__ = ('CameraGStreamer', )
66

7-
7+
from kivy.clock import Clock
88
from kivy.graphics.texture import Texture
99
from . import CameraBase
1010

@@ -77,7 +77,9 @@ def _gst_new_buffer(self, *largs):
7777
for x in self._decodebin.src_pads():
7878
for cap in x.get_caps():
7979
self._texturesize = (cap['width'], cap['height'])
80+
Clock.schedule_once(self._update)
8081
return
82+
Clock.schedule_once(self._update)
8183

8284
def start(self):
8385
super(CameraGStreamer, self).start()

kivy/core/camera/camera_opencv.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
__all__ = ('CameraOpenCV')
1010

1111
from kivy.logger import Logger
12+
from kivy.clock import Clock
1213
from kivy.graphics.texture import Texture
1314
from . import CameraBase
1415

@@ -59,6 +60,11 @@ def init_camera(self):
5960
# with self.init_camera (but slowly as we'd have to always get a frame).
6061
self._resolution = (int(frame.width), int(frame.height))
6162

63+
#get fps
64+
self.fps = cv.GetCaptureProperty(self._device, cv.CV_CAP_PROP_FPS)
65+
if self.fps <= 0:
66+
self.fps = 1 / 30.
67+
6268
if not self.stopped:
6369
self.start()
6470

@@ -83,3 +89,12 @@ def _update(self, dt):
8389
except:
8490
Logger.exception('OpenCV: Couldn\'t get image from Camera')
8591

92+
def start(self):
93+
super(CameraOpenCV, self).start()
94+
Clock.unschedule(self._update)
95+
Clock.schedule_interval(self._update, self.fps)
96+
97+
def stop(self):
98+
super(CameraOpenCV, self).stop()
99+
Clock.unschedule(self._update)
100+

kivy/core/camera/camera_videocapture.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
__all__ = ('CameraVideoCapture', )
1010

1111
from . import CameraBase
12+
from kivy.clock import Clock
1213

1314
try:
1415
from VideoCapture import Device
@@ -33,6 +34,7 @@ def init_camera(self):
3334
self._device.setResolution(self.resolution[0], self.resolution[1])
3435
except:
3536
raise Exception('VideoCapture: Resolution not supported')
37+
self.fps = 1 / 30.
3638

3739
def _update(self, dt):
3840
data, camera_width, camera_height = self._device.getBuffer()
@@ -47,3 +49,14 @@ def _update(self, dt):
4749
# update buffer
4850
self._buffer = data
4951
self._copy_to_gpu()
52+
53+
def start(self):
54+
super(CameraVideoCapture, self).start()
55+
Clock.unschedule(self._update)
56+
Clock.schedule_interval(self._update, self.fps)
57+
58+
def stop(self):
59+
super(CameraVideoCapture, self).stop()
60+
Clock.unschedule(self._update)
61+
62+

kivy/data/logo/kivy-icon-128.png

100644100755
9.24 KB
Loading

kivy/data/logo/kivy-icon-16.png

3.58 KB
Loading

kivy/data/logo/kivy-icon-24.png

100644100755
240 Bytes
Loading

kivy/data/logo/kivy-icon-256.png

100644100755
20.4 KB
Loading

kivy/data/logo/kivy-icon-32.png

100644100755
3.47 KB
Loading

kivy/data/logo/kivy-icon-512.png

100644100755
46.7 KB
Loading

kivy/data/logo/kivy-icon-64.png

100644100755
4.84 KB
Loading

kivy/data/style.kv

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,7 @@
201201
# Don't allow expansion of the ../ node
202202
is_leaf: not ctx.isdir or ctx.name.endswith('..' + ctx.sep) or self.locked
203203
on_touch_down: self.collide_point(*args[1].pos) and ctx.controller.entry_touched(self, args[1])
204+
on_touch_up: self.collide_point(*args[1].pos) and ctx.controller.entry_released(self, args[1])
204205
BoxLayout:
205206
pos: root.pos
206207
Label:
@@ -244,6 +245,7 @@
244245
size_hint: None, None
245246

246247
on_touch_down: self.collide_point(*args[1].pos) and ctx.controller.entry_touched(self, args[1])
248+
on_touch_up: self.collide_point(*args[1].pos) and ctx.controller.entry_released(self, args[1])
247249

248250
canvas:
249251
Color:

kivy/uix/camera.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,9 @@ def __init__(self, **kwargs):
8989
resolution=self._on_index)
9090
self._on_index()
9191

92+
def on_tex(self, *l):
93+
self.canvas.ask_update()
94+
9295
def _on_index(self, *largs):
9396
self._camera = None
9497
if self.index < 0:
@@ -98,6 +101,7 @@ def _on_index(self, *largs):
98101
self._camera.bind(on_load=self._camera_loaded)
99102
if self.play:
100103
self._camera.start()
104+
self._camera.bind(on_texture=self.on_tex)
101105

102106
def _camera_loaded(self, *largs):
103107
self.texture = self._camera.texture

kivy/uix/filechooser.py

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,9 @@ def __init__(self, **kwargs):
140140
self.register_event_type('on_submit')
141141
super(FileChooserController, self).__init__(**kwargs)
142142

143+
self._items = []
144+
self.bind(selection=self._update_item_selection)
145+
143146
if platform in ('darwin', 'linux2'):
144147
self.is_hidden = is_hidden_unix
145148
elif platform == 'win32':
@@ -151,6 +154,10 @@ def __init__(self, **kwargs):
151154
filters=self._trigger_update)
152155
self._trigger_update()
153156

157+
def _update_item_selection(self, *args):
158+
for item in self._items:
159+
item.selected = item.path in self.selection
160+
154161
def _trigger_update(self, *args):
155162
Clock.unschedule(self._update_files)
156163
Clock.schedule_once(self._update_files)
@@ -168,9 +175,12 @@ def on_remove_subentry(self, subentry, entry):
168175
pass
169176

170177
def on_submit(self, selected, touch=None):
171-
self.selection = []
178+
pass
172179

173180
def entry_touched(self, entry, touch):
181+
'''(internal) This method must be called by the template when an entry
182+
is touched by the user.
183+
'''
174184
if self.multiselect:
175185
if isdir(entry.path) and touch.is_double_tap:
176186
self.open_entry(entry)
@@ -181,10 +191,23 @@ def entry_touched(self, entry, touch):
181191
self.selection.append(entry.path)
182192
else:
183193
if isdir(entry.path):
184-
self.open_entry(entry)
194+
pass
185195
else:
186196
self.selection = [entry.path, ]
187-
self.dispatch('on_submit', [entry.path], touch)
197+
198+
def entry_released(self, entry, touch):
199+
'''(internal) This method must be called by the template when an entry
200+
is touched by the user.
201+
202+
.. versionadded:: 1.0.10
203+
'''
204+
if self.multiselect:
205+
pass
206+
else:
207+
if isdir(entry.path):
208+
self.open_entry(entry)
209+
elif touch.is_double_tap:
210+
self.dispatch('on_submit', self.selection, touch)
188211

189212
def open_entry(self, entry):
190213
try:
@@ -232,6 +255,7 @@ def get_nice_size(self, fn):
232255
def _update_files(self, *args):
233256
# Clear current files
234257
self.dispatch('on_entries_cleared')
258+
self._items = []
235259

236260
# Add the components that are always needed
237261
if platform == 'win32':
@@ -247,6 +271,7 @@ def _update_files(self, *args):
247271
pardir = Builder.template(self._ENTRY_TEMPLATE, **dict(name=back,
248272
size='', path=back, controller=self, isdir=True, parent=None,
249273
sep=sep, get_nice_size=lambda: ''))
274+
self._items.append(pardir)
250275
self.dispatch('on_entry_added', pardir)
251276
try:
252277
self._add_files(self.path)

kivy/uix/image.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,7 @@ def __init__(self, **kwargs):
250250

251251
def on_source(self, instance, value):
252252
if not value:
253+
self._coreimage.unbind(on_texture=self._on_tex_change)
253254
self.texture = None
254255
self._coreimage = None
255256
else:
@@ -271,4 +272,5 @@ def is_uri(self, filename):
271272
return proto in ('http', 'https', 'ftp')
272273

273274
def _on_tex_change(self, *largs):
274-
self.texture = self._coreimage.texture
275+
if self._coreimage:
276+
self.texture = self._coreimage.texture

kivy/uix/video.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,8 @@ def __init__(self, **kwargs):
9595
super(Video, self).__init__(**kwargs)
9696

9797
def texture_update(self, *largs):
98+
'''This method is a no-op in Video widget.
99+
'''
98100
pass
99101

100102
def on_source(self, instance, value):

0 commit comments

Comments
 (0)