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

Class Canvas
source code

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.

Instance Methods [hide private]
  __init__(self, id, width, height, label="", bgcolor=None, scrollbars=True, callback=None)
Canvas Constructor.
  __setup_gui__(self, width, height)
  __set_useful_attributes__(self)
  __setup_connections__(self)
  __get_resize_mode__(self)
Return a tuple with ( horizontal, vertical ) resize mode
  __configure_gc__(self, fgcolor=None, bgcolor=None, fill=None, line_width=None, line_style=None)
  resize(self, width, height)
Resize the drawing area.
  draw_image(self, image, x=0, y=0, width=None, height=None, src_x=0, src_y=0)
Draw image on canvas.
  draw_text(self, text, x=0, y=0, fgcolor=None, bgcolor=None, font_name=None, font_size=None, font_options=0, font_family=None, width=None, wrap_word=False, alignment=LEFT, justify=True)
Draw text on canvas.
  draw_point(self, x, y, color=None)
Draw point.
  draw_points(self, points, color=None)
Draw points.
  draw_line(self, x0, y0, x1, y1, color=None, size=1)
Draw line.
  draw_segments(self, segments, color=None, size=1)
Draw line segments.
  draw_lines(self, points, color=None, size=1)
Draw lines connecting points.
  draw_rectangle(self, x, y, width, height, color=None, size=1, fillcolor=None, filled=False)
Draw rectagle.
  draw_arc(self, x, y, width, height, start_angle, end_angle, color=None, size=1, fillcolor=None, filled=False)
Draw arc on canvas.
  draw_polygon(self, points, color=None, size=1, fillcolor=None, filled=False)
Draw polygon on canvas.
  clear(self)
Clear using bgcolor.
  fill(self, color)
  get_size(self)
  get_image(self)
Get the Image that represents this drawing area.
  set_label(self, label)
  get_label(self)
  __str__(self)
  __repr__(self)

Inherited from _EGWidget: __get_widgets__, hide, set_active, set_inactive, show

Inherited from object: __delattr__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __setattr__


Static Methods [hide private]
  __color_from__(color)
Convert from color to internal representation.
  __to_gtk_color__(color)

Class Variables [hide private]
padding  
bgcolor  
LEFT  
CENTER  
RIGHT  
FONT_OPTION_BOLD  
FONT_OPTION_OBLIQUE  
FONT_OPTION_ITALIC  
FONT_NAME_NORMAL  
FONT_NAME_SERIF  
FONT_NAME_SANS  
FONT_NAME_MONO  
MOUSE_BUTTON_1  
MOUSE_BUTTON_2  
MOUSE_BUTTON_3  
MOUSE_BUTTON_4  
MOUSE_BUTTON_5  

Inherited from object: __class__


Properties [hide private]
label  

Inherited from _EGWidget: app

Inherited from _EGObject: id


Method Details [hide private]

__init__(self, id, width, height, label="", bgcolor=None, scrollbars=True, callback=None)
(Constructor)

source code 
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. If None, no label or frame will be shown.
  • bgcolor - color to paint background.
  • scrollbars - whenever to use scrollbars and make canvas fit small places.
  • 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 (or'ed MOUSE_BUTTON_*)
    • horizontal positon (x)
    • vertical positon (y)
Overrides: _EGWidget.__init__

To Do: honor the alpha value while drawing colors.

__setup_gui__(self, width, height)

source code 

__set_useful_attributes__(self)

source code 

__setup_connections__(self)

source code 

__get_resize_mode__(self)

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

__color_from__(color)

source code 

Convert from color to internal representation.

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

__to_gtk_color__(color)

source code 

__configure_gc__(self, fgcolor=None, bgcolor=None, fill=None, line_width=None, line_style=None)

source code 

resize(self, width, height)

source code 
Resize the drawing area.

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

source code 

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_text(self, text, x=0, y=0, fgcolor=None, bgcolor=None, font_name=None, font_size=None, font_options=0, font_family=None, width=None, wrap_word=False, alignment=LEFT, justify=True)

source code 

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, family, size and options may be specified using font_name, font_family, 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_*.

Font name is a string that have all the information, like "sans bold 12". This is returned by Font.

Text alignment is one of LEFT, RIGHT or CENTER.

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

source code 
Draw point.

draw_points(self, points, color=None)

source code 

Draw points.

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

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

source code 
Draw line.

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

source code 

Draw line segments.

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

Lines are not connected, use draw_lines instead.

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

source code 

Draw lines connecting points.

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

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

source code 

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_arc(self, x, y, width, height, start_angle, end_angle, color=None, size=1, fillcolor=None, filled=False)

source code 

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_polygon(self, points, color=None, size=1, fillcolor=None, filled=False)

source code 

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.

clear(self)

source code 
Clear using bgcolor.

fill(self, color)

source code 

get_size(self)

source code 

get_image(self)

source code 
Get the Image that represents this drawing area.

set_label(self, label)

source code 

get_label(self)

source code 

__str__(self)
(Informal representation operator)

source code 
Overrides: _EGObject.__str__

__repr__(self)
(Representation operator)

source code 
Overrides: _EGObject.__str__

Class Variable Details [hide private]

padding

Value:
5                                                                     
      

bgcolor

Value:
'black'                                                                
      

LEFT

Value:
-1                                                                    
      

CENTER

Value:
0                                                                     
      

RIGHT

Value:
1                                                                     
      

FONT_OPTION_BOLD

Value:
1                                                                     
      

FONT_OPTION_OBLIQUE

Value:
2                                                                     
      

FONT_OPTION_ITALIC

Value:
4                                                                     
      

FONT_NAME_NORMAL

Value:
'normal'                                                               
      

FONT_NAME_SERIF

Value:
'serif'                                                                
      

FONT_NAME_SANS

Value:
'sans'                                                                 
      

FONT_NAME_MONO

Value:
'monospace'                                                            
      

MOUSE_BUTTON_1

Value:
1                                                                     
      

MOUSE_BUTTON_2

Value:
2                                                                     
      

MOUSE_BUTTON_3

Value:
4                                                                     
      

MOUSE_BUTTON_4

Value:
8                                                                     
      

MOUSE_BUTTON_5

Value:
16                                                                    
      

Property Details [hide private]

label

Get Method:
eagle.Canvas.get_label(self)
Set Method:
eagle.Canvas.set_label(self, label)
Delete Method:
None