Editorial Workflows

Python UI Examples

public workflow

Install Workflow...

This workflow contains at least one Python script. Only use it if you trust the person who shared this with you, and if you know exactly what it does.

I understand, install the workflow!

This is a workflow for Editorial, a Markdown and plain text editor for iOS. To download it, you need to view this page on a device that has the app installed.

Description: This workflow contains simple example uses of the UI module to create custom UIs.

Some examples include:

- Animations for UI controls
- Importing images as control images or backgrounds
- changing colors via switches
- adding views to custom views
- Delegates
- touch handling

Shared by: Tutorial Doctor

Comments: Comment Feed (RSS)

There are no comments yet.

+ Add Comment

Workflow Preview
Resizable Window ?
Source Code
from ui import *

class ViewClass(View):
	def __init__(self):
		pass
	def touch_began(self,touch):
		window.width = touch.location[0]
		window.height = touch.location[1]
	def touch_moved(self,touch):
		window.width = touch.location[0]
		window.height = touch.location[1]
	def touched_ended(self,touch):
		window.width = touch.location[0]
		window.height = touch.location[1]

main_window = load_view()
window = main_window['window']
main_window.present('sheet')
Stop ?
Stop
  • This Workflow
  • Repeat Block
Show HUD Alert
ON
Message
Drag an example above the stop action to view it.
To Do ?
Animate ?
Source Code
import ui
import sound

screen = ui.get_screen_size()
screen_X = screen[0]
screen_Y = screen[1]


def LowerCurtain(sender):
	if curtain.height != 200:
		sound.play_effect('Woosh_2')
	def Lower():
		curtain.height = 200
	ui.animate(Lower,1)
	window['curtain'].text = 'Lowered'
	window['field'].enabled = False
	window['switch'].enabled = False


def RaiseCurtain(sender):
	if curtain.height != 32:
		sound.play_effect('Woosh_1')
	curtain.height = 32
	window['curtain'].text = 'Raised'
	window['field'].enabled = True
	window['switch'].enabled = True


window = ui.load_view()
window['field'].enabled = False


curtain = window['curtain']
curtain.flex = 'TRW'
window['curtain'].height = 200


window.present('sheet')
Animate Scale ?
Source Code
import ui

def tapped(sender):
	def animation():
		box.width=0
		box.height=0
	ui.animate(animation,1)

window = ui.load_view()
box = window['box']
box.font = ('Arial',24)

window.present('sheet')
Animate location (WIP) ?
Source Code
import ui
import math
import numbers

def pressed(sender):
	def animation():
		for i in range (0,500):
			box.x = box.x + 1
			box.y = math.sin(box.x)
	ui.animate(animation,5)

window = ui.load_view()
box = window['button']
box.font = ('Arial',24)

window.present('sheet')
Function Trigger ?
Source Code
import ui

def print_text(sender):
    print 'Hello'

ui.load_view().present('sheet')
Boolean Switch (Basic) ?
Source Code
from ui import *

def Flip_Switch(sender):
	if sender.value == True:
		main_view.background_color= 'white'
	elif sender.value == False:
		main_view.background_color = 'black'

main_view = load_view()
switch = main_view['switch']
switch.action = Flip_Switch
main_view.present('sheet')
Boolean Switch ?
Source Code
import ui

def change(sender):
	field.text = str(switch.value)

window = ui.load_view()
window.present('sheet')

switch = window['switch']
field = window['field']

field.text = str(switch.value)
Coordinates ?
Source Code
import ui
import speech

import ui

class MyView (ui.View):
	def __init__(self):
		# This will also be called without arguments when the view is loaded from a UI file.
		# You don't have to call super. Note that this is called *before* the attributes
		# defined in the UI file are set. Implement `did_load` to customize a view after
		# it's been fully loaded from a UI file.
		pass
	def draw(self):
		# This will be called whenever the view's content needs to be drawn.
		# You can use any of the ui module's drawing functions here to render
		# content into the view's visible rectangle.
		# Do not call this method directly, instead, if you need your view
		# to redraw its content, call set_needs_display().
		# Example:
		pass

	def touch_began(self, touch):
		# Called when a touch begins.
		coor.center = touch.location
	def touch_moved(self, touch):
		# Called when a touch moves.
		coor.center = touch.location
		coor.text = str(coor.center)
		
	def touch_ended(self, touch):
		# Called when a touch ends.
		speech.say('final location' + str(coor.center),'en',.4)


