Pen Tablet Support/GTK Widget

From OLPC
< Pen Tablet Support
Revision as of 13:20, 12 April 2008 by Pdubroy (talk | contribs) (New page: This GTK widget is intended for applications that want to map tablet input to an on-screen widget that is the same shape and aspect ratio as the physical tablet. At its largest size, this ...)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

This GTK widget is intended for applications that want to map tablet input to an on-screen widget that is the same shape and aspect ratio as the physical tablet. At its largest size, this would take up the full width of the screen and approximately 1/3 of the height of the screen.

Note: As of April 12, 2008, this is being developed in Patrick Dubroy's git branch at

 git://dev.laptop.org/users/pdubroy/sugar-toolkit 

or on gitweb. Comments are welcome -- please leave them on the Talk page.

Usage

Using this widget is as simple as:

 from sugar.graphics.tabletarea import TabletArea
 
 tablet_area = TabletArea()

This will create a gtk.DrawingArea on-screen. Whenever a stroke is detected on the tablet, a corresponding stroke will appear inside the widget. Some useful API:

 # Returns a list of strokes that have been made inside the tablet area
 tablet_area.get_strokes() 
 
 # Returns a copy of the gtk.gdk.Pixmap displayed on the tablet area
 tablet_area.get_pixmap() 
 
 # Clears the tablet area -- both the pixmap and the list of strokes.
 tablet_area.clear()

Full API documentation (subject to change) can be found here.

Sample Activity

For more information, please see the sample activity: source is in

 git://dev.laptop.org/users/pdubroy/TabletAreaTest 

or on gitweb. Alternatively, you can just grab the bundle: TabletAreaTest-1.xo.