Pen Tablet Support/GTK Widget

From OLPC
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.

Please note that because the driver support for the Pen Tablet is still in flux, this activity forks an evtest process to read input from the tablet. This will not be necessary in the future.