main_view = ui.load_view()


coor = main_view['coor']
#coor.text = str(coor.x)


main_view.present('sheet')
Custom View Class Touch Events ?
Source Code
import ui
from sound import *
import workflow

class MyView (ui.View):
	def __init__(self):
		# This will also be called without arguments when the view is loaded from a UI file.
		# You don't have to call super. Note that this is called *before* the attributes
		# defined in the UI file are set. Implement `did_load` to customize a view after
		# it's been fully loaded from a UI file.
		self.indicator = ui.View(frame=(0,0,40,40), background_color='red')
		self.indicator.hidden = True
		self.add_subview(self.indicator)

	def did_load(self):
		# This will be called when a view has been fully loaded from a UI file.
		pass

	def will_close(self):
		# This will be called when a presented view is about to be dismissed.
		# You might want to save data here.
		pass

	def draw(self):
		# This will be called whenever the view's content needs to be drawn.
		# You can use any of the ui module's drawing functions here to render
		# content into the view's visible rectangle.
		# Do not call this method directly, instead, if you need your view
		# to redraw its content, call set_needs_display().
		# Example:
		pass
	def layout(self):
		# This will be called when a view is resized. You should typically set the
		# frames of the view's subviews here, if your layout requirements cannot
		# be fulfilled with the standard auto-resizing (flex) attribute.
		pass

	def touch_began(self, touch):
		# Called when a touch begins.
		print 'Touch'
		self.indicator.center = touch.location
		self.indicator.hidden = False
		main_view['touch'].center = touch.location

	def touch_moved(self, touch):
		# Called when a touch moves.
		self.indicator.center = touch.location
		main_view['touch'].center = touch.location

	def touch_ended(self, touch):
		# Called when a touch ends.
		self.indicator.hidden = True

	def keyboard_frame_will_change(self, frame):
		# Called when the on-screen keyboard appears/disappears
		# Note: The frame is in screen coordinates.
		pass

	def keyboard_frame_did_change(self, frame):
		# Called when the on-screen keyboard appears/disappears
		# Note: The frame is in screen coordinates.
		pass


def close_menu(sender):
	main_view.remove_subview(menu)
	play_effect('Click_1',1,.4) #sound,volume,pitch

def show_menu(sender):
	main_view.add_subview(menu)
	play_effect('Click_2')

def switch_sound(sender) :
	play_effect('Woosh_1',.2,.5)

main_view = ui.load_view()
main_view.touch_enabled

menu = main_view['menu']
window = main_view['window']

btn_close_menu = main_view['menu']['close_button']
btn_close_menu.action = close_menu

btn_show_menu = main_view['window']['menu_button']
btn_show_menu.action = show_menu

switch = main_view['menu']['switch']
switch.action = switch_sound

touch = main_view['touch']

main_view.present('sheet')

import ui
Color Toggle(WIP) ?
Source Code
import ui
def ChangeBackgroundColor(sender):
	
	if sender.value == True and sender == switch_green:
		view1.text_color = 'green'
		box.background_color = 'green'
		box.title = 'green'
	
		
	if sender.value == True and sender == switch_yellow:
		view2.text_color = 'yellow'
		box.background_color = 'yellow'
		box.title = 'yellow'
	
		
	if sender.value == True and sender == switch_red:
		view3.text_color = 'red'
		box.background_color = 'red'
		box.title = 'red'
	
		
	

window = ui.load_view()



view3 = window['view3']
view1 = window['view1']
view2 = window['view2']

switch_green = window['switch_green']
switch_yellow = window['switch_yellow']
switch_red = window['switch_red']

box = window['box']







window.present('popover',animated=True )
Delegates ?
Source Code
import ui
import sound

def play_sound(sender):
	sound.play_effect('Beep')
	
def change_color(sender):
	btn_color.background_color = 'red'

		
class MyTextViewDelegate (object):
	def textview_should_begin_editing(self, textview):
		return True
	def textview_did_begin_editing(self, textview):
		pass
	def textview_did_end_editing(self, textview):
		pass
	def textview_should_change(self, textview, range, replacement):
		return True
	def textview_did_change(self, textview):
		textview.text = 'changed'
	def textview_did_change_selection(self, textview):
		pass


