goocanvas.CanvasView

goocanvas.CanvasView — The Canvas View

Synopsis

class goocanvas.CanvasView(gtk.Container):
    goocanvas.CanvasView()
def convert_from_item_space(item_view, x, y)
def convert_to_item_space(item_view, x, y)
def convert_from_pixel(x, y)
def convert_to_pixel(x, y)
def create_item_view(item, parent_view)
def get_item_view_at(x, y, pointer_event)
def get_model()
def get_scale()
def grab_focus(item_view)
def keyboard_grab(item_view, owner_events, time)
def keyboard_ungrab(item_view, time)
def pointer_grab(item_view, event_mask, cursor, time)
def pointer_ungrab(item_view, time)
def render(cr, bounds, scale)
def request_redraw(bounds)
def request_update()
def scroll_to(left, top)
def set_bounds(left, top, right, bottom)
def set_model(model)
def set_scale(pixel_per_unit)
def update()

Ancestry

+-- gobject.GObject
	+-- gtk.Object
		+-- gtk.Widget
			+-- gtk.Container
				+-- goocanvas.CanvasView

goocanvas.CanvasView Properties

gtk.Object Properties

gtk.Widget Properties

gtk.Container Properties

"anchor"Read/WriteWhere to place the canvas when it is smaller than the widget's allocated area. Default value: gtk.ANCHOR_NORTH_WEST
"model"Read/WriteThe model for the canvas view.
"scale"Read/WriteThe number of pixels to use for each device unit. Allowed values: >= 0 Default value: 1
"x1"Read/WriteThe x coordinate of the left edge of the canvas bounds, in device units. Default value: 0.
"x2"Read/WriteThe x coordinate of the right edge of the canvas bounds, in device units. Default value: 1000.
"y1"Read/WriteThe y coordinate at the top edge of the canvas bounds, in device units. Default value: 0.
"y2"Read/WriteThe y coordinate at the bottom edge of the canvas bounds, in device units. Default value: 1000.

goocanvas.CanvasView Signal Prototypes

"item-view-created" def callback(canvas_view, item, user_param, ...)
"set-scroll-adjustments" def callback(canvas_view, hadjustment, vadjustment, user_param, ...)

Description

Constructor

    goocanvas.CanvasView()
Returns:A new goocanvas.CanvasView

Creates a new canvas view.

Methods

goocanvas.CanvasView.convert_from_item_space

    def convert_from_item_space(item_view, x, y)
item_view:A goocanvas.CanvasItemView
x:The x coordinate to convert.
y: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 view coordinate space, applying all transformation matrices including the item's own transformation matrix, if it has one.

goocanvas.CanvasView.convert_from_pixel

    def convert_from_pixel(x, y)
x:The x coordinate to convert.
y:The y coordinate to convert.
Returns:The new x and y coordinates.

Converts a coordinate from pixels to the canvas view 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.

goocanvas.CanvasView.convert_to_item_space

    def convert_to_item_space(item_view, x, y)
item_view:A goocanvas.CanvasItemView
x:The x coordinate to convert.
y:The y coordinate to convert.
Returns:The new x and y coordinates.

Converts a coordinate from the canvas view coordinate space to the given item's coordinate space, applying all transformation matrices including the item's own transformation matrix, if it has one.

goocanvas.CanvasView.convert_to_pixel

    def convert_to_pixel(x, y)
x:The x coordinate to convert.
y:The y coordinate to convert.
Returns:The new x and y coordinates.

Converts a coordinate from the canvas view coordinate space to pixels. The canvas view 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

goocanvas.CanvasView.create_item_view

    def create_item_view(item, parent_view)
item:The the item to create a view for.
parent_view:The parent view of the new item.
Returns:A new item view.

Creates a new item view for the given item, It emits the "item-view-created" signal after creating the view, so application code can connect signal handlers to the new view if desired.

goocanvas.CanvasView.get_item_view_at

    def get_item_view_at(x, y, pointer_event)
