Skip to content

Instantly share code, notes, and snippets.

class GobanApp(App):
manager = ObjectProperty(None,allownone=True)
def build(self):
...
from kivy.app import App
from kivy.uix.widget import Widget
from kivy.uix.boxlayout import BoxLayout
from kivy.properties import NumericProperty, ReferenceListProperty, ObjectProperty, ListProperty, AliasProperty, StringProperty, DictProperty, BooleanProperty, StringProperty, OptionProperty
class MyCustomWidget(Widget):
_val1 = NumericProperty(0)
_val2 = NumericProperty(50)
def AddVal1(self):
valToAdd = 26
@inclement
inclement / gist:5690438
Created June 1, 2013 13:44
Texture region test. Changing a TextureRegion works fine, except even though the rectangle coordinates should be 40,40 the region always starts from 0,0
from kivy.app import App
from kivy.uix.widget import Widget
from kivy.uix.boxlayout import BoxLayout
from kivy.uix.button import Button
from kivy.properties import NumericProperty, ReferenceListProperty, ObjectProperty, ListProperty, AliasProperty, StringProperty, DictProperty, BooleanProperty, StringProperty, OptionProperty
from kivy.graphics.texture import Texture
from random import randint
class TextureDemo(Widget):
class NumberChooser(BoxLayout):
number = NumericProperty(0)
number_max = NumericProperty(9)
number_min = NumericProperty(0)
def increment(self):
if self.number < self.number_max:
self.number += 1
def decrement(self):
if self.number > self.number_min:
self.number -= 1
@inclement
inclement / gist:6244996
Created August 15, 2013 21:18
Android app crash on screen rotate
I/python (17969): PROPAGATING VIEW MODE tablet
I/ActivityManager( 519): Config changes=1480 {1.0 234mcc10mnc en_GB ldltr sw384dp w598dp h359dp 320dpi nrml land finger -keyb/v/h -nav/h s.19}
I/InputReader( 519): Reconfiguring input devices. changes=0x00000004
I/InputReader( 519): Device reconfigured: id=6, name='touch_dev', size 768x1280, orientation 1, mode 1, display id 0
D/PhoneStatusBar( 727): mSettingsPanelGravity = 55
I/python (17969): [INFO ] [Android ] Must to in sleep mode, check the app
I/python (17969): App asked to pause
I/python (17969): [INFO ] [Android ] App paused, now wait for resume.
D/AndroidRuntime(17969): Shutting down VM
W/dalvikvm(17969): threadid=1: thread exiting with uncaught exception (group=0x41c16700)
@inclement
inclement / gist:6245730
Created August 15, 2013 23:01
Kivy app crash on rotation
D/Finsky (11851): [1] 5.onFinished: Installation state replication succeeded.
I/ActivityManager( 519): Config changes=1480 {1.0 234mcc10mnc en_GB ldltr sw384dp w598dp h359dp 320dpi nrml land finger -keyb/v/h -nav/h s.50}
I/InputReader( 519): Reconfiguring input devices. changes=0x00000004
I/InputReader( 519): Device reconfigured: id=6, name='touch_dev', size 768x1280, orientation 1, mode 1, display id 0
I/InputReader( 519): Reconfiguring input devices. changes=0x00000004
I/InputReader( 519): Device reconfigured: id=6, name='touch_dev', size 768x1280, orientation 1, mode 1, display id 0
I/python (24254): [INFO ] [Android ] Must to in sleep mode, check the app
I/python (24254): App asked to pause
I/python (24254): [INFO ] [Android ] App paused, now wait for resume.
D/AndroidRuntime(24254): Shutting down VM
@inclement
inclement / gist:6328249
Last active December 21, 2015 15:39
CompositeListItem example
from kivy.uix.listview import ListView, ListItemButton, CompositeListItem
from kivy.adapters.listadapter import ListAdapter
from kivy.properties import NumericProperty, ReferenceListProperty, ObjectProperty, ListProperty, AliasProperty, StringProperty, DictProperty, BooleanProperty, StringProperty, OptionProperty
from kivy.app import App
class ExampleApp(App):
def build(self):
tuples = zip(map(str,range(10)),map(str,range(10,20)))
@inclement
inclement / gist:6334255
Created August 25, 2013 14:55
Error with kivy pep8 checker
$ git commit kivy/app.py
Traceback (most recent call last):
File "/home/asandy/kivy/kivy/tools/pep8checker/pep8kivy.py", line 4, in <module>
import pep8
File "/home/asandy/kivy/kivy/tools/pep8checker/pep8.py", line 1054, in <module>
stdin_get_value = TextIOWrapper(sys.stdin.buffer, errors='ignore').read
NameError: name 'TextIOWrapper' is not defined
Error: 1 styleguide violation(s) encountered!
Your commit has been aborted. Please fix the violations and retry.
@inclement
inclement / gist:6365275
Created August 28, 2013 12:07
label markup test
from kivy.app import App
from kivy.uix.label import Label
class ExApp(App):
def build(self):
return Label(text='[b]yay[/b]\n[i]moo[/i]\n', markup=True)
if __name__ == "__main__":
ExApp().run()
@inclement
inclement / gist:6372048
Created August 28, 2013 22:15
Kivy scheduling example
from kivy.app import App
from kivy.uix.widget import Widget
from kivy.uix.button import Button
from kivy.uix.progressbar import ProgressBar
from kivy.uix.boxlayout import BoxLayout
from kivy.clock import Clock
class MainMenu(BoxLayout):
def __init__(self, **kwargs):
super(MainMenu, self).__init__(**kwargs)