class MyTableViewDelegate (object):
	def tableview_did_select(self, tableview, section, row):
		# Called when a row was selected.
		pass

	def tableview_did_deselect(self, tableview, section, row):
		# Called when a row was de-selected (in multiple selection mode).
		pass

	def tableview_title_for_delete_button(self, tableview, section, row):
		# Return the title for the 'swipe-to-***' button.
		return 'Remove'


class MyTextFieldDelegate (object):
	def textfield_should_begin_editing(self, textfield):
		return True
	def textfield_did_begin_editing(self, textfield):
		pass
	def textfield_did_end_editing(self, textfield):
		pass
	def textfield_should_return(self, textfield):
		textfield.end_editing()
		return True
	def textfield_should_change(self, textfield, range, replacement):
		return True
	def textfield_did_change(self, textfield):
		textfield.text = 'Changed'


view = ui.load_view()
view.present('sheet')

btn_color = view['btn_color']

text = view['text']
text.delegate = MyTextViewDelegate()

table = view['table']
table.delegate = MyTableViewDelegate()

field = view['field']
field.delegate = MyTextFieldDelegate()
Display (WIP) ?
Drag Window with sound ?
Source Code
# KEY/LEGEND:
# evt:event
# anim:animation


import ui
from sound import *

# FUNCTIONS
#Gets the center of a view
def Get_Center(frame):
	center = (frame.width/2,frame.height/2)
	return center

#Sets the top center of a view to a touch location
def Move_To_Location(frame,evt):
	frame.x = evt.location[0]-(frame.width/2)
	frame.y = evt.location[1]


# A custom view class (inherits from the ui.View class)
class ViewClass(ui.View):
	def __init__(self):
		pass
	def touch_began(self,touch):
		Move_To_Location(window,touch)
		play_effect('Click_1')
		pass
	def touch_moved(self,touch):
		Move_To_Location(window,touch)
		pass
	def touch_ended(self,touch):
		play_effect('Crashing')
		Move_To_Location(window,touch)


# OBJECTS
main_view = ui.load_view()
window = main_view['window']
window.touch_enabled = False 
title = main_view['window']['title']


# DISPLAY IT
main_view.present('fullscreen')
drop down menu(WIP) ?
Source Code
from ui import *

class menu(View):
	def __init__(self,hanger):
		self.height = 320
		self.width = 180
		self.x = hanger.x
		self.y = hanger.y + hanger.height
		self.border_color = 'black'
		self.border_width = 1

main_frame = load_view()
main_frame.present('sheet')
button = main_frame['button']
menu = menu(button)
main_frame.add_subview(menu)
Get & Set UI value ?
Source Code
import ui
import console

view = ui.load_view()

# Get value of a UI control in the UI designer
print view['label'].text

# Present the view
view.present('sheet')

# Set the value of a UI control in the UI Designer
update = view['label'].text = 'Welcome Editor'

print update
Navigation View ?
Source Code
from ui import *

def button_tapped(sender):
	sender.navigation_view.push_view(text)

main = load_view()
main.flex = 'TR'
text = main['text']
nav = NavigationView(main)
nav.navigation_bar_hidden = True 
nav.present('sheet')
Load Image (Basic) ?
Source Code
from PIL import Image
import ui
import photos
import console


show_albums = False
include_metadata = False
original = True 
raw_data = True
multi = False


image = ui.Image.from_data(photos.pick_image(show_albums,include_metadata,original,raw_data,multi))

image_size = image.size

window = ui.load_view()
window.present('popover')


#window.width = image_size[0]
#window.height = image_size[1]
window['view'].image = image

console.alert('Image Size',str(image_size))

#ui.Image.from_data(photos.get_image(-1,True,True))
#window['button'].background_image = image
Load Image Large ?
Source Code
from PIL import Image
import ui
import photos

screen = ui.get_screen_size()
screenX = screen[0]
screenY = screen[1]

window = ui.load_view()
window.present('fullscreen')

image = ui.Image.from_data(photos.pick_image(True,False,True,True,False))

#ui.Image.from_data(photos.get_image(-1,True,True))

#window['button'].background_image = image
window['view'].image = image
window['view'].width = screenX
window['view'].height = screenY
window['view'].center = (screenX/2,screenY/2)
Load image refined ?
Source Code
from PIL import Image
import ui
import photos


show_albums = False
include_metadata = False
original = True 
raw_data = True
multi = False


