mirror of https://github.com/kivy/kivy.git
core:Window improve screenshot method, closes #1455
This commit is contained in:
parent
28e726520b
commit
61ff0febd4
|
@ -733,14 +733,17 @@ class WindowBase(EventDispatcher):
|
||||||
elif key == 'center_y':
|
elif key == 'center_y':
|
||||||
w.center_y = value * height
|
w.center_y = value * height
|
||||||
|
|
||||||
def screenshot(self, name='screenshot%(counter)04d.png'):
|
def screenshot(self, name='screenshot{:04d}.png'):
|
||||||
'''Save the actual displayed image in a file
|
'''Save the actual displayed image in a file
|
||||||
'''
|
'''
|
||||||
i = 0
|
i = 0
|
||||||
path = None
|
path = None
|
||||||
|
if name != 'screenshot{:04d}.png':
|
||||||
|
_ext = name.split('.')[-1]
|
||||||
|
name = ''.join((name[:-(len(_ext) + 1)], '{:04d}.', _ext))
|
||||||
while True:
|
while True:
|
||||||
i += 1
|
i += 1
|
||||||
path = join(getcwd(), name % {'counter': i})
|
path = join(getcwd(), name.format(i))
|
||||||
if not exists(path):
|
if not exists(path):
|
||||||
break
|
break
|
||||||
return path
|
return path
|
||||||
|
@ -920,8 +923,8 @@ class WindowBase(EventDispatcher):
|
||||||
target attached if you're using the keyboard in a multi user
|
target attached if you're using the keyboard in a multi user
|
||||||
mode.
|
mode.
|
||||||
`input_type`: string
|
`input_type`: string
|
||||||
Choose the type of soft keyboard to request. Can be one of 'text',
|
Choose the type of soft keyboard to request. Can be one of
|
||||||
'number', 'url', 'mail', 'datetime', 'tel', 'address'.
|
'text', 'number', 'url', 'mail', 'datetime', 'tel', 'address'.
|
||||||
|
|
||||||
.. versionadded:: 1.8.0
|
.. versionadded:: 1.8.0
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue