Pen Tablet Support/GTK Widget: Difference between revisions

From OLPC
Jump to navigation Jump to search
(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 ...)
 
No edit summary
Line 4: Line 4:
git://dev.laptop.org/users/pdubroy/sugar-toolkit
git://dev.laptop.org/users/pdubroy/sugar-toolkit


or on [http://dev.laptop.org/git?p=users/pdubroy/sugar-toolkit gitweb]. Comments are welcome -- please leave them on the Talk page.
or on [http://dev.laptop.org/git?p=users/pdubroy/sugar-toolkit gitweb]. Comments are welcome -- please leave them on the [[Talk:Pen_Tablet_Support/GTK_Widget |Talk page]].


== Usage ==
== Usage ==
Line 33: Line 33:


or on [http://dev.laptop.org/git?p=users/pdubroy/TabletAreaTest gitweb]. Alternatively, you can just grab the bundle: [http://dev.laptop.org/~pdubroy/TabletAreaTest-1.xo TabletAreaTest-1.xo].
or on [http://dev.laptop.org/git?p=users/pdubroy/TabletAreaTest gitweb]. Alternatively, you can just grab the bundle: [http://dev.laptop.org/~pdubroy/TabletAreaTest-1.xo 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.

Revision as of 17:23, 12 April 2008

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.