Status of Python
Posted: 08 August 2008 10:48 AM   [ Ignore ]
Avatar
Rank
Joined  2008-05-06
Total Posts:  58
New Member

Greetings everyone!

I’m writing this post because, well, I’m confused, I need direction, and I think I might not be alone in either. Like many others, I began writing my own custom apps in Actionscript 3/Flash, and while it makes it quick and easy to develop them, it also runs slow as heck on anything other than a beast of a computer, and it doesn’t really allow for the sorts of graphical manipulations that I know many of us would like to see, since there’s no direct access to hardware rendering (at least, not in Flash 9). Then I was tipped onto Python. Seems fairly easy to pick up (although it might take a lifetime to master), there are great libraries out there already for working with graphics, and there are a few folks already working on things Python and multitouch related. However, it seems...disorganized, to say the least.

I’m a total newbie to Python, I’ll admit it, but when I came to learn how to do multitouch, I was able to jump right into the AS3 side of things because there were tutorials, examples, and tons of code already floating around. There were also guides, and the AS3 example code was integrated right into the Touchlib code you download from the SVN. Since trying to jump into the Python side of things, though, I’ve found no less than 4 different libraries, all promising to deliver basically the same thing, barely any example working applications, and not even a dedicated sub-forum, let alone guides or tutorials. If we want to get serious about Python around NUIGroup, I suggest we start changing this, for the good of all those folks out there, like me, who are trying to get a grip on this, and simply finding themselves floundering around without a clue.

So, here’s what I’m asking, oh ye Lords of Multitouch Python (and you know who you are): what is the status of Python and multitouch? What libraries are out there? What samples? Any tutorials? Can we settle on a way to get the ball rolling, an “official” NUIGroup way of doing Python multitouch, and start progressing from there? If not, what differences need to be solved to get to that point?

I don’t mean in any way to imply that the progress of the Python side of things is progressing too slowly, I just feel completely in the dark about the whole thing. I’ve poured over the python-lux transcript till my eyes bled, but it all boils down to one question: if I want to make the transition from AS3 to Python, where should I start?

On a side note, I’d like to begin the discussion by bringing up the subject of object event handling. In AS3, the concept is that you attach event listeners to each object you place on the table, then write generic event handlers. So, when someone touches Photo #451, it fires an event to the generic event handler for the photo objects, and some action takes place. In most of the Python scripts I’ve seen (and correct me if I’m wrong, here), the events system seems (at best) to be set around a global blob level (i.e. an event fires every time the blob state of the table changes, and then you have to do collision detection or something to figure out if you touched anything...)—it seems like it would be best (if it were possible) to develop a system as close the AS3 way of doing things as possible, if for no other reason than to ease the transition of folks like myself, since I have a feeling that’s where a lot of Python converts will be coming from.

Well, sorry for the wall of text, but I think this is an important issue, and I was hoping this might spur some discussion.

Profile
 
 
Posted: 08 August 2008 11:03 AM   [ Ignore ]   [ # 1 ]
Avatar
RankRankRankRank
Joined  2008-06-04
Total Posts:  565
Elite

I to am eager to get to grips with python but as yet have had no coding experiance.  I think Xelapond is the Snake Charmer!.  And as a framework Lux should help alot.  Your right though, for this to become truly cross platform python is the way to go.

Incase you didn’t aleready know docs.python.org is the place to start as it starts from the begining.

 Signature 

}---)))@

V JAY!  http://www.v-lux.net LASER tut http://nuigroup.com/forums/viewthread/6407/

Architectural Technician and Building Surveys

http://www.jpgainsfordassociates.com

Profile
 
 
Posted: 08 August 2008 11:22 AM   [ Ignore ]   [ # 2 ]
Avatar
Rank
Joined  2008-05-06
Total Posts:  58
New Member

ajlovegrove: glad I’m not the only one, then :D.

As for learning Python itself, I’ve read through Dive into Python (http://www.diveintopython.org) an excellent e-Book for beginning with the language. I often learn best simply by doing, and I feel like I have enough of a base that if someone could point me in the right direction with an example app or two and say “have at it!”, I would be more than able to start finding my way. I just don’t know what that direction is, or what those sample apps are, yet :D.

Profile
 
 
Posted: 08 August 2008 11:31 AM   [ Ignore ]   [ # 3 ]
Avatar
RankRankRankRank
Joined  2008-04-22
Total Posts:  525
Elite

Hi,

Yes, docs.python.org/tut is a great place to start learning Python.  I don’t think Python is like AS3 in that you couldn’t really learn it through doing Multi-Touch stuff, yet.  You are better off following the tutorial, then learning how to do Multi-Touch.  You are correct is that there are many(4 or 5) different TUIO parsers for Python.  I have tried several of them out, and I like TouchPy the most.  It seems the most complete and stable.  I have been bugging admins for months to make a Python subsection, but it doesn’t look like it will happen(I think this will change with the release of Python-Lux).  Speaking of which, yes, the global blob state thing is true.  That is for lack of a proper Python Multi-Touch Framework.  Lux aims to fix this(I am 90% sure, maybe nuiman can confirm).  Lux will provide a unified framework, so between moving from AS3 to Python you will just have to learn a new language syntax, the framework will be the same.

At the moment Python Multi-Touch support is limited because of this event handling issue you pointed out.  We have many good GUI libraries, however.  Rabbyt, PyGame, PyGlet, Clutter.  All these allow for really easy graphical apps to be created.  That is only half the problem however, and once we have Python-Lux it will handle graphical drawing as welll as TUIO Parsing.

In summary, Python Multi-Touch support sucks at the moment.  We are only half way there.  This is going to change very soon.  Python-Lux will be ready very shortly after C++ Lux is released.  For now get started learning Python, and know that Python-Lux will be ready soon(can’t tell you when, I don’t know then Lux will be released).

All the best, and Good Luck!

Alex

 Signature 

I am more then willing to to test your Multi-Touch programs on Linux, PM me if you have something.  If you’re looking for something faster then AS3 and Easier then C, try Python!

My Blog

Profile
 
 
Posted: 07 September 2008 07:27 AM   [ Ignore ]   [ # 4 ]
Avatar
RankRankRankRank
Joined  2008-02-22
Total Posts:  556
Elite

Any good sites with info on Python?

 Signature 

http://www.justinriggio.com cool mad
http://www.niceminds.com My blog

Profile
 
 
Posted: 07 September 2008 09:45 AM   [ Ignore ]   [ # 5 ]
Avatar
RankRankRankRank
Joined  2008-04-22
Total Posts:  525
Elite

This thread is a great resource.

 Signature 

I am more then willing to to test your Multi-Touch programs on Linux, PM me if you have something.  If you’re looking for something faster then AS3 and Easier then C, try Python!

My Blog

Profile
 
 
Posted: 17 November 2008 01:19 AM   [ Ignore ]   [ # 6 ]
Avatar
RankRank
Joined  2007-11-29
Total Posts:  153
Member

pymt now supports attaching event handlers dynamically (and fiducials btw...but plenty of other things still need to be done).  It uses the pyglets events system which lets you do it in a couple of various ways.  For example:

from pymt import *


#you can use the @ decorator to say that the method you are defining is an event handler for an object like so:
b1=Button(pos=(0,10), size=(80,80))
@
b1.event
def on_click
(touchIDxy):
    
b1.color = (1,0,0,1)
    
@
b1.event
def on_touch_move
(touchestouchIDxy):
    
b1.color random_color()


#to do exactly the same you can push the event handler manually.
#this way the function can have any name and you can attach it to
#mutiple events or attach some function created somewhere else 
def exitHandler(touchIDxy):
        
import sys
        sys
.exit()

b2=Button(pos=(100,10), size=(80,80))
b2.push_handlers(on_click=exitHandler)



#throw the buttons in a window and run the app
root Container()
root.add_widget(b1)
root.add_widget(b2)

UIWindow(root)
runTouchApp()

the pyglet documentation is a little more thorough on all the fancy things you can do with these kinds of events: pyglet event framework

 Signature 

http://blog.tehansen.de
http://cs.uiowa.edu/~tehansen

Profile