goocanvas.Canvas — The Canvas
class goocanvas.Canvas(gtk.Container): |
gtk.Object Properties
gtk.Widget Properties
gtk.Container Properties
|
"item-created" | def callback( |
"set-scroll-adjustments" | def callback( |
def convert_from_item_space(item
, x
, y
)
| A goocanvas.Item |
| The x coordinate to convert. |
| The y coordinate to convert. |
Returns: | The new x and y coordinates. |
Converts a coordinate from the given item's coordinate space to the canvas coordinate space, applying all transformation matrices including the item's own transformation matrix, if it has one.
def convert_from_pixel(x
, y
)
| The x coordinate to convert. |
| The y coordinate to convert. |
Returns: | The new x and y coordinates. |
Converts a coordinate from pixels to the canvas coordinate space.
The pixel coordinate space specifies pixels from the top-left of the entire canvas window,
according to the current scale setting. See
set_scale()
.
The canvas view coordinate space is specified in the call to
set_bounds()
.
def convert_to_item_space(item
, x
, y
)
| A goocanvas.Item |
| The x coordinate to convert. |
| The y coordinate to convert. |
Returns: | The new x and y coordinates. |
Converts a coordinate from the canvas coordinate space to the given item's coordinate space, applying all transformation matrices including the item's own transformation matrix, if it has one.
def convert_to_pixel(x
, y
)
| The x coordinate to convert. |
| The y coordinate to convert. |
Returns: | The new x and y coordinates. |
Converts a coordinate from the canvas coordinate space to pixels.
The canvas coordinate space is specified in the call to
set_bounds
The pixel coordinate space specifies pixels from the top-left of the entire canvas window,
according to the current scale setting. See
set_scale
def create_cairo_context()
Returns: | a new cairo context. |
Creates a cairo context, initialized with the default canvas settings.
def create_item(model
)
| The item model to create a canvas item for. |
Returns: | A new canvas item. |
Creates a new canvas item for the given item model, and recursively creates items for any children. It uses the create_item virtual method if it has been set. Subclasses of GooCanvas can define this method if they want to use custom views for items. It emits the "item-created" signal after creating the view, so application code can connect signal handlers to the new view if desired.
def get_bounds()
Returns: | A tuple with the four coordinates. |
Gets the bounds of the canvas, in canvas units. By default, canvas units are pixels, though the GooCanvas:units property can be used to change the units to points, inches or millimeters.
def get_default_line_width()
Returns: | The default line width of the canvas. |
Gets the default line width, which depends on the current units setting.
def get_item(model
)
| A
goocanvas.ItemModel
|
Returns: | The canvas item corresponding to the given
goocanvas.ItemModel
or None if no canvas item has been created for it yet.
|
Gets the canvas item associated with the given
goocanvas.ItemModel
.
This is only useful when set_root_item_model
has been used to set a model for the canvas.
For simple applications you can use get_item to set up signal handlers for your items, e.g.
item = canvas.get_item (my_item) item.connect ("button_press_event", on_my_item_button_press)
More complex applications may want to use the GooCanvas::item-created signal to hook up their signal handlers.
def get_item_at(x
, y
, is_pointer_event
)
| The x coordinate of the point. |
| The y coordinate of the point. |
| True if the "pointer-events" property of items should be used to determine which parts of the item are tested. |
Returns: | The item found at the given point, or None if no item was found. |
Gets the item at the given point.
def get_items_at(x
, y
, is_pointer_event
)
| The x coordinate of the point. |
| The y coordinate of the point. |
| True if the "pointer-events" property of items should be used to determine which parts of the item are tested. |
Returns: | A list of items found at the given point, with the top item at the start of the list, or None if no items were found. |
Gets all items at the given point.
def get_items_in_area(area
, inside_area
, allow_overlaps
, include_containers
)
| The area to compare with each item's bounds. |
| True if items inside area should be returned, or False if items outside area should be returned. |
| True if items which are partly inside and partly outside should be returned. |
| True if containers should be checked as well as normal items. |
Returns: | A list of items in the given area, or None if no items are found. |
Gets a list of items inside or outside a given area.
def get_root_item()
Returns: | The root item, or None if there is no root item. |
Gets the root item of the canvas, usually a
goocanvas.Group
.
def get_root_item_model()
Returns: | The root item model, or None if there is no root item. |
Gets the root item model of the canvas, usually a
goocanvas.GroupModel
.
def get_scale()
Returns: | The current scale setting. |
Gets the current scale of the canvas, i.e. the number of pixels to use for each device unit.
def grab_focus(item
)
| The item to grab the focus. |
Grabs the keyboard focus for the given item.
def keyboard_grab(item
, owner_events
, time
)
| The item to grab the keyword for. |
| True if keyboard events for this application
will be reported normally, or False if all keyboard events will
be reported with respect to the grab item. |
| The time of the event that lead to the keyboard grab.
This should come from the relevant
gtk.gdk.Event
|
Returns: | gtk.gdk.GRAB_SUCCESS if the grab succeeded. |
Grabs the keyboard focus for the given item.
def keyboard_grab(item
, time
)
| The item that has the keyboard grab. |
| The time of the event that lead to the keyboard ungrab.
This should come from the relevant
gtk.gdk.Event
|
Ungrabs the pointer, if the given item view has the pointer grab.
def pointer_grab(item
, event_mask
, cursor
, time
)
| The item to grab the pointer for. |
| The events to receive during the grab. |
| The cursor to display during the grab, or None .
|
| The time of the event that lead to the pointer grab.
This should come from the relevant
gtk.gdk.Event .
|
Returns: | gtk.gdk.GRAB_SUCCESS if the grab succeeded. |
Attempts to grab the pointer for the given item.
def pointer_ungrab(item
, time
)
| The item that has the pointer grab. |
| The time of the event that lead to the pointer ungrab.
This should come from the relevant
gtk.gdk.Event
|
Ungrabs the pointer, if the given item view has the pointer grab.
def register_widget_item(witem
)
| A goocanvas.Widget .
|
Registers a widget item with the canvas, so that the canvas can do the necessary actions to move and resize the widget as needed.
This function should only be used by
goocanvas.Widget
and subclass implementations.
def render(cr
, bounds
, scale
)
| A cairo context. |
| The area to render, or None
to render the entire canvas. |
| The scale to compare with each item's visibility threshold to see if they should be rendered. This only affects items that have their visibility set to goocanvas.ITEM_VISIBLE_ABOVE_THRESHOLD. |
Renders all or part of a canvas to the given cairo context.
def request_redraw(bounds
)
| The bounds to redraw. |
Requests that the given bounds be redrawn.
def request_update()
Schedules an update of the
goocanvas.Canvas
.
This will be performed in the idle loop, after all pending events have been handled,
but before the canvas has been repainted.
def scroll_to(left
, top
)
| The x coordinate to scroll to. |
| The y coordinate to scroll to. |
Scrolls the canvas, placing the given point as close to the top-left of the view as possible.
def set_bounds(left
, top
, right
, bottom
)
| The left edge. |
| The top edge. |
| The right edge. |
| The bottom edge. |
Sets the bounds of the
goocanvas.Canvas
in device units. By default, device units are the same as pixels, though
set_scale
can be used to specify a different scale.
def set_root_item(item
)
| The root canvas item. |
Sets the root item of the canvas. Any existing canvas items are removed.
def set_root_item_model(model
)
| The root canvas item model. |
Sets the root item of the canvas. A hierarchy of canvas items will be created, corresponding to the hierarchy of items in the model. Any current canvas items will be removed.
def set_scale(pixel_per_unit
)
| The new scale setting. |
Sets the current scale of the canvas, i.e. the number of pixels to use for each device unit.
def unregister_item(model
)
| The item model whose canvas item is being finalized. |
This function should be called in the finalize method of
goocanvas.Item
objects, to remove the canvas item from the GooCanvas's hash table.
def callback(canvas
, item
, model
, user_param
, ...
)
|
The goocanvas.Canvas .
|
|
The new goocanvas.Item .
|
|
The goocanvas.ItemModel .
|
| the first user parameter (if any) specified
with the connect ()
method
|
| additional user parameters (if any) |
The 'item-created" signal is emitted when the a new canvas item is created. Applications can set up signal handlers for the new items here.
def callback(canvas
, hadjustment
, vadjustment
, user_param
, ...
)
|
The goocanvas.Canvas .
|
| The horizontal adjustment. |
| The vertical adjustment. |
| the first user parameter (if any) specified
with the connect ()
method
|
| additional user parameters (if any) |
The 'set-scroll-adjustments" signal is emitted when the GooCanvas is placed inside a
gtk.ScrolledWindow
,
to connect up the adjustments so scrolling works properly.
It isn't useful for applications.