Skip to content

Instantly share code, notes, and snippets.

@inclement
inclement / gist:33dde57f2f60b1524145
Created July 30, 2014 21:24
Example of changing texture wrap and tex_coords
'''
Example of changing texture properties and the properties
of its containing rectangle.
'''
from kivy.uix.widget import Widget
from kivy.properties import ObjectProperty, ListProperty, StringProperty
from kivy.lang import Builder
from kivy.clock import Clock
asandy@homemade:~/kivy$ USE_SDL2=1 make
python2 setup.py build_ext --inplace
Environ change use_sdl2 -> True
[INFO ] Kivy v1.8.0-dev
Found GLES 2.0 headers at /usr/include/GLES2/gl2.h
SDL2: found SDL header at /usr/include/SDL2/SDL.h
SDL2: found SDL_mixer header at /usr/include/SDL2/SDL_mixer.h
SDL2: found SDL_ttf header at /usr/include/SDL2/SDL_ttf.h
SDL2: found SDL_image header at /usr/include/SDL2/SDL_image.h
running build_ext
def format_percent(number, format=None, locale='en_US'):
return '0.34%'
>>> format_percent(0.34/100, '#,###.##%', locale='en_US')
'0.34%'
('value is', '\n\n\n\n\nself.disabled_color if self.disabled else (self.color if not self.markup else (1, 1, 1, 1))')
('value is', '\n\n\n\n\n\n\nself.texture')
('value is', '\n\n\n\n\n\n\n\nself.texture_size')
('value is', '\n\n\n\n\n\n\n\n\nint(self.center_x - self.texture_size[0] / 2.), int(self.center_y - self.texture_size[1] / 2.)')
('value is', "\n\n\n\n\n\n\n\n\n\n\n\nself.background_normal if self.state == 'normal' else self.background_down")
('value is', "\n\n\n\n\n\n\n\n\n\n\n\n\nself.background_disabled_normal if self.state == 'normal' else self.background_disabled_down")
('value is', '\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nself.background_color')
('value is', '\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nself.border')
('value is', '\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nself.pos')
('value is', '\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nself.size')
print 'n is', n
print n.log10(5)
ax1.scatter(min_cs, n.log10(determinants), s=1.5, color='blue', alpha=0.5)
==================
Output:
n is <module 'numpy' from '/usr/lib/python2.7/site-packages/numpy/__init__.pyc'>
0.698970004336
Traceback (most recent call last):
import sys
sys.path.append('/home/asandy')
from matplotlib import rc
rc('font', **{'family':'serif','serif':['Computer Modern Roman']})
rc('text', usetex=True)
rc('axes', **{'labelsize':10})
rc('xtick', **{'labelsize':10})
rc('ytick', **{'labelsize':10})
class Renderer(Widget):
def __init__(self, fd, **kwargs):
self.instructions = InstructionGroup()
self.canvas = RenderContext(compute_normal_mat=True)
self.mesh1 = RenderContext(compute_normal_mat=True)
self.mesh1.shader.source = resource_find('shaders/red.glsl')
self.mesh2 = RenderContext(compute_normal_mat=True)
self.mesh2.shader.source = resource_find('shaders/blue.glsl')
<PartBox@BoxLayout>:
ti: ti
orientation: 'vertical'
size_hint_x: 0.2
title: ''
Label:
text: root.title
TextInput:
id: ti
text: '0'
#:kivy 1.0.9
TestWidget:
<RectangleWidget@Widget>:
source: ''
canvas:
Color:
rgba: 1, 1, 1, 1
Rectangle:
pos: self.pos
@inclement
inclement / gist:17614c3d11e5004d5200
Created January 23, 2015 02:33
Example kivy app with two panes
from kivy.app import App
from kivy.uix.boxlayout import BoxLayout
from kivy.lang import Builder
Builder.load_string('''
<MainWidget>:
BoxLayout:
orientation: 'vertical'
Button:
text: 'some string '