mirror of https://github.com/kivy/kivy.git
pep8 fixes
This commit is contained in:
parent
0172a82cd9
commit
4c6690bd6f
|
@ -5,9 +5,9 @@ Take picture
|
|||
.. author:: Mathieu Virbel <mat@kivy.org>
|
||||
|
||||
Little example to demonstrate how to start an Intent, and get the result.
|
||||
When you use the Android.startActivityForResult(), the result will be dispatched
|
||||
into onActivityResult. You can catch the event with the android.activity API
|
||||
from python-for-android project.
|
||||
When you use the Android.startActivityForResult(), the result will be
|
||||
dispatched into onActivityResult. You can catch the event with the
|
||||
android.activity API from python-for-android project.
|
||||
|
||||
If you want to compile it, don't forget to add the CAMERA permission::
|
||||
|
||||
|
|
|
@ -81,7 +81,7 @@ class KivyRenderTextInput(CodeInput):
|
|||
ctrl, cmd = 64, 1024
|
||||
key, key_str = keycode
|
||||
|
||||
if text and not key in (list(self.interesting_keys.keys()) + [27]):
|
||||
if text and key not in (list(self.interesting_keys.keys()) + [27]):
|
||||
# This allows *either* ctrl *or* cmd, but not both.
|
||||
if modifiers == ['ctrl'] or (is_osx and modifiers == ['meta']):
|
||||
if key == ord('s'):
|
||||
|
|
|
@ -134,7 +134,7 @@ class GestureDatabase(GridLayout):
|
|||
if i.ids.select.state == 'down':
|
||||
self.selected_count -= 1
|
||||
for g in i.gesture_list:
|
||||
# if g in self.recognizer.db: # not needed, for testing
|
||||
# if g in self.recognizer.db: # not needed, for testing
|
||||
self.recognizer.db.remove(g)
|
||||
self.ids.gesture_list.remove_widget(i)
|
||||
|
||||
|
|
|
@ -2,9 +2,9 @@
|
|||
Custom Keyboards
|
||||
================
|
||||
|
||||
This demo shows how to create and display custom keyboards on screen. Note that
|
||||
the new "input_type" property of the TextInput means that this is rarely needed.
|
||||
We provide this demo for the sake of completeness.
|
||||
This demo shows how to create and display custom keyboards on screen.
|
||||
Note that the new "input_type" property of the TextInput means that this
|
||||
is rarely needed. We provide this demo for the sake of completeness.
|
||||
"""
|
||||
# Author: Zen-CODE
|
||||
from kivy.app import App
|
||||
|
@ -18,8 +18,8 @@ from kivy.config import Config
|
|||
from kivy.uix.screenmanager import Screen, ScreenManager
|
||||
from kivy import require
|
||||
|
||||
# This example uses features introduced in Kivy 1.8.0, namely being able to load
|
||||
# custom json files from the app folder
|
||||
# This example uses features introduced in Kivy 1.8.0, namely being able
|
||||
# to load custom json files from the app folder.
|
||||
require("1.8.0")
|
||||
|
||||
Builder.load_string('''
|
||||
|
@ -167,8 +167,8 @@ class KeyboardScreen(Screen):
|
|||
""" Add a buttons for each available keyboard layout. When clicked,
|
||||
the buttons will change the keyboard layout to the one selected. """
|
||||
layouts = list(VKeyboard().available_layouts.keys())
|
||||
layouts.append("numeric.json") # Add the file in our app directory
|
||||
# Note the .json extension is required
|
||||
# Add the file in our app directory, the .json extension is required.
|
||||
layouts.append("numeric.json")
|
||||
for key in layouts:
|
||||
self.kbContainer.add_widget(
|
||||
Button(
|
||||
|
|
|
@ -123,8 +123,8 @@ void main (void) {
|
|||
float dr = th / 10.;
|
||||
v = min(v, dr) / dr;
|
||||
|
||||
// calculate the distance between the center of the square and current pixel
|
||||
// display the pixel only if the distance is inside the circle
|
||||
// calculate the distance between the center of the square and current
|
||||
// pixel; display the pixel only if the distance is inside the circle
|
||||
float vdist = length(abs(tex_coord0 - center) * size / square);
|
||||
float value = 1 - v;
|
||||
if ( vdist < value ) {
|
||||
|
|
|
@ -196,7 +196,8 @@ class ShaderTreeApp(App):
|
|||
|
||||
def change(*largs):
|
||||
sw.fs = available_shaders[self.shader_index]
|
||||
self.shader_index = (self.shader_index + 1) % len(available_shaders)
|
||||
self.shader_index = ((self.shader_index + 1) %
|
||||
len(available_shaders))
|
||||
btn.bind(on_release=change)
|
||||
root.add_widget(btn)
|
||||
return root
|
||||
|
|
|
@ -59,7 +59,8 @@ fruit_data_list_of_dicts = [
|
|||
{
|
||||
'name': 'Cantaloupe',
|
||||
'Serving Size': '1/4 medium (134 g/4.8 oz)',
|
||||
'data': [50, 0, 0, 0, 20, 1, 240, 7, 12, 4, 1, 4, 11, 1, 120, 80, 2, 2],
|
||||
'data': [50, 0, 0, 0, 20, 1, 240, 7, 12, 4, 1, 4, 11, 1, 120,
|
||||
80, 2, 2],
|
||||
'is_selected': False},
|
||||
{
|
||||
'name': 'Grapefruit',
|
||||
|
|
|
@ -104,9 +104,9 @@ class FruitImageDetailView(BoxLayout):
|
|||
container.add_widget(Label(text=self.fruit_name))
|
||||
for attribute in fruit_data_attributes:
|
||||
container.add_widget(Label(text="{0}:".format(attribute),
|
||||
halign='right'))
|
||||
halign='right'))
|
||||
container.add_widget(
|
||||
Label(text=str(fruit_data[self.fruit_name][attribute])))
|
||||
Label(text=str(fruit_data[self.fruit_name][attribute])))
|
||||
self.add_widget(container)
|
||||
|
||||
def fruit_changed(self, list_adapter, *args):
|
||||
|
@ -118,7 +118,8 @@ class FruitImageDetailView(BoxLayout):
|
|||
# [TODO] Would we want touch events for the composite, as well as
|
||||
# the components? Just the components? Just the composite?
|
||||
#
|
||||
# Is selected_object an instance of ThumbnailedListItem (composite)?
|
||||
# Is selected_object an instance of ThumbnailedListItem
|
||||
# (composite)?
|
||||
#
|
||||
# Or is it a ListItemButton?
|
||||
#
|
||||
|
|
|
@ -101,8 +101,8 @@ class SelectionMonitor(Widget):
|
|||
self.sel_count_6 = len(adapter.selection)
|
||||
|
||||
|
||||
letters_dict = \
|
||||
{l: {'text': l, 'is_selected': False} for l in 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'}
|
||||
letters_dict = {
|
||||
l: {'text': l, 'is_selected': False} for l in 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'}
|
||||
|
||||
listview_selection_buttons = {}
|
||||
|
||||
|
|
|
@ -124,7 +124,7 @@ class LoadDialog(FloatLayout):
|
|||
class Unicode_TextInput(BoxLayout):
|
||||
|
||||
txt_input = ObjectProperty(None)
|
||||
unicode_string = StringProperty('''Latin-1 supplement: éé çç ßß
|
||||
unicode_string = StringProperty("""Latin-1 supplement: éé çç ßß
|
||||
|
||||
List of major languages taken from Google Translate
|
||||
____________________________________________________
|
||||
|
@ -150,11 +150,13 @@ Dutch: De snelle bruine vos springt over de luie oude hond.
|
|||
Estonian: Kiire pruun rebane hüppab üle laisa vana koer.
|
||||
Filipino: Ang mabilis na brown soro jumps sa ang tamad lumang aso.
|
||||
Finnish: Nopea ruskea kettu hyppää yli laiska vanha koira.
|
||||
French: Le renard brun rapide saute par dessus le chien paresseux vieux.
|
||||
French: Le renard brun rapide saute par dessus le chien
|
||||
paresseux vieux.
|
||||
Galician: A lixeira raposo marrón ataca o can preguiceiro de idade.
|
||||
Gregorian: სწრაფი ყავისფერი მელა jumps გამო ზარმაცი წლის ძაღლი.
|
||||
German: Der schnelle braune Fuchs springt über den faulen alten Hund.
|
||||
Greek: Η γρήγορη καφέ αλεπού πηδάει πάνω από το τεμπέλικο γέρικο σκυλί.
|
||||
Greek: Η γρήγορη καφέ αλεπού πηδάει πάνω από το τεμπέλικο
|
||||
γέρικο σκυλί.
|
||||
Gujrati: આ ઝડપી ભુરો શિયાળ તે બેકાર જૂના કૂતરા પર કૂદકા.
|
||||
Gurmukhi: ਤੇਜ ਭੂਰੇ ਰੰਗ ਦੀ ਲੂੰਬੜੀ ਆਲਸੀ ਬੁੱਢੇ ਕੁੱਤੇ ਦੇ ਉਤੋਂ ਦੀ ਟੱਪਦੀ ਹੈ ।
|
||||
Hiation Creole: Rapid mawon Rena a so sou chen an parese fin vye granmoun.
|
||||
|
@ -186,15 +188,16 @@ Slovenian: Kožuščku hudobnega nad leni starega psa.
|
|||
Spanish: La cigüeña tocaba el saxofón en el viejo perro perezoso.
|
||||
Swahili: Haraka brown fox anaruka juu ya mbwa wavivu zamani.
|
||||
Swedish: Den snabba bruna räven hoppar över den lata gammal hund.
|
||||
Tamil: விரைவான பிரவுன் ஃபாக்ஸ் சோம்பேறி பழைய நாய் மீது தொடரப்படுகிறது
|
||||
Tamil: விரைவான பிரவுன் ஃபாக்ஸ் சோம்பேறி பழைய நாய் மீது
|
||||
தொடரப்படுகிறது
|
||||
Telugu: శీఘ్ర బ్రౌన్ ఫాక్స్ సోమరితనం పాత కుక్క కంటే హెచ్చుతగ్గుల.
|
||||
Thai: สีน้ำตาลอย่างรวดเร็วจิ้งจอกกระโดดมากกว่าสุนัขเก่าที่ขี้เกียจ
|
||||
Turkish: Hızlı kahverengi tilki tembel köpeğin üstünden atlar.
|
||||
Ukranian: Швидкий коричневий лис перестрибує через лінивий старий пес.
|
||||
Urdu: فوری بھوری لومڑی سست بوڑھے کتے پر کودتا.
|
||||
Vietnamese: Các con cáo nâu nhanh chóng nhảy qua con chó lười biếng cũ.
|
||||
Welsh: Mae\'r cyflym frown llwynog neidio dros y ci hen ddiog.
|
||||
Yiddish: דער גיך ברוין פוקס דזשאַמפּס איבער די פויל אַלט הונט.''')
|
||||
Welsh: Mae'r cyflym frown llwynog neidio dros y ci hen ddiog.
|
||||
Yiddish: דער גיך ברוין פוקס דזשאַמפּס איבער די פויל אַלט הונט.""")
|
||||
|
||||
def dismiss_popup(self):
|
||||
self._popup.dismiss()
|
||||
|
|
|
@ -37,7 +37,7 @@ arguments via the *kwargs* keyword::
|
|||
'cls_dicts': [{'cls': ListItemButton,
|
||||
'kwargs': {'text': rec['text']}},
|
||||
{'cls': ListItemLabel,
|
||||
'kwargs': {'text': "Middle-{0}".format(rec['text']),
|
||||
'kwargs': {'text': rec['text'],
|
||||
'is_representing_cls': True}},
|
||||
{'cls': ListItemButton,
|
||||
'kwargs': {'text': rec['text']}}]}
|
||||
|
|
|
@ -248,8 +248,8 @@ class ListAdapter(Adapter, EventDispatcher):
|
|||
if item['is_selected']:
|
||||
self.handle_selection(view_instance)
|
||||
elif hasattr(item, 'is_selected'):
|
||||
if (inspect.isfunction(item.is_selected)
|
||||
or inspect.ismethod(item.is_selected)):
|
||||
if (inspect.isfunction(item.is_selected) or
|
||||
inspect.ismethod(item.is_selected)):
|
||||
if item.is_selected():
|
||||
self.handle_selection(view_instance)
|
||||
else:
|
||||
|
@ -331,8 +331,8 @@ class ListAdapter(Adapter, EventDispatcher):
|
|||
elif type(item) == dict:
|
||||
item['is_selected'] = value
|
||||
elif hasattr(item, 'is_selected'):
|
||||
if (inspect.isfunction(item.is_selected)
|
||||
or inspect.ismethod(item.is_selected)):
|
||||
if (inspect.isfunction(item.is_selected) or
|
||||
inspect.ismethod(item.is_selected)):
|
||||
item.is_selected()
|
||||
else:
|
||||
item.is_selected = value
|
||||
|
|
|
@ -642,10 +642,10 @@ class ClockBaseInterruptBehavior(ClockBaseBehavior):
|
|||
return
|
||||
|
||||
if not event.timeout or (
|
||||
not self.interupt_next_only and event.timeout
|
||||
<= 1 / fps # remaining time
|
||||
- (self.time() - self._last_tick) # elapsed time
|
||||
+ 4 / 5. * self.get_resolution()): # resolution fudge factor
|
||||
not self.interupt_next_only and event.timeout <=
|
||||
1 / fps - # remaining time
|
||||
(self.time() - self._last_tick) + # elapsed time
|
||||
4 / 5. * self.get_resolution()): # resolution fudge factor
|
||||
self._event.set()
|
||||
|
||||
def idle(self):
|
||||
|
|
|
@ -57,7 +57,8 @@ class SpellingOSXAppKit(SpellingBase):
|
|||
except AttributeError:
|
||||
# From 10.6 onwards you're supposed to do it like this:
|
||||
checkrange = NSMakeRange(0, len(fragment))
|
||||
g = l.guessesForWordRange_inString_language_inSpellDocumentWithTag_(
|
||||
checkrange, fragment, l.language(), 0)
|
||||
g = l.\
|
||||
guessesForWordRange_inString_language_inSpellDocumentWithTag_(
|
||||
checkrange, fragment, l.language(), 0)
|
||||
# Right, this was much easier, Apple! :-)
|
||||
return list(g)
|
||||
|
|
|
@ -35,8 +35,8 @@ def circumcircle(a, b, c):
|
|||
mPQ = (P + Q) * .5
|
||||
mQR = (Q + R) * .5
|
||||
|
||||
numer = -(- mPQ.y * R.y + mPQ.y * Q.y + mQR.y * R.y - mQR.y * Q.y
|
||||
- mPQ.x * R.x + mPQ.x * Q.x + mQR.x * R.x - mQR.x * Q.x)
|
||||
numer = -(- mPQ.y * R.y + mPQ.y * Q.y + mQR.y * R.y - mQR.y * Q.y -
|
||||
mPQ.x * R.x + mPQ.x * Q.x + mQR.x * R.x - mQR.x * Q.x)
|
||||
denom = (-Q.x * R.y + P.x * R.y - P.x * Q.y +
|
||||
Q.y * R.x - P.y * R.x + P.y * Q.x)
|
||||
|
||||
|
|
|
@ -242,8 +242,8 @@ class SafeMembrane(object):
|
|||
return SafeMembrane(r)
|
||||
|
||||
def __setattr__(self, attr, val, osa=object.__setattr__):
|
||||
if (attr == '_ref'
|
||||
or hasattr(type(self), attr) and not attr.startswith('__')):
|
||||
if (attr == '_ref' or
|
||||
hasattr(type(self), attr) and not attr.startswith('__')):
|
||||
osa(self, attr, val)
|
||||
else:
|
||||
self.safeIn()
|
||||
|
|
|
@ -857,7 +857,8 @@ will first be unloaded and then reloaded again. For example:
|
|||
'''
|
||||
|
||||
|
||||
from kivy.lang.builder import Observable, Builder, BuilderBase, BuilderException
|
||||
from kivy.lang.builder import (Observable, Builder, BuilderBase,
|
||||
BuilderException)
|
||||
from kivy.lang.parser import Parser, ParserException, global_idmap
|
||||
|
||||
__all__ = ('Observable', 'Builder', 'BuilderBase', 'BuilderException',
|
||||
|
|
|
@ -707,25 +707,25 @@ class BuilderBase(object):
|
|||
|
||||
.. code-block:: python
|
||||
|
||||
>>> w = Builder.load_string(\'''
|
||||
... Widget:
|
||||
... height: self.width / 2. if self.disabled else self.width
|
||||
... x: self.y + 50
|
||||
... \''')
|
||||
>>> w.size
|
||||
[100, 100]
|
||||
>>> w.pos
|
||||
[50, 0]
|
||||
>>> w.width = 500
|
||||
>>> w.size
|
||||
[500, 500]
|
||||
>>> Builder.unbind_widget(w.uid)
|
||||
>>> w.width = 222
|
||||
>>> w.y = 500
|
||||
>>> w.size
|
||||
[222, 500]
|
||||
>>> w.pos
|
||||
[50, 500]
|
||||
>>> w = Builder.load_string(\'''
|
||||
... Widget:
|
||||
... height: self.width / 2. if self.disabled else self.width
|
||||
... x: self.y + 50
|
||||
... \''')
|
||||
>>> w.size
|
||||
[100, 100]
|
||||
>>> w.pos
|
||||
[50, 0]
|
||||
>>> w.width = 500
|
||||
>>> w.size
|
||||
[500, 500]
|
||||
>>> Builder.unbind_widget(w.uid)
|
||||
>>> w.width = 222
|
||||
>>> w.y = 500
|
||||
>>> w.size
|
||||
[222, 500]
|
||||
>>> w.pos
|
||||
[50, 500]
|
||||
|
||||
.. versionadded:: 1.7.2
|
||||
'''
|
||||
|
|
Loading…
Reference in New Issue