1. Kevin Luikens
  2. whackamole

Commits

Chas Leichner  committed 5e56f68

removed framework directory

  • Participants
  • Parent commits 49416e9
  • Branches default

Comments (0)

Files changed (62)

File framework/animation/animation.py

  • Ignore whitespace
-from pymt import *
-from OpenGL.GL import *
-
-class MTSprite(MTWidget):
-    def __init__(self, **kwargs):
-        super(MTSprite, self).__init__(**kwargs)
-        self.rotation = 0
-        self.filename		= kwargs.get('filename')
-        self.image     = pymt.Image(self.filename)
-        self.size           = self.image.size
-        self.scale = self.style.get('scale')
-        self.intial_pos = self.pos
-
-    def draw(self):
-        with gx_matrix:
-            glTranslated(self.x+self.width/2,self.y+self.height/2,0)
-            glRotated(int(self.rotation),0,0,1)
-            glTranslated(-self.x-self.width/2,-self.y-self.height/2,0)
-            set_color(*self.style.get('bg-color'))
-            self.scale = self.style.get('scale')
-            self.image.pos  = self.pos
-            self.image.scale= self.scale
-            self.size = self.image.size
-            self.image.draw()
-
-
-    def reset(self):
-        self.size = self.image.size
-        self.style['scale'] = 1.0
-        self.pos = self.intial_pos
-        self.rotation = 0
-        self.image.pos  = self.pos
-        self.image.scale= self.scale
-
-
-m = MTWindow()
-
-#Set up buttons
-but_layout = MTGridLayout(cols=5,rows=1)
-m.add_widget(but_layout)
-reset = MTButton(label="Reset",height=50)
-but_layout.add_widget(reset)
-
-simple = MTButton(label="Simple",height=50)
-but_layout.add_widget(simple)
-
-sequence = MTButton(label="Sequence",height=50)
-but_layout.add_widget(sequence)
-
-parallel = MTButton(label="Parallel",height=50)
-but_layout.add_widget(parallel)
-
-repeat_delta = MTButton(label="Repeat",height=50)
-but_layout.add_widget(repeat_delta)
-
-but_layout.x = m.width/2-but_layout.width/2 #Align button at the bottom-center
-
-
-#Add Objects
-greeny = MTSprite(filename="icons/greeny.png" ,pos=(100,100), style={'scale':1.0})
-m.add_widget(greeny)
-
-#Construct Animations
-movX = Animation(duration=1, x=m.width/2-greeny.width/2)
-movY = Animation(duration=1, y=m.height/2-greeny.height/2)
-movXY = Animation(duration=1, pos=(m.width/2-greeny.width/2, m.height/2-greeny.height/2)) #Move to center
-rot360 = Animation(duration=2, rotation=720)
-scale = Animation(duration=1.5, scale=2)
-
-mov_dxy = Animation(duration=0.5, pos=(50,50), type="delta")
-mov_dx = Animation(duration=0.5, x=50, type="delta")
-rot_d = Animation(duration=0.5, rotation=45, type="delta")
-
-mov_x = Animation(duration=1, x=250)
-rot = Animation(duration=1, rotation=15)
-
-seq = movX + movY + rot360 + scale
-
-pll = movX & movY & rot360 & scale
-
-repeat_delta_anim = Repeat(mov_dx + rot_d, times=6)
-
-#handle button press
-@reset.event
-def on_press(*largs):
-    greeny.reset()
-
-@simple.event
-def on_press(*largs):
-    greeny.do(movXY)
-
-@sequence.event
-def on_press(*largs):
-    greeny.do(seq)
-
-@parallel.event
-def on_press(*largs):
-    greeny.do(pll)
-
-@repeat_delta.event
-def on_press(*largs):
-    greeny.do(repeat_delta_anim)
-
-runTouchApp()

File framework/animation/animation_functions.py

  • Ignore whitespace
-from pymt import *
-from OpenGL.GL import *
-import random, math
-
-class MTSprite(MTWidget):
-    def __init__(self, **kwargs):
-        super(MTSprite, self).__init__(**kwargs)
-        self.rotation = 0
-        self.filename		= kwargs.get('filename')
-        self.image     = pymt.Image(self.filename)
-        self.size           = self.image.size
-        self.scale = 1.0
-        self.intial_pos = self.pos
-
-    def draw(self):
-        with gx_matrix:
-            glTranslated(self.x+self.width/2,self.y+self.height/2,0)
-            glRotated(int(self.rotation),0,0,1)
-            glTranslated(-self.x-self.width/2,-self.y-self.height/2,0)
-            set_color(*self.style.get('bg-color'))
-            self.image.pos  = self.pos
-            self.image.scale= self.scale
-            self.size = self.image.size
-            self.image.draw()
-
-    def reset(self):
-        self.size = self.image.size
-        self.scale = 1.0
-        self.pos = self.intial_pos
-        self.rotation = 0
-        self.image.pos  = self.pos
-        self.image.scale= self.scale
-
-w = MTWindow(style={'bg-color':(0,0,0)})
-getWindow().gradient = False
-
-objlist = [] #List of sprites
-
-for i in range(64):
-    x = int(random.uniform(100, w.width-100))
-    y = int(random.uniform(100, w.height-100))
-    obj = MTSprite(pos=(x,y), filename="icons/clock.png")
-    objlist.append(obj)
-    w.add_widget(obj)
-
-#Set up buttons
-but_layout = MTGridLayout(cols=4,rows=2)
-w.add_widget(but_layout)
-randomize = MTButton(label="Randomize",height=50)
-but_layout.add_widget(randomize)
-
-grid = MTButton(label="Grid",height=50)
-but_layout.add_widget(grid)
-
-circular = MTButton(label="Circular",height=50)
-but_layout.add_widget(circular)
-
-bowtie = MTButton(label="Bow Tie",height=50)
-but_layout.add_widget(bowtie)
-
-but_layout.x = w.width/2-but_layout.width/2 #Align button at the bottom-center
-
-#handle button press
-@randomize.event
-def on_press(*largs):
-    anim_list = []
-    for i in range(64):
-        x = int(random.uniform(100, w.width-100))
-        y = int(random.uniform(100, w.height-100))
-        anim_list.append(Animation(duration=1.5, pos=(x,y), alpha_function="ease_in_out_back"))
-
-    i = 0
-    for obj in objlist:
-        obj.do(anim_list[i])
-        i += 1
-
-@grid.event
-def on_press(*largs):
-    anim_list = []
-    for i in range(8):
-        for j in range(8):
-            x = j*64+100
-            y = i*64+40
-            anim_list.append(Animation(duration=1.5, pos=(x,y), alpha_function="ease_in_out_back"))
-
-    i = 0
-    for obj in objlist:
-        obj.do(anim_list[i])
-        i += 1
-
-@circular.event
-def on_press(*largs):
-    anim_list = []
-    for i in range(64):
-        teta = math.radians(8*i)
-        x = 200 * math.cos(teta)+w.width/2
-        y = 200 * math.sin(teta)+w.height/2
-        anim_list.append(Animation(duration=1.5, pos=(x,y), alpha_function="ease_in_out_back"))
-
-    i = 0
-    for obj in objlist:
-        obj.do(anim_list[i])
-        i += 1
-
-@bowtie.event
-def on_press(*largs):
-    anim_list = []
-    for i in range(64):
-        teta = math.radians(8*i)
-        x = 200 * math.cos(teta)+w.width/2
-        y = 200 * math.sin(teta*2)+w.height/2
-        anim_list.append(Animation(duration=1.5, pos=(x,y), alpha_function="ease_in_out_back"))
-
-    i = 0
-    for obj in objlist:
-        obj.do(anim_list[i])
-        i += 1
-
-runTouchApp()

File framework/animation/icons/README

  • Ignore whitespace
-ICONS are under Creative Commons. 
-Thanks to 
-spoongraphics - http://www.blog.spoongraphics.co.uk/freebies/free-cute-furry-monster-icons-for-mac-pc-and-web
-cemagraphics - http://cemagraphics.deviantart.com/art/Candy-Clock-Icon-96460050

File framework/animation/icons/clock.png

  • Ignore whitespace
Removed
Old image

File framework/animation/icons/greeny.png

  • Ignore whitespace
Removed
Old image

File framework/base_event_dispatcher.py

  • Ignore whitespace
-'''
-Create a event dispatcher, and use it to get all event from PyMT
-Without any OpenGL window created.
-'''
-
-# prevent window creation
-import os
-
-os.environ['PYMT_SHADOW_WINDOW'] = '0'
-from pymt import *
-
-# create a class to catch all events
-class TouchEventListener:
-    def dispatch_event(self, event_name, *arguments):
-        print 'Event dispatched', event_name, 'with', arguments
-
-# append the class to event listeners
-pymt_event_listeners.append(TouchEventListener())
-
-# start pymt subsystem
-runTouchApp(slave=True)
-
-# now you can run your application,
-# and don't forget to update PyMT subsystem
-while True:
-    # update pymt subsystem
-    getEventLoop().idle()
-
-    # do your own thing.
-    pass
-

File framework/core/audio.py

  • Ignore whitespace
-'''
-Test of audio core, with event play/stop.
-'''
-
-import os
-from pymt import *
-
-# load the sound
-filename = os.path.join(os.path.dirname(__file__), 'test_audio.wav')
-sound = SoundLoader.load(filename)
-
-# install callack for on_play/on_stop event
-@sound.event
-def on_play():
-    print '-> sound started, status is', sound.status
-
-@sound.event
-def on_stop():
-    print '-> sound finished, status is', sound.status
-    stopTouchApp()
-
-# start to play the sound
-sound.play()
-
-# run the application
-runTouchApp()
-

File framework/core/camera.py

  • Ignore whitespace
-from pymt import *
-
-scat = MTScatterWidget()
-
-s = MTWidget()
-c = Camera()
-@s.event
-def on_draw():
-    c.update()
-    c.draw()
-
-scat.add_widget(s)
-scat.size = (c.width, c.height)
-
-runTouchApp(scat)

File framework/core/test_audio.wav

  • Ignore whitespace
Binary file removed.

File framework/exceptions.py

  • Ignore whitespace
-# Simple exemple of exception handler
-# Exeption will be catch, and set the return to PASS
-# So, app will be not stopped by this.
-
-from pymt import *
-
-class E(ExceptionHandler):
-    def handle_exception(self, inst):
-        pymt_logger.exception(inst)
-        return ExceptionManager.PASS
-
-pymt_exception_manager.add_handler(E())
-
-m = MTWindow()
-t = MTButton()
-@t.event
-def on_press(*largs):
-    print a
-m.add_widget(t)
-runTouchApp()

File framework/image.jpg

  • Ignore whitespace
Removed
Old image

File framework/images/014a6659998b0b81cc225d4706fde2e3.png

  • Ignore whitespace
Removed
Old image

File framework/images/015acd2f0f3717ca9d110dd3fab6feb8.png

  • Ignore whitespace
Removed
Old image

File framework/images/017814c0b79fc4a1d8f4376ff222b73a.png

  • Ignore whitespace
Removed
Old image

File framework/images/01a1b6a222fd93e66de0dbba493b6ee7.png

  • Ignore whitespace
Removed
Old image

File framework/images/01cbc032d8da1976de59fb217ea1b1f0.png

  • Ignore whitespace
Removed
Old image

File framework/images/01d1ac1cb6c62af5a790b46bf6dbbb5a.png

  • Ignore whitespace
Removed
Old image

File framework/images/01e7ee23d4bf5bff6b68ea559b77725c.png

  • Ignore whitespace
Removed
Old image

File framework/images/01fb643dd2bf4a8b3b7415729fc648b2.png

  • Ignore whitespace
Removed
Old image

File framework/images/02090c797de78d1e3ab04c235bc4f853.png

  • Ignore whitespace
Removed
Old image

File framework/images/02136494e006d50bae50caaefcf78acd.png

  • Ignore whitespace
Removed
Old image

File framework/images/021fcc091455534f03a8ba5989d30d53.png

  • Ignore whitespace
Removed
Old image

File framework/images/02474ef2b6db85075b0df70bd781983b.png

  • Ignore whitespace
Removed
Old image

File framework/loader.py

  • Ignore whitespace
-from pymt import *
-
-# asynchronous load the image in http
-img = Loader.image('http://pymt.eu/styles/logo.png')
-
-# add a container with the core image, and display it
-runTouchApp(MTContainer(img))

File framework/reload.css

  • Ignore whitespace
-/**
- * Change this CSS and hit F7 or reload button
- * on cssreload.py example
- */
-#btn1 {
-	border-color: rgb(255, 0, 0);
-	draw-background: 0;
-	draw-border: 1;
-	draw-text-shadow: 1;
-	color: rgb(0,0,0);
-}

File framework/ui_colors_cssreload.py

  • Ignore whitespace
-from pymt import *
-
-css_add_file('reload.css')
-
-b1 = MTButton(id='btn1', label='Reload CSS', pos=(100, 100))
-b2 = MTButton(id='btn2', label='Button 2', pos=(250, 100))
-
-@b1.event
-def on_press(*largs):
-    css_reload()
-
-w = getWindow()
-w.add_widget(b1)
-w.add_widget(b2)
-
-runTouchApp()

File framework/ui_dragable.py

  • Ignore whitespace
-from pymt import *
-from random import random
-
-window = getWindow()
-
-# create 100 dragable object with random position and color
-w, h = window.size
-for i in xrange(100):
-    x = random() * w
-    y = random() * h
-    window.add_widget(MTDragable(pos=(x, y),
-        style={'bg-color': get_random_color(), 'draw-background': 1}))
-
-runTouchApp()

File framework/ui_dragable_as_container.py

  • Ignore whitespace
-from pymt import *
-from random import random
-
-css_add_sheet('dragablelabel { draw-background: 1; }')
-
-class DragableLabel(MTDragable):
-    def __init__(self, **kwargs):
-        super(DragableLabel, self).__init__()
-        self.label = MTLabel(**kwargs)
-        self.add_widget(self.label)
-
-    def on_update(self):
-        self.label.pos = interpolate(self.label.pos, self.pos)
-        self.size = interpolate(self.size, self.label.size)
-        super(DragableLabel, self).on_update()
-
-window = getWindow()
-w, h = window.size
-
-for text in ('My dog is lazy', 'My cat is sleeping', 'Hello world'):
-    # Make a label dragable
-    label = DragableLabel(label=text, padding=40)
-
-    # randomize a position
-    label.center = w * random(), h * random()
-
-    # add to window
-    window.add_widget(label)
-
-runTouchApp()
-

File framework/ui_kinetic.py

  • Ignore whitespace
-from pymt import *
-
-css_add_sheet('.rect { draw-background: 1; }')
-
-# create a kinetic object
-kinetic = MTKinetic()
-
-# add some object on kinetic place
-kinetic.add_widget(MTDragable(cls='rect', style={'bg-color': (1, .2, .2, 1)}))
-kinetic.add_widget(MTDragable(cls='rect', style={'bg-color': (.2, 1, .2, 1)}))
-kinetic.add_widget(MTDragable(cls='rect', style={'bg-color': (.2, .2, 1, 1)}))
-
-# run app with kinetic plane
-runTouchApp(kinetic)

File framework/ui_klist.py

  • Ignore whitespace
-from pymt import *
-
-# create a list with no possibility to move on Y axis
-wlist = MTList(size=getWindow().size, do_y=False)
-
-# create a grid layout to use inside the list
-wlayout = MTGridLayout(rows=5)
-wlist.add_widget(wlayout)
-
-# create a lot of button. you should be able to click on it, and
-# move the list in X axis
-for x in xrange(100):
-    wlayout.add_widget(MTToggleButton(label=str(x)))
-
-runTouchApp(wlist)

File framework/ui_widgets_button.py

  • Ignore whitespace
-'''
-Button example with all events in button.
-'''
-
-from pymt import *
-
-b = MTButton(label='Push me')
-@b.event
-def on_press(*largs):
-	print 'on_press()', b.state, largs
-
-@b.event
-def on_release(*largs):
-	print 'on_release()', b.state, largs
-
-@b.event
-def on_state_change(*largs):
-    print 'on_state_change()', b.state, largs
-
-runTouchApp(b)

File framework/ui_widgets_button_align.py

  • Ignore whitespace
-from pymt import *
-
-w = MTWidget()
-
-y = 0
-for halign in ('left', 'center', 'right'):
-    y += 100
-    x = 100
-    for valign in ('top', 'center', 'bottom'):
-        m = MTButton(label='%s:%s' % (halign, valign),
-                     pos=(x, y), size=(150, 30),
-                     anchor_x=halign, anchor_y=valign)
-        x += 200
-        w.add_widget(m)
-
-runTouchApp(w)

File framework/ui_widgets_button_css.py

  • Ignore whitespace
-from pymt import *
-
-# Create a CSS with 2 rules
-additional_css = '''
-.simple {
-	draw-alpha-background: 0;
-	draw-border: 0;
-	draw-text-shadow: 1;
-}
-
-.colored {
-	bg-color: rgb(68, 170, 0);
-	border-radius: 20;
-	border-radius-precision: .1;
-	font-size: 16;
-}
-'''
-
-# Add the CSS into PyMT
-css_add_sheet(additional_css)
-
-# Create different button, with one or 2 rules at the same time
-v = MTBoxLayout(orientation='vertical', padding=20, spacing=20)
-v.add_widget(MTButton(label='Coucou'))
-v.add_widget(MTButton(label='Coucou', cls='simple'))
-v.add_widget(MTButton(label='Coucou', cls='colored'))
-v.add_widget(MTButton(label='Coucou', cls=('simple', 'colored')))
-
-runTouchApp(v)

File framework/ui_widgets_button_toggle.py

  • Ignore whitespace
-from pymt import *
-
-b = MTToggleButton(label='Push me')
-
-@b.event
-def on_press(*largs):
-	print 'on_press()', b.state, largs
-
-@b.event
-def on_release(*largs):
-	print 'on_release()', b.state, largs
-
-runTouchApp(b)

File framework/ui_widgets_buttonmatrix.py

  • Ignore whitespace
-from pymt import *
-
-# create a custom 10x10 matrix, fullscreen
-m = MTButtonMatrix(matrix_size=(10, 10), size_hint=(1, 1))
-
-# create a default handler for the on_press event
-def m_on_press(args):
-    # extract row / column / state
-    row, column, state = args
-    print 'matrix change at %d x %d = %s' % (row, column, state)
-
-# connect the handler to the widget
-m.connect('on_press', m_on_press)
-
-runTouchApp(m)

File framework/ui_widgets_composed_colorpicker.py

  • Ignore whitespace
-from pymt import *
-runTouchApp(MTColorPicker())

File framework/ui_widgets_composed_filebrowser.py

  • Ignore whitespace
-from pymt import *
-
-# create the filebrowser
-fb = MTFileBrowser()
-
-# when selection will be done, it will print the selected files
-@fb.event
-def on_select(list):
-    print list
-
-runTouchApp(fb)

File framework/ui_widgets_composed_textarea.py

  • Ignore whitespace
-# Text area (multiline text input)
-from pymt import *
-
-wid = MTTextArea()
-
-@wid.event
-def on_text_validate():
-    print 'Text have been validated:', wid.value
-
-@wid.event
-def on_text_change(text):
-    print 'Text have been changed (not validated):', text
-
-runTouchApp(wid)
-

File framework/ui_widgets_composed_textinput.py

  • Ignore whitespace
-# Text input widget with a switch to use hardware keyboard or not
-from pymt import *
-
-wid = MTTextInput()
-
-@wid.event
-def on_text_change(text):
-    print 'Text have been changed (not validated):', text
-
-runTouchApp(wid)

File framework/ui_widgets_composed_vkeyboard.py

  • Ignore whitespace
-from pymt import *
-keyboard = MTVKeyboard()
-
-@keyboard.event
-def on_key_down(*largs):
-    print 'key down:', largs
-
-@keyboard.event
-def on_key_up(*largs):
-    print 'key up:', largs
-
-@keyboard.event
-def on_text_change(*largs):
-    print 'text change', largs
-
-runTouchApp(keyboard)

File framework/ui_widgets_composed_vkeyboard_numerical.py

  • Ignore whitespace
-from pymt import *
-
-# create a custom layout, a numerical one
-class NumericKeyboardLayout(KeyboardLayout):
-    ID              = 'numeric'
-    TITLE           = 'Numeric keyboard'
-    DESCRIPTION     = ''
-    SIZE            = (4, 4)
-    NORMAL_1 = [
-        ('7', '7', None, 1),    ('8', '8', None, 1),    (u'9', u'9', None, 1),
-        (u'\u2a2f', None, 'escape', 1),
-    ]
-    NORMAL_2 = [
-        ('4', '4', None, 1),    ('5', '5', None, 1),    (u'6', u'6', None, 1),
-    ]
-    NORMAL_3 = [
-        ('1', '1', None, 1),    ('2', '2', None, 1),    (u'3', u'3', None, 1),
-        (u'\u232b', None, 'backspace', 1),
-    ]
-    NORMAL_4 = [
-        ('0', '0', None, 1),    (',', ',', None, 2),
-        (u'\u23ce', None, 'enter', 1)
-    ]
-
-# create a keyboard, with our custom layout
-k = MTVKeyboard(layout=NumericKeyboardLayout(), size=(400, 300))
-
-# create a instance of textinput, with this keyboard by default
-m = MTTextInput(keyboard=k)
-
-runTouchApp(m)

File framework/ui_widgets_composed_vkeyboardspellcheck.py

  • Ignore whitespace
-from pymt import *
-m = MTTextInput(keyboard=MTSpellVKeyboard(), font_size=42)
- 
-runTouchApp(m)

File framework/ui_widgets_container.py

  • Ignore whitespace
-from pymt import *
-import os
-
-# load an image
-current_dir = os.path.dirname(__file__)
-image = Image(os.path.join(current_dir, 'image.jpg'))
-
-# create a scatter container, and put the image in
-scatter = MTScatterContainer(image)
-
-runTouchApp(scatter)

File framework/ui_widgets_coverflow.py

  • Ignore whitespace
-from pymt import *
-from glob import glob
-from OpenGL.GL import *
-import os
-
-if __name__ == '__main__':
-    base_image = os.path.join(os.path.dirname(__file__),
-                              '..', 'pictures', 'images')
-    w = getWindow()
-    coverflow = MTCoverFlow(size=w.size)
-    for filename in glob(os.path.join(base_image, '*.jpg')):
-        button = MTImageButton(image=Loader.image(filename))
-        button.title = os.path.basename(filename)
-        coverflow.add_widget(button)
-
-    runTouchApp(coverflow)

File framework/ui_widgets_flippable.py

  • Ignore whitespace
-from pymt import *
-
-widget = MTFlippableWidget()
-widget.add_widget(MTLabel(label='Front'), side='front')
-widget.add_widget(MTLabel(label='Back'), side='back')
-
-@widget.event
-def on_touch_down(touch):
-    widget.flip()
-
-runTouchApp(widget)

File framework/ui_widgets_label.py

  • Ignore whitespace
-from pymt import *
-
-# for our example, force drawing of background for all label
-c = '''label {
-    draw-background: 1;
-    bg-color: rgb(0,0,255,120);
-}'''
-css_add_sheet(c)
-
-# add all the label to the window
-m = getWindow()
-
-# testing autowidth/autoheight
-l = MTLabel(label='Label1: PLOP Woooooooooooooooot !', font_size=24, autowidth=True, autoheight=True, pos=(200, 400))
-m.add_widget(l)
-
-# testing multiline with autowidth/autoheight
-l2 = MTLabel(label='Label2: Mwhahahaha\nLabel2: :)', pos=(200, 300), autowidth=True, autoheight=True)
-m.add_widget(l2)
-
-# testing multiline + padding + align
-l3 = MTLabel(label='Plop\nworld', pos=(200, 200), autosize=True, padding=10)
-l4 = MTLabel(label='Plop\nworld', pos=(300, 200), autosize=True, padding=10, halign='center')
-l5 = MTLabel(label='Plop\nworld', pos=(400, 200), autosize=True, padding=10, halign='right')
-m.add_widget(l3)
-m.add_widget(l4)
-m.add_widget(l5)
-
-runTouchApp()

File framework/ui_widgets_layout.py

  • Ignore whitespace
-import random
-from pymt import *
-
-
-def simple_box_layout_test():
-    root = MTBoxLayout()
-    root.add_widget(MTButton(label="button 1"))
-    root.add_widget(MTButton(label="button 2"))
-    root.add_widget(MTButton(label="button 3"))
-    return root
-
-def vertical_box_layout_test():
-    root = MTBoxLayout(orientation='vertical', id='vertical', size_hint=(2.0,1.0), bg_color=(0,1,0,0.3))
-    root.add_widget(MTButton(label="button 1"))
-    root.add_widget(MTButton(label="button 2"))
-    root.add_widget(MTButton(label="button 3"))
-    return root
-
-def size_hint_box_layout_test():
-    root = MTBoxLayout(width=())
-    root.add_widget(MTButton(label="button 1"))
-    root.add_widget(MTButton(label="button 2"))
-    root.add_widget(MTButton(label="button 3"))
-    return root
-
-def stacked_box_layout():
-    root = MTBoxLayout(id='root', size_hint=(1.0,1.0),bg_color=(1,0,0,0.3))
-    root.add_widget(MTButton(label="button", size_hint=(1.0, 1.0)))
-    root.add_widget(simple_box_layout_test())
-    root.add_widget(vertical_box_layout_test())
-    root.add_widget(MTButton(label="button"))
-    return root
-
-if __name__ == '__main__':
-    root = stacked_box_layout()
-    runTouchApp(root)

File framework/ui_widgets_list.py

  • Ignore whitespace
-from pymt import *
-
-# callback for the buttons
-def test_button(btn, *largs):
-    print 'button pressed', btn.label
-
-# create a grid layout with 2 rows
-layout = MTGridLayout(rows=2)
-for x in xrange(22):
-    btn = MTToggleButton(label='label%d' % x)
-    btn.connect('on_press', curry(test_button, btn))
-    layout.add_widget(btn)
-
-# create a list of 400x200 size, and disable scrolling on Y axis
-lst = MTList(size=(400, 200), do_y=False)
-lst.add_widget(layout)
-
-# center the list on the screen
-anchor = MTAnchorLayout()
-anchor.add_widget(lst)
-
-runTouchApp(anchor)

File framework/ui_widgets_list_xy.py

  • Ignore whitespace
-from pymt import *
-
-# callback for the buttons
-def test_button(btn, *largs):
-    print 'button pressed', btn.label
-
-# create a grid layout with 2 rows
-layout = MTGridLayout(rows=4)
-for x in xrange(50):
-    btn = MTToggleButton(label='label%d' % x)
-    btn.connect('on_press', curry(test_button, btn))
-    layout.add_widget(btn)
-
-# create a list of 400x400 size
-# default is on both axis
-lst = MTList(size=(400, 400))
-lst.add_widget(layout)
-
-# center the list on the screen
-anchor = MTAnchorLayout()
-anchor.add_widget(lst)
-
-runTouchApp(anchor)

File framework/ui_widgets_objectdisplay.py

  • Ignore whitespace
-# Simple example to show fiducial on screen
-from pymt import *
-runTouchApp(MTObjectDisplay())

File framework/ui_widgets_radial.py

  • Ignore whitespace
-from pymt import *
-
-sl = MTVectorSlider(pos=getWindow().center)
-
-@sl.event
-def on_amplitude_change(value):
-    print 'Slider amplitude change', value
-
-@sl.event
-def on_angle_change(value):
-    print 'Slider angle change', value
-
-@sl.event
-def on_vector_change(x, y):
-    print 'Slider vector change', x, y
-
-runTouchApp(sl)

File framework/ui_widgets_rectangular.py

  • Ignore whitespace
-from pymt import *
-
-css_add_sheet('rectangularwidget { draw-background: 1; }')
-
-# create our root rectangular widget
-root = MTRectangularWidget()
-
-# create a rectangular widget, outside the first one
-child  = MTRectangularWidget(size=(200,200), pos=(200,200))
-
-root.add_widget(child)
-
-runTouchApp(root)

File framework/ui_widgets_scatter.py

  • Ignore whitespace
-from pymt import *
-
-# force background draw for scatter
-css_add_sheet('''
-scatterwidget {
-    draw-background: 1;
-}''')
-
-# add a simple scatter
-scatter = MTScatterWidget(size=(300, 300))
-
-runTouchApp(scatter)

File framework/ui_widgets_scatter_children.py

  • Ignore whitespace
-from pymt import *
-
-# force background draw for scatter
-css_add_sheet('''
-scatterwidget {
-    draw-background: 1;
-}''')
-
-# add a simple scatter
-scatter = MTScatterWidget(size=(300, 300), pos=(100, 100), rotation=45)
-
-# add some children in
-layout = MTBoxLayout()
-layout.add_widget(MTButton(label='A1'))
-layout.add_widget(MTButton(label='A2'))
-scatter.add_widget(layout)
-
-# now, the scatter is rotated, and the button too.
-# it's still possible to click on the button, even
-# if they are rotated too
-runTouchApp(scatter)

