Module eagle :: Class Canvas
[show private | hide private]
[frames | no frames]

Type Canvas

object --+        
         |        
 _EGObject --+    
             |    
     _EGWidget --+
                 |
                Canvas


The drawing area.

Eagle's drawing area (Canvas) is provided with a frame and an optional label, together with scrollbars, to make it fit everywhere.
Method Summary
  __init__(self, id, width, height, label, bgcolor, callback)
Canvas Constructor.
  __color_from__(color)
Convert from color to internal representation. (Static method)
  __configure_gc__(self, fgcolor, bgcolor, fill, line_width, line_style)
  __get_resize_mode__(self)
Return a tuple with ( horizontal, vertical ) resize mode
  __repr__(self)
  __set_useful_attributes__(self)
  __setup_connections__(self)
  __setup_gui__(self, width, height)
  __str__(self)
  clear(self)
Clear using bgcolor.
  draw_arc(self, x, y, width, height, start_angle, end_angle, color, size, fillcolor, filled)
Draw arc on canvas.
  draw_image(self, image, x, y, width, height, src_x, src_y)
Draw image on canvas.
  draw_line(self, x0, y0, x1, y1, color, size)
Draw line.
  draw_lines(self, points, color, size)
Draw lines connecting points.
  draw_point(self, x, y, color)
Draw point.
  draw_points(self, points, color)
Draw points.
  draw_polygon(self, points, color, size, fillcolor, filled)
Draw polygon on canvas.
  draw_rectangle(self, x, y, width, height, color, size, fillcolor, filled)
Draw rectagle.
  draw_segments(self, segments, color, size)
Draw line segments.
  draw_text(self, text, x, y, fgcolor, bgcolor, font_name, font_size, font_options, width, wrap_word, alignment, justify)
Draw text on canvas.
  fill(self, color)
  get_image(self)
Get the Image that represents this drawing area.
  get_size(self)
  resize(self, width, height)
Resize the drawing area.
    Inherited from _EGWidget
  __get_widgets__(self)
Return a list of internal widgets this Eagle widget contains.
  hide(self)
Make widget invisible.
  set_active(self, active)
Set the widget as active.
  set_inactive(self)
Same as set_active( False )
  show(self)
Make widget visible.
    Inherited from object
  __delattr__(...)
x.__delattr__('name') <==> del x.name
  __getattribute__(...)
x.__getattribute__('name') <==> x.name
  __hash__(x)
x.__hash__() <==> hash(x)
  __new__(T, S, ...)
T.__new__(S, ...) -> a new object with type S, a subtype of T
  __reduce__(...)
helper for pickle
  __reduce_ex__(...)
helper for pickle
  __setattr__(...)
x.__setattr__('name', value) <==> x.name = value

Property Summary
  label
    Inherited from _EGWidget
  app
    Inherited from _EGObject
  id

Class Variable Summary
str bgcolor = 'black'
int CENTER = 0                                                                     
str FONT_NAME_MONO = 'monospace'
str FONT_NAME_NORMAL = 'normal'
str FONT_NAME_SANS = 'sans'
str FONT_NAME_SERIF = 'serif'
int FONT_OPTION_BOLD = 1                                                                     
int FONT_OPTION_ITALIC = 4                                                                     
int FONT_OPTION_OBLIQUE = 2                                                                     
int LEFT = -1                                                                    
int padding = 5                                                                     
int RIGHT = 1                                                                     

Instance Method Details

__init__(self, id, width, height, label='', bgcolor=None, callback=None)
(Constructor)

Canvas Constructor.
Parameters:
id - unique identifier.
width - width of the drawing area in pixels, widget can be larger or smaller because and will use scrollbars if need.
height - height of the drawing area in pixels, widget can be larger or smaller because and will use scrollbars if need.
label - label to display in the widget frame around the drawing area.
bgcolor - color to paint background.
callback - function (or list of functions) to call when mouse state changed in the drawing area. Function will get as parameters:
  • App reference
  • Canvas reference
  • Button state
  • horizontal positon (x)
  • vertical positon (y)
Overrides:
eagle._EGWidget.__init__

__get_resize_mode__(self)

Return a tuple with ( horizontal, vertical ) resize mode
Overrides:
eagle._EGWidget.__get_resize_mode__ (inherited documentation)

clear(self)

Clear using bgcolor.

draw_arc(self, x, y, width, height, start_angle, end_angle, color=None, size=1, fillcolor=None, filled=False)

Draw arc on canvas.

Arc will be the part of an ellipse that starts at ( x, y ) and have size of widthxheight.

start_angle and end_angle are in radians, starts from the positive x-axis and are counter-clockwise.

If filled is True, it will be filled with fillcolor.

If color is provided, it will draw the arc's frame, even if filled is True. Frame here is just the curve, not the straight lines that are limited by start_angle and end_angle.

draw_image(self, image, x=0, y=0, width=None, height=None, src_x=0, src_y=0)

Draw image on canvas.

By default it draws entire image at top canvas corner.

You may restrict which image areas to use with src_x, src_y, width and height.

You may choose position on canvas with x and y.

draw_line(self, x0, y0, x1, y1, color=None, size=1)

Draw line.

draw_lines(self, points, color=None, size=1)

Draw lines connecting points.

Points are connected using lines, but first and last points are not connected, use draw_polygon instead.

draw_point(self, x, y, color=None)

Draw point.

draw_points(self, points, color=None)

Draw points.

Efficient way to draw more than one point with the same characteristics.

draw_polygon(self, points, color=None, size=1, fillcolor=None, filled=False)

Draw polygon on canvas.

If filled is True, it will be filled with fillcolor.

If color is provided, it will draw the polygon's frame, even if filled is True.

draw_rectangle(self, x, y, width, height, color=None, size=1, fillcolor=None, filled=False)

Draw rectagle.

If filled is True, it will be filled with fillcolor.

If color is provided, it will draw the rectangle's frame, even if filled is True.

draw_segments(self, segments, color=None, size=1)

Draw line segments.

Efficient way to draw more than one line with the same characteristics.

Lines are not connected, use draw_lines instead.

draw_text(self, text, x=0, y=0, fgcolor=None, bgcolor=None, font_name=None, font_size=None, font_options=0, width=None, wrap_word=False, alignment=-1, justify=True)

Draw text on canvas.

By default text is draw with current font and colors at top canvas corner.

You may limit width providing a value and choose if it should wrap at words (wrap_word=True) or characters (wrap_word=False).

Colors can be specified with fgcolor an bgcolor. If not provided, the system foreground color is used and no background color is used.

Font name, size and options may be specified using font_name, font_size and font_options, respectively. Try to avoid using system specific font fames, use those provided by FONT_NAME_*. Font options is OR'ed values from FONT_OPTIONS_*.

Text alignment is one of LEFT, RIGHT or CENTER.

get_image(self)

Get the Image that represents this drawing area.

resize(self, width, height)

Resize the drawing area.

Static Method Details

__color_from__(color)

Convert from color to internal representation.

Gets a string, integer or tuple/list arguments and converts into internal color representation.

Property Details

label

Get Method:
get(...)
Set Method:
set(...)

Class Variable Details

bgcolor

Type:
str
Value:
'black'                                                                

CENTER

Type:
int
Value:
0                                                                     

FONT_NAME_MONO

Type:
str
Value:
'monospace'                                                            

FONT_NAME_NORMAL

Type:
str
Value:
'normal'                                                               

FONT_NAME_SANS

Type:
str
Value:
'sans'                                                                 

FONT_NAME_SERIF

Type:
str
Value:
'serif'                                                                

FONT_OPTION_BOLD

Type:
int
Value:
1                                                                     

FONT_OPTION_ITALIC

Type:
int
Value:
4                                                                     

FONT_OPTION_OBLIQUE

Type:
int
Value:
2                                                                     

LEFT

Type:
int
Value:
-1                                                                    

padding

Type:
int
Value:
5                                                                     

RIGHT

Type:
int
Value:
1                                                                     

Generated by Epydoc 2.1 on Sun Dec 25 16:27:53 2005 http://epydoc.sf.net