Skip to content
This repository has been archived by the owner on Nov 13, 2023. It is now read-only.

master #4

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@
*.swp
*.DS_Store
*.kpf
build/*
build/*
pymt/c_ext/c_*.c
10 changes: 5 additions & 5 deletions doc/autobuild.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@

def writefile(filename, data):
global dest_dir
print 'write', filename
print('write', filename)
f = os.path.join(dest_dir, filename)
h = open(f, 'w')
h.write(data)
h.close()


# Activate PyMT modules
for k in pymt.pymt_modules.list().keys():
for k in list(pymt.pymt_modules.list().keys()):
pymt.pymt_modules.import_module(k)

# Search all pymt module
Expand Down Expand Up @@ -117,7 +117,7 @@ def writefile(filename, data):
t += " api-%s.rst\n" % subpackage

# search modules
m = modules.keys()
m = list(modules.keys())
m.sort()
for module in m:
packagemodule = module.rsplit('.', 1)[0]
Expand All @@ -129,7 +129,7 @@ def writefile(filename, data):


# Create index for all module
m = modules.keys()
m = list(modules.keys())
m.sort()
refid = 0
for module in m:
Expand Down Expand Up @@ -180,4 +180,4 @@ def writefile(filename, data):


# Generation finished
print 'Generation finished, do make html'
print('Generation finished, do make html')
2 changes: 1 addition & 1 deletion doc/sources/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
import os
os.environ['PYMT_DOC_INCLUDE'] = '1'
import pymt
print pymt.__file__
print(pymt.__file__)

version = pymt.__version__
release = pymt.__version__
Expand Down
8 changes: 4 additions & 4 deletions examples/apps/3Ddrawing/3Ddrawing.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from __future__ import with_statement


# PYMT Plugin integration
IS_PYMT_PLUGIN = True
Expand Down Expand Up @@ -157,7 +157,7 @@ def pick(self, x,y):
self.draw_picking()
self.has_moved = False
pick = glReadPixels(int(x), int(y), 1, 1, GL_RGB, GL_UNSIGNED_BYTE)
pick = map(ord, pick)
pick = list(map(ord, pick))
return pick[0]*4, 1024 - pick[1]*4

def paint(self, x, y):
Expand Down Expand Up @@ -186,7 +186,7 @@ def on_touch_down(self, touch):
if len(self.touch_position) == 1:
self.touch1 = touch.id
elif len(self.touch_position) == 2:
self.touch1, self.touch2 = self.touch_position.keys()
self.touch1, self.touch2 = list(self.touch_position.keys())
v1 = Vector(*self.touch_position[self.touch1])
v2 = Vector(*self.touch_position[self.touch2])
self.scale_dist = v1.distance(v2)
Expand All @@ -209,7 +209,7 @@ def on_touch_move(self, touch):
#if we got here, its a touch to turn/scale the model
dx, dy, angle = 0,0,0
#two touches: scale and rotate around Z
if self.touch_position.has_key(self.touch1) and self.touch_position.has_key(self.touch2):
if self.touch1 in self.touch_position and self.touch2 in self.touch_position:
v1 = Vector(*self.touch_position[self.touch1])
v2 = Vector(*self.touch_position[self.touch2])

Expand Down
2 changes: 1 addition & 1 deletion examples/apps/3Dviewer/3Dviewer.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from __future__ import with_statement


# PYMT Plugin integration
IS_PYMT_PLUGIN = True
Expand Down
4 changes: 2 additions & 2 deletions examples/apps/flowchart/flowchart.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,8 +204,8 @@ def draw(self):
step = 200 * scale
a = int(a[0] / step - 1) * step, int(a[1] / step - 1) * step
b = int(b[0] / step + 1) * step, int(b[1] / step + 1) * step
for x in xrange(a[0], b[0], step):
for y in xrange(a[1], b[1], step):
for x in range(a[0], b[0], step):
for y in range(a[1], b[1], step):
set_color(.9, .9, .9)
drawLine((a[0], y, b[0], y), width=1)
drawLine((x, a[1], x, b[1]), width=1)
Expand Down
8 changes: 4 additions & 4 deletions examples/apps/fridgeletter/fridgeletter.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,12 @@ def __init__(self, **kwargs):

def createletters(self, *largs):
w = self.get_parent_window()
for c in xrange(65, 91): # A-Z
for c in range(65, 91): # A-Z
count = 1
if chr(c) in 'AEUIO':
count = 4
for i in xrange(0, count):
color = map(lambda x: x/255., (randint(100,255), randint(100,255), randint(100,255), 255))
for i in range(0, count):
color = [x/255. for x in (randint(100,255), randint(100,255), randint(100,255), 255)]
l = FridgeLetterAtomic(letter=chr(c), color=color)
if w:
l.pos = randint(0, w.width), randint(0, w.height)
Expand All @@ -73,7 +73,7 @@ def randomize(self, *largs):
for letter in self.children:
if letter == self.buttons:
continue
letter.do(Animation(pos=map(lambda x: x * random(), w.size),
letter.do(Animation(pos=[x * random() for x in w.size],
f='ease_out_cubic', duration=.5))

def draw(self):
Expand Down
4 changes: 2 additions & 2 deletions examples/apps/gestures/gestures.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ def on_gesture(self, gesture, touch):
# try to find gesture from database
best = self.gdb.find(gesture, minscore=0.5)
if not best:
print 'No gesture found\nString version of your last gesture :\n', self.gdb.gesture_to_str(gesture)
print('No gesture found\nString version of your last gesture :\n', self.gdb.gesture_to_str(gesture))
else:
print 'Gesture found, score', best[0], ':', best[1].label
print('Gesture found, score', best[0], ':', best[1].label)
self.lastgesture = gesture
self.lastbest = best

Expand Down
22 changes: 11 additions & 11 deletions examples/apps/mtwitter/twitter.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
import sys
import tempfile
import time
import urllib
import urllib2
import urlparse
import urllib.request, urllib.parse, urllib.error
import urllib.request, urllib.error, urllib.parse
import urllib.parse
import twitter

class TwitterError(Exception):
Expand Down Expand Up @@ -1295,7 +1295,7 @@ def SetXTwitterHeaders(self, client, url, version):

def _BuildUrl(self, url, path_elements=None, extra_params=None):
# Break url into consituent parts
(scheme, netloc, path, params, query, fragment) = urlparse.urlparse(url)
(scheme, netloc, path, params, query, fragment) = urllib.parse.urlparse(url)

# Add any additional path elements to the path
if path_elements:
Expand All @@ -1315,7 +1315,7 @@ def _BuildUrl(self, url, path_elements=None, extra_params=None):
query = extra_query

# Return the rebuilt URL
return urlparse.urlunparse((scheme, netloc, path, params, query, fragment))
return urllib.parse.urlunparse((scheme, netloc, path, params, query, fragment))

def _InitializeRequestHeaders(self, request_headers):
if request_headers:
Expand All @@ -1341,19 +1341,19 @@ def _GetOpener(self, url, username=None, password=None):
if username and password:
self._AddAuthorizationHeader(username, password)
handler = self._urllib.HTTPBasicAuthHandler()
(scheme, netloc, path, params, query, fragment) = urlparse.urlparse(url)
(scheme, netloc, path, params, query, fragment) = urllib.parse.urlparse(url)
handler.add_password(Api._API_REALM, netloc, username, password)
opener = self._urllib.build_opener(handler)
else:
opener = self._urllib.build_opener()
opener.addheaders = self._request_headers.items()
opener.addheaders = list(self._request_headers.items())
return opener

def _Encode(self, s):
if self._input_encoding:
return unicode(s, self._input_encoding).encode('utf-8')
return str(s, self._input_encoding).encode('utf-8')
else:
return unicode(s).encode('utf-8')
return str(s).encode('utf-8')

def _EncodeParameters(self, parameters):
'''Return a string in key=value&key=value form
Expand All @@ -1370,7 +1370,7 @@ def _EncodeParameters(self, parameters):
if parameters is None:
return None
else:
return urllib.urlencode(dict([(k, self._Encode(v)) for k, v in parameters.items() if v is not None]))
return urllib.parse.urlencode(dict([(k, self._Encode(v)) for k, v in list(parameters.items()) if v is not None]))

def _EncodePostData(self, post_data):
'''Return a string in key=value&key=value form
Expand All @@ -1388,7 +1388,7 @@ def _EncodePostData(self, post_data):
if post_data is None:
return None
else:
return urllib.urlencode(dict([(k, self._Encode(v)) for k, v in post_data.items()]))
return urllib.parse.urlencode(dict([(k, self._Encode(v)) for k, v in list(post_data.items())]))

def _FetchUrl(self,
url,
Expand Down
4 changes: 2 additions & 2 deletions examples/apps/paint/paint.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,14 +147,14 @@ def on_touch_down(self, touch):
self.touch_positions[touch.id] = (touch.x, touch.y)

def on_touch_move(self, touch):
if self.touch_positions.has_key(touch.id):
if touch.id in self.touch_positions:
ox,oy = self.touch_positions[touch.id]
self.paint_queue.appendleft((self.color, (ox,oy,touch.x,touch.y)))
self.do_paint_queue = True
self.touch_positions[touch.id] = (touch.x, touch.y)

def on_touch_up(self, touch):
if self.touch_positions.has_key(touch.id):
if touch.id in self.touch_positions:
del self.touch_positions[touch.id]

def update_brush(brush, size, *largs):
Expand Down
8 changes: 4 additions & 4 deletions examples/apps/particles/particles.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from __future__ import with_statement

from pymt import *
from OpenGL.GL import *
import random
Expand Down Expand Up @@ -29,9 +29,9 @@ def __init__(self, settings):
self.random_color()

def random_color(self):
r_min, r_max = map(lambda x: x/255., self.settings.color_r)
g_min, g_max = map(lambda x: x/255., self.settings.color_g)
b_min, b_max = map(lambda x: x/255., self.settings.color_b)
r_min, r_max = [x/255. for x in self.settings.color_r]
g_min, g_max = [x/255. for x in self.settings.color_g]
b_min, b_max = [x/255. for x in self.settings.color_b]
self.color = [random.uniform(r_min, r_max),
random.uniform(g_min, g_max),
random.uniform(b_min, b_max),
Expand Down
4 changes: 2 additions & 2 deletions examples/desktop/desktop-multi.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from __future__ import with_statement

import os
import math
from pymt import *
Expand Down Expand Up @@ -253,7 +253,7 @@ def on_gesture(self, gesture, touch):

try:
score, best = self.gdb.find(gesture, minscore=.5)
except Exception, e:
except Exception as e:
return

if best.id == 'circle':
Expand Down
2 changes: 1 addition & 1 deletion examples/desktop/desktop-single.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def populate(self):

# no icon ?
if icon is None:
print 'No icon found for', infos['title']
print('No icon found for', infos['title'])
continue

# create an image button for every plugin
Expand Down
2 changes: 1 addition & 1 deletion examples/framework/base_event_dispatcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# create a class to catch all events
class TouchEventListener:
def dispatch_event(self, event_name, *arguments):
print 'Event dispatched', event_name, 'with', arguments
print('Event dispatched', event_name, 'with', arguments)

# append the class to event listeners
pymt_event_listeners.append(TouchEventListener())
Expand Down
4 changes: 2 additions & 2 deletions examples/framework/core/audio.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@
# install callack for on_play/on_stop event
@sound.event
def on_play():
print '-> sound started, status is', sound.status
print('-> sound started, status is', sound.status)

@sound.event
def on_stop():
print '-> sound finished, status is', sound.status
print('-> sound finished, status is', sound.status)
stopTouchApp()

# start to play the sound
Expand Down
2 changes: 1 addition & 1 deletion examples/framework/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ def handle_exception(self, inst):
t = MTButton()
@t.event
def on_press(*largs):
print a
print(a)
m.add_widget(t)
runTouchApp()
2 changes: 1 addition & 1 deletion examples/framework/ui_dragable.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

# create 100 dragable object with random position and color
w, h = window.size
for i in xrange(100):
for i in range(100):
x = random() * w
y = random() * h
window.add_widget(MTDragable(pos=(x, y),
Expand Down
2 changes: 1 addition & 1 deletion examples/framework/ui_klist.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

# 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):
for x in range(100):
wlayout.add_widget(MTToggleButton(label=str(x)))

runTouchApp(wlist)
6 changes: 3 additions & 3 deletions examples/framework/ui_widgets_button.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@
b = MTButton(label='Push me')
@b.event
def on_press(*largs):
print 'on_press()', b.state, largs
print('on_press()', b.state, largs)

@b.event
def on_release(*largs):
print 'on_release()', b.state, largs
print('on_release()', b.state, largs)

@b.event
def on_state_change(*largs):
print 'on_state_change()', b.state, largs
print('on_state_change()', b.state, largs)

runTouchApp(b)
4 changes: 2 additions & 2 deletions examples/framework/ui_widgets_button_toggle.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@

@b.event
def on_press(*largs):
print 'on_press()', b.state, largs
print('on_press()', b.state, largs)

@b.event
def on_release(*largs):
print 'on_release()', b.state, largs
print('on_release()', b.state, largs)

runTouchApp(b)
2 changes: 1 addition & 1 deletion examples/framework/ui_widgets_buttonmatrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
def m_on_press(args):
# extract row / column / state
row, column, state = args
print 'matrix change at %d x %d = %s' % (row, column, state)
print('matrix change at %d x %d = %s' % (row, column, state))

# connect the handler to the widget
m.connect('on_press', m_on_press)
Expand Down
2 changes: 1 addition & 1 deletion examples/framework/ui_widgets_composed_filebrowser.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@
# when selection will be done, it will print the selected files
@fb.event
def on_select(list):
print list
print(list)

runTouchApp(fb)
4 changes: 2 additions & 2 deletions examples/framework/ui_widgets_composed_textarea.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@

@wid.event
def on_text_validate():
print 'Text have been validated:', wid.value
print('Text have been validated:', wid.value)

@wid.event
def on_text_change(text):
print 'Text have been changed (not validated):', text
print('Text have been changed (not validated):', text)

runTouchApp(wid)

2 changes: 1 addition & 1 deletion examples/framework/ui_widgets_composed_textinput.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@

@wid.event
def on_text_change(text):
print 'Text have been changed (not validated):', text
print('Text have been changed (not validated):', text)

runTouchApp(wid)
Loading