File framework/ui_widgets_scatter_image.py

  • Ignore whitespace
-from pymt import *
-import os
-
-# just get the image
-current_dir = os.path.dirname(__file__)
-filename = os.path.join(current_dir, 'image.jpg')
-
-# create 2 scatter with image
-m = MTScatterImage(filename=filename, opacity=.5)
-m2 = MTScatterImage(filename=filename, pos=(100, 100))
-
-win = getWindow()
-win.add_widget(m)
-win.add_widget(m2)
-
-runTouchApp()

File framework/ui_widgets_slider.py

  • Ignore whitespace
-from pymt import *
-
-# create a slider from 0.-1. and make it change colors when pressed 
-sl = MTSlider(min=0., max=1., style={'slider-color-down':(.5,1,0,1)})
-
-@sl.event
-def on_value_change(value):
-    print 'Slider value change', value
-
-runTouchApp(sl)

File framework/ui_widgets_slider_boundary.py

  • Ignore whitespace
-from pymt import *
-
-sl = MTBoundarySlider(value=50)
-
-@sl.event
-def on_value_change(vmin, vmax):
-    print 'Slider values change: ', vmin, ' - ', vmax
-
-runTouchApp(sl)

File framework/ui_widgets_slider_circular.py

  • Ignore whitespace
-# example with a scatter plane + multiple circular slider
-# add a css to see bounding box of circular slider
-
-from pymt import *
-
-css_add_sheet('circularslider { draw-background: 1; }')
-
-s = MTScatterPlane()
-
-m = MTBoxLayout(pos=(100,100))
-c = MTCircularSlider(radius=100.0, rotation=200, value=50, thickness=20)
-m.add_widget(c)
-c2 = MTCircularSlider(radius=50.0, rotation=90, value=75)
-m.add_widget(c2)
-c3 = MTCircularSlider(radius=80.0, value=25, padding=8, thickness=50)
-c3.value = 100
-c.value = 25
-
-c.connect('on_value_change', c2, 'value')
-c.connect('on_value_change', c3, 'value')
-
-m.add_widget(c3)
-s.add_widget(m)
-
-runTouchApp(s)

File framework/ui_widgets_slider_multi.py

  • Ignore whitespace
-from pymt import *
-
-sl = MTMultiSlider(init_value=0.1)
-
-@sl.event
-def on_value_change(values):
-    print 'Slider values change: ', values
-
-runTouchApp(sl)

File framework/ui_widgets_slider_xy.py

  • Ignore whitespace
-
-from pymt import *
-
-# create a slider from 0.-1.
-sl = MTXYSlider()
-
-@sl.event
-def on_value_change(x, y):
-    print 'Slider value change', x, y
-
-runTouchApp(sl)

File framework/ui_widgets_xmlwidget.py

  • Ignore whitespace
-from pymt import *
-
-guixml = '''<?xml version="1.0" encoding="UTF-8"?>
-<MTWidget>
-    <MTButton label="1" pos="(50,150)" color="(1,0,0)" />
-    <MTButton label="2" pos="(250,150)" color="(0,1,0)" />
-    <MTButton label="2" pos="(450,150)" color="(0,0,1)" />
-    <MTWidget>
-        <MTButton label="5" pos="(0,0)" color="(0,0,0)"/>
-        <MTButton label="6" pos="(100,0)" color="(1,1,1)"/>
-    </MTWidget>
-</MTWidget>
-'''
-
-# create the gui from xml
-widget = XMLWidget(xml=guixml)
-
-# run the app from the root widget
-runTouchApp(widget.root)
-

File games/mole/mole.py

View file
  • Ignore whitespace
     
     def __init__(self,**kwargs):
         kwargs.setdefault('matrix_size', (3, 3))
-        super(TTTGame, self).__init__(**kwargs)
+        super(Mole, self).__init__(**kwargs)
         #TODO
         #self.player_images = (MTWidget(),MTSvg(filename='cross.svg'),MTSvg(filename='circle.svg') )
         self.player = 1
     ctx = MTContext()
     pymt_plugin_activate(w, ctx)
     runTouchApp()
-    pymt_plugin_deactivate(w, ctx)
+    pymt_plugin_deactivate(w, ctx)