x:The x coordinate of the point
y:The y coordinate of the point
pointer_event:Trueif the "pointer-events" properties of items should be used to determine which parts of the item are tested.
Returns: the item view found at the given point, or None if no item view was found.

Gets the item view at the given point.

goocanvas.CanvasView.get_model

    def get_model()
Returns: the goocanvas.CanvasModel being displayed.

Gets the model being displayed in the canvas.

goocanvas.CanvasView.get_scale

    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.

goocanvas.CanvasView.grab_focus

    def grab_focus(item_view)
item_view:The item view to grab the focus.
Returns:A goocanvas.CanvasView

Grabs the keyboard focus for the given item.

goocanvas.CanvasView.keyboard_grab

    def keyboard_grab(item_view, owner_events, time)
item_view:The item view to grab the keyword for.
owner_events: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 view.
time: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.

goocanvas.CanvasView.keyboard_ungrab

    def keyboard_grab(item_view, time)
item_view:The item view that has the keyboard grab.
time: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.

goocanvas.CanvasView.pointer_grab

    def pointer_grab(item_view, event_mask, cursor, time)
item_view:The item view to grab the pointer for.
event_mask:The events to receive during the grab.
cursor:The cursor to display during the grab, or None.
time: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 view.

goocanvas.CanvasView.pointer_ungrab

    def pointer_ungrab(item_view, time)
item_view:The item view that has the pointer grab.
time: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.

goocanvas.CanvasView.render

    def render(cr, bounds, scale)
cr:A cairo context.
bounds:The area to render, or None to render the entire canvas.
scale: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.

goocanvas.CanvasView.request_redraw

    def request_redraw(bounds)
bounds:The bounds to redraw.

Requests that the given bounds be redrawn.

goocanvas.CanvasView.request_update

    def request_update()

Schedules an update of the goocanvas.CanvasView. This will be performed in the idle loop, after all pending events have been handled, but before the canvas has been repainted.

goocanvas.CanvasView.scroll_to

    def scroll_to(left, top)
left:The x coordinate to scroll to.
top:The y coordinate to scroll to.

Scrolls the canvas, placing the given point as close to the top-left of the view as possible.

goocanvas.CanvasView.set_bounds

    def set_bounds(left, top, right, bottom)
left:The left edge.
top:The top edge.
right:The right edge.
bottom:The bottom edge.

Sets the bounds of the goocanvas.CanvasView in device units. By default, device units are the same as pixels, though set_scale can be used to specify a different scale.

goocanvas.CanvasView.set_model

    def set_model(model)
model: A goocanvas.CanvasModel.

Sets the model to be displayed in the goocanvas.CanvasView. A hierarchy of item views will be created, corresponding to the hierarchy of items in the model.

goocanvas.CanvasView.set_scale

    def set_scale(pixel_per_unit)
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.

goocanvas.CanvasView.update

    def update()

Updates any item views that need updating. This is only intended to be used by subclasses of goocanvas.CanvasView or goocanvas.CanvasItemView implementation. If the bounds of items change, they will request a redraw of the old and new bounds so the display is updated correctly.

Signals

The "item-view-created" goocanvas.CanvasView Signal

    def callback(canvas_view, item_view, item, user_param, ...)
canvas_view: The goocanvas.CanvasView.
item_view: The new goocanvas.CanvasItemView.
item: The goocanvas.Item.
user_param:the first user parameter (if any) specified with the connect() method
...:additional user parameters (if any)

The 'item-view-created" signal is emitted when the a new item view is created. Applications can set up signal handlers for the new item views here.

The "set-scroll-adjustments" goocanvas.CanvasView Signal

    def callback(canvas_view, hadjustment, vadjustment, user_param, ...)
canvas_view: The goocanvas.CanvasView.
hadjustment: The horizontal adjustment.
vadjustment: The vertical adjustment.
user_param: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.