photo =photos.pick_image(show_albums,include_metadata,original,raw_data,multi)
image = ui.Image
image_data= image.from_data(photo)
                               

window = ui.load_view()
window.present('popover')


#window.width = image_size[0]
#window.height = image_size[1]
window['view'].image = image_data


#print image_size



#ui.Image.from_data(photos.get_image(-1,True,True))
#window['button'].background_image = image
Move In 2 ?
Source Code
import ui

screen = ui.get_screen_size()
screenX = screen[0]
screenY = screen[1]

def Move_In(sender):
	def animation2():
		text2.y = 200
		text2.alpha = 1
	ui.animate(animation2,2)
	

window = ui.load_view()
text2 = window['text2']
text2.alpha=0

window.present('fullscreen')
"Move In"'Animation ?
Source Code
import ui

screen = ui.get_screen_size()
screenX = screen[0]
screenY = screen[1]

def Move_In(sender):
	def animation():
		text.y = 200
		text.alpha = 1
	ui.animate(animation,2)
	
window = ui.load_view()
window.present('fullscreen')


text = window['text']
text.alpha=0
Path Drawing ?
Source Code
from ui import *

class MyView (View):
	def __init__(self):
		# This will also be called without arguments when the view is loaded from a UI file.
		# You don't have to call super. Note that this is called *before* the attributes
		# defined in the UI file are set. Implement `did_load` to customize a view after
		# it's been fully loaded from a UI file.
		pass

	def did_load(self):
		# This will be called when a view has been fully loaded from a UI file.
		pass

	def will_close(self):
		# This will be called when a presented view is about to be dismissed.
		# You might want to save data here.
		pass

	def draw(self):
		# This will be called whenever the view's content needs to be drawn.
		# You can use any of the ui module's drawing functions here to render
		# content into the view's visible rectangle.
		# Do not call this method directly, instead, if you need your view
		# to redraw its content, call set_needs_display().
		# Example:
		path = Path.oval(0,0, 300, 300)
		set_color('red')
		path.fill()
		
		img = Image.named('ionicons-beaker-256')
		img.draw(0, 0, 64, 64)

	def layout(self):
		# This will be called when a view is resized. You should typically set the
		# frames of the view's subviews here, if your layout requirements cannot
		# be fulfilled with the standard auto-resizing (flex) attribute.
		pass
	def touch_began(self, touch):
		# Called when a touch begins.
		pass
	def touch_moved(self, touch):
		pass
	def touch_ended(self, touch):
		# Called when a touch ends.
		pass


custom_view = MyView()
custom_view.present('sheet')
Push Window ?
Source Code
import ui


def Get_Center(frame):
	center = (frame.width/2,frame.height/2)
	return center
	
def Shift_Down(frame,speed=.1):
	def anim():
		frame.center = (frame.center[0],frame.center[1]+frame.height)
	ui.animate(anim,speed)
	
def Shift_Up(frame,speed=.1):
	def anim():
		frame.center = (frame.center[0],frame.center[1]-frame.height)
	ui.animate(anim,speed)
	
def Shift_Right(frame,speed):
	def anim():
		frame.center = (frame.center[0] + frame.width,frame.center[1])
	ui.animate(anim,speed)
	
def Shift_Left(frame):
	def anim():
		frame.center = (frame.center[0] - frame.width,frame.center[1])
	ui.animate(anim,speed)
	
	
class ViewClass(ui.View):
	def __init__(self):
		pass
	def touch_began(self,touch):
		Shift_Down(window,.2)
		pass
	def touch_moved(self,touch):
		#window.center = touch.location
		pass
	def touch_ended(self,touch):
		Shift_Up(window,.2)
		#pass
		
		
view = ui.load_view()
window = view['window']
window.touch_enabled = False 
title = view['window']['title']
view.present('sheet')
Window Touch Animation ?
Source Code
import ui


def Get_Center(frame):
	center = (frame.width/2,frame.height/2)
	return center
	

class ViewClass(ui.View):
	def __init__(self):
		pass
	def touch_began(self,touch):
		window.center = touch.location
		pass
	def touch_moved(self,touch):
		window.center = touch.location
		pass
	def touch_ended(self,touch):
		#self.center = touch.location
		def anim():
			window.center = Get_Center(view)
		ui.animate(anim,.4)


view = ui.load_view()
window = view['window']
window.touch_enabled = False 

view.present('sheet')
Rotate ?
Source Code
import ui

window = ui.load_view()


def rotate(object,amount):
	object.transform = ui.Transform.rotation(amount*0.0174532925)
	
	

label = window['label']


window.present('sheet')

rotate(label,30)
scale ?
Source Code
import ui

window = ui.load_view()


def scale(object,x,y):
	object.transform = ui.Transform.scale(x,y)
	
	

label_green = window['label_green']


window.present('sheet')

scale(label_green,2,2)
Sidebar ?
Source Code
from ui import *
import editor

class MyTextViewDelegate (object):
	def textview_should_begin_editing(self, textview):
		return True
	def textview_did_begin_editing(self, textview):
		pass
	def textview_did_end_editing(self, textview):
		pass
	def textview_should_change(self, textview, range, replacement):
		return True
	def textview_did_change(self, textview):
		pass
	def textview_did_change_selection(self, textview):
		pass


SCREEN = get_screen_size()
panel = load_view()

textview = panel['textview']
textview.text = editor.get_text()
textview.delegate = MyTextViewDelegate()

panel.present('sidebar')
Touch (WIP) ?
Source Code
import ui

class MyView (ui.View):
	def __init__(self):
		# This will also be called without arguments when the view is loaded from a UI file.
		# You don't have to call super. Note that this is called *before* the attributes
		# defined in the UI file are set. Implement `did_load` to customize a view after
		# it's been fully loaded from a UI file.
		pass

	def did_load(self):
		# This will be called when a view has been fully loaded from a UI file.
		pass

	def will_close(self):
		# This will be called when a presented view is about to be dismissed.
		# You might want to save data here.
		pass

	def draw(self):
		# This will be called whenever the view's content needs to be drawn.
		# You can use any of the ui module's drawing functions here to render
		# content into the view's visible rectangle.
		# Do not call this method directly, instead, if you need your view
		# to redraw its content, call set_needs_display().
		# Example:
		path = ui.Path.oval(0, 0, self.width, self.height)
		ui.set_color('red')
		path.fill()
		img = ui.Image.named('ionicons-beaker-256')
		img.draw(0, 0, self.width, self.height)

	def layout(self):
		# This will be called when a view is resized. You should typically set the
		# frames of the view's subviews here, if your layout requirements cannot
		# be fulfilled with the standard auto-resizing (flex) attribute.
		pass

	def touch_began(self, touch):
		# Called when a touch begins.
		print touch.location

	def touch_moved(self, touch):
		# Called when a touch moves.
		pass

	def touch_ended(self, touch):
		# Called when a touch ends.
		pass

	def keyboard_frame_will_change(self, frame):
		# Called when the on-screen keyboard appears/disappears
		# Note: The frame is in screen coordinates.
		pass

	def keyboard_frame_did_change(self, frame):
		# Called when the on-screen keyboard appears/disappears
		# Note: The frame is in screen coordinates.
		pass



v = MyView()
v.touch_began(view)
v.add_subview(view)
v.present('sheet')
Touch Image (Ole) ?
Source Code
#coding: utf-8
import workflow
import ui
import photos

class DragView (ui.View):
	def __init__(self):
		self.background_color = (1, 1, 1, 0.3)
		self.border_color = 'aqua'
		self.border_width = 2
		self.indicator = ui.View(frame=(0,0,40,40), background_color='red')
		self.indicator.hidden = True
		self.add_subview(self.indicator)
	
	def touch_began(self, touch):
		self.indicator.center = touch.location
		self.indicator.hidden = False
	
	def touch_moved(self, touch):
		self.indicator.center = touch.location
	
	def touch_ended(self, touch):
		self.indicator.hidden = True

class DemoView (ui.View):
	def __init__(self):
		self.image_view = ui.ImageView(frame=self.bounds)
		self.image_view.content_mode = ui.CONTENT_SCALE_ASPECT_FIT
		self.image_view.flex = 'WH'
		self.image_view.background_color = 'gray'
		self.add_subview(self.image_view)
		self.drag_view = DragView()
		self.add_subview(self.drag_view)
		
	def set_image(self, img):
		self.image_view.image = img
		self.layout()
	
	def layout(self):
		if self.image_view.image:
			w, h = self.width, self.height
			iw, ih = self.image_view.image.size
			scale = min(w/iw, h/ih)
			dw, dh = iw * scale, ih * scale
			x, y = (w - dw) * 0.5, (h - dh) * 0.5
			self.drag_view.frame = (x, y, dw, dh)
			

img = ui.Image.from_data(photos.pick_image(raw_data=True))
if img:
	v = ui.load_view()
	v['view1'].set_image(img)
	v.present()
translate ?
Source Code
import ui

window = ui.load_view()


def translate(object,x,y):
	object.transform = ui.Transform.translation(x,y)
	
	

label_blu = window['label_blu']


window.present('sheet')

translate(label_blu,100,-100)
View in Custom view ?
Source Code
import ui

class MyView (ui.View):
	def __init__(self):
		# This will also be called without arguments when the view is loaded from a UI file.
		# You don't have to call super. Note that this is called *before* the attributes
		# defined in the UI file are set. Implement `did_load` to customize a view after
		# it's been fully loaded from a UI file.
		v = ui.load_view()
		self.add_subview(v)

	def did_load(self):
		# This will be called when a view has been fully loaded from a UI file.
		pass

	def will_close(self):
		# This will be called when a presented view is about to be dismissed.
		# You might want to save data here.
		pass

	def draw(self):
		# This will be called whenever the view's content needs to be drawn.
		# You can use any of the ui module's drawing functions here to render
		# content into the view's visible rectangle.
		# Do not call this method directly, instead, if you need your view
		# to redraw its content, call set_needs_display().
		# Example:
		pass

	def layout(self):
		# This will be called when a view is resized. You should typically set the
		# frames of the view's subviews here, if your layout requirements cannot
		# be fulfilled with the standard auto-resizing (flex) attribute.
		pass

	def touch_began(self, touch):
		# Called when a touch begins.
		pass

	def touch_moved(self, touch):
		# Called when a touch moves.
		pass

	def touch_ended(self, touch):
		# Called when a touch ends.
		pass

	def keyboard_frame_will_change(self, frame):
		# Called when the on-screen keyboard appears/disappears
		# Note: The frame is in screen coordinates.
		pass

	def keyboard_frame_did_change(self, frame):
		# Called when the on-screen keyboard appears/disappears
		# Note: The frame is in screen coordinates.
		pass

v = MyView()
v.present('sheet')
Windows Basic ?
Source Code
import ui
from sound import *
import workflow
import console

def close_menu(sender):
	main_view.remove_subview(menu)
	play_effect('Click_1',1,.4) #sound,volume,pitch

def show_menu(sender):
	main_view.add_subview(menu)
	play_effect('Click_2')

def switch_sound(sender) :
	play_effect('Woosh_1',.2,.5)

main_view = ui.load_view()

menu = main_view['menu']
window = main_view['window']

btn_close_menu = main_view['menu']['close_button']
btn_close_menu.action = close_menu

btn_show_menu = main_view['window']['menu_button']
btn_show_menu.action = show_menu

switch = main_view['menu']['switch']
switch.action = switch_sound

main_view.present('sheet')
Windows 2 ?
Source Code
import ui
from sound import *
import workflow
import console

def close_menu(sender):
	window.remove_subview(menu)
	play_effect('Click_1',1,.4) #sound,volume,pitch

def show_menu(sender):
	window.add_subview(menu)
	play_effect('Click_2')

def switch_sound(sender) :
	play_effect('Woosh_1',.2,.5)

window = ui.load_view()

menu = window['menu']

btn_close = window['menu']['button']
btn_close.action = close_menu

btn_open = window['window2']['btn_show_menu']
btn_open.action = show_menu

go_switch = window['menu']['go']
go_switch.action = switch_sound

stop_switch = window['menu']['stop']
stop_switch.action = switch_sound

window.present('fullscreen')
Window Touch Animation ?
Source Code
import ui


def Get_Center(frame):
	center = (frame.width/2,frame.height/2)
	return center
	

class ViewClass(ui.View):
	def __init__(self):
		pass
	def touch_began(self,touch):
		window.center = touch.location
		pass
	def touch_moved(self,touch):
		window.center = touch.location
		pass
	def touch_ended(self,touch):
		#self.center = touch.location
		def anim():
			window.center = Get_Center(view)
		ui.animate(anim,.4)


view = ui.load_view()
window = view['window']
window.touch_enabled = False 

title = view['window']['title']

view.present('sheet')