Back to index

python3.2  3.2.2
Public Member Functions | Public Attributes | Private Member Functions | Static Private Member Functions
turtle.TurtleScreenBase Class Reference
Inheritance diagram for turtle.TurtleScreenBase:
Inheritance graph
[legend]
Collaboration diagram for turtle.TurtleScreenBase:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def __init__

Public Attributes

 cv
 canvwidth
 canvheight
 xscale
 yscale
_PyObject_HEAD_EXTRA Py_ssize_t ob_refcnt
struct _typeobjectob_type

Private Member Functions

def _createpoly
def _drawpoly
def _createline
def _drawline
def _delete
def _update
def _delay
def _iscolorstring
def _bgcolor
def _write

Static Private Member Functions

def _blankimage
def _image

Detailed Description

Provide the basic graphics functionality.
   Interface between Tkinter and turtle.py.

   To port turtle.py to some different graphics toolkit
   a corresponding TurtleScreenBase class has to be implemented.

Definition at line 458 of file turtle.py.


Constructor & Destructor Documentation

def turtle.TurtleScreenBase.__init__ (   self,
  cv 
)

Definition at line 481 of file turtle.py.

00481 
00482     def __init__(self, cv):
00483         self.cv = cv
00484         if isinstance(cv, ScrolledCanvas):
00485             w = self.cv.canvwidth
00486             h = self.cv.canvheight
00487         else:  # expected: ordinary TK.Canvas
00488             w = int(self.cv.cget("width"))
00489             h = int(self.cv.cget("height"))
00490             self.cv.config(scrollregion = (-w//2, -h//2, w//2, h//2 ))
00491         self.canvwidth = w
00492         self.canvheight = h
00493         self.xscale = self.yscale = 1.0

Here is the caller graph for this function:


Member Function Documentation

def turtle.TurtleScreenBase._bgcolor (   self,
  color = None 
) [private]
Set canvas' backgroundcolor if color is not None,
else return backgroundcolor.

Definition at line 578 of file turtle.py.

00578 
00579     def _bgcolor(self, color=None):
00580         """Set canvas' backgroundcolor if color is not None,
00581         else return backgroundcolor."""
00582         if color is not None:
00583             self.cv.config(bg = color)
00584             self._update()
00585         else:
00586             return self.cv.cget("bg")

Here is the call graph for this function:

Here is the caller graph for this function:

def turtle.TurtleScreenBase._blankimage ( ) [static, private]
return a blank image object

Definition at line 467 of file turtle.py.

00467 
00468     def _blankimage():
00469         """return a blank image object
00470         """
00471         img = TK.PhotoImage(width=1, height=1)
00472         img.blank()
00473         return img

def turtle.TurtleScreenBase._createline (   self) [private]
Create an invisible line item on canvas self.cv)

Definition at line 524 of file turtle.py.

00524 
00525     def _createline(self):
00526         """Create an invisible line item on canvas self.cv)
00527         """
00528         return self.cv.create_line(0, 0, 0, 0, fill="", width=2,
00529                                    capstyle = TK.ROUND)

Here is the call graph for this function:

def turtle.TurtleScreenBase._createpoly (   self) [private]
Create an invisible polygon item on canvas self.cv)

Definition at line 494 of file turtle.py.

00494 
00495     def _createpoly(self):
00496         """Create an invisible polygon item on canvas self.cv)
00497         """
00498         return self.cv.create_polygon((0, 0, 0, 0, 0, 0), fill="", outline="")

Here is the call graph for this function:

def turtle.TurtleScreenBase._delay (   self,
  delay 
) [private]
Delay subsequent canvas actions for delay ms.

Definition at line 564 of file turtle.py.

00564 
00565     def _delay(self, delay):
00566         """Delay subsequent canvas actions for delay ms."""
00567         self.cv.after(delay)

def turtle.TurtleScreenBase._delete (   self,
  item 
) [private]
Delete graphics item from canvas.
If item is"all" delete all graphics items.

Definition at line 553 of file turtle.py.

00553 
00554     def _delete(self, item):
00555         """Delete graphics item from canvas.
00556         If item is"all" delete all graphics items.
00557         """
00558         self.cv.delete(item)

Here is the caller graph for this function:

def turtle.TurtleScreenBase._drawline (   self,
  lineitem,
  coordlist = None,
  fill = None,
  width = None,
  top = False 
) [private]
Configure lineitem according to provided arguments:
coordlist is sequence of coordinates
fill is drawing color
width is width of drawn line.
top is a boolean value, which specifies if polyitem
will be put on top of the canvas' displaylist so it
will not be covered by other items.

Definition at line 531 of file turtle.py.

00531 
00532                   fill=None, width=None, top=False):
00533         """Configure lineitem according to provided arguments:
00534         coordlist is sequence of coordinates
00535         fill is drawing color
00536         width is width of drawn line.
00537         top is a boolean value, which specifies if polyitem
00538         will be put on top of the canvas' displaylist so it
00539         will not be covered by other items.
00540         """
00541         if coordlist is not None:
00542             cl = []
00543             for x, y in coordlist:
00544                 cl.append(x * self.xscale)
00545                 cl.append(-y * self.yscale)
00546             self.cv.coords(lineitem, *cl)
00547         if fill is not None:
00548             self.cv.itemconfigure(lineitem, fill=fill)
00549         if width is not None:
00550             self.cv.itemconfigure(lineitem, width=width)
00551         if top:
00552             self.cv.tag_raise(lineitem)

Here is the caller graph for this function:

def turtle.TurtleScreenBase._drawpoly (   self,
  polyitem,
  coordlist,
  fill = None,
  outline = None,
  width = None,
  top = False 
) [private]
Configure polygonitem polyitem according to provided
arguments:
coordlist is sequence of coordinates
fill is filling color
outline is outline color
top is a boolean value, which specifies if polyitem
will be put on top of the canvas' displaylist so it
will not be covered by other items.

Definition at line 500 of file turtle.py.

00500 
00501                   outline=None, width=None, top=False):
00502         """Configure polygonitem polyitem according to provided
00503         arguments:
00504         coordlist is sequence of coordinates
00505         fill is filling color
00506         outline is outline color
00507         top is a boolean value, which specifies if polyitem
00508         will be put on top of the canvas' displaylist so it
00509         will not be covered by other items.
00510         """
00511         cl = []
00512         for x, y in coordlist:
00513             cl.append(x * self.xscale)
00514             cl.append(-y * self.yscale)
00515         self.cv.coords(polyitem, *cl)
00516         if fill is not None:
00517             self.cv.itemconfigure(polyitem, fill=fill)
00518         if outline is not None:
00519             self.cv.itemconfigure(polyitem, outline=outline)
00520         if width is not None:
00521             self.cv.itemconfigure(polyitem, width=width)
00522         if top:
00523             self.cv.tag_raise(polyitem)

Here is the caller graph for this function:

def turtle.TurtleScreenBase._image (   filename) [static, private]
return an image object containing the
imagedata from a gif-file named filename.

Definition at line 475 of file turtle.py.

00475 
00476     def _image(filename):
00477         """return an image object containing the
00478         imagedata from a gif-file named filename.
00479         """
00480         return TK.PhotoImage(file=filename)

Here is the caller graph for this function:

def turtle.TurtleScreenBase._iscolorstring (   self,
  color 
) [private]
Check if the string color is a legal Tkinter color string.

Definition at line 568 of file turtle.py.

00568 
00569     def _iscolorstring(self, color):
00570         """Check if the string color is a legal Tkinter color string.
00571         """
00572         try:
00573             rgb = self.cv.winfo_rgb(color)
00574             ok = True
00575         except TK.TclError:
00576             ok = False
00577         return ok

Here is the caller graph for this function:

def turtle.TurtleScreenBase._update (   self) [private]
Redraw graphics items on canvas

Definition at line 559 of file turtle.py.

00559 
00560     def _update(self):
00561         """Redraw graphics items on canvas
00562         """
00563         self.cv.update()

Here is the caller graph for this function:

def turtle.TurtleScreenBase._write (   self,
  pos,
  txt,
  align,
  font,
  pencolor 
) [private]
Write txt at pos in canvas with specified font
and color.
Return text item and x-coord of right bottom corner
of text's bounding box.

Definition at line 587 of file turtle.py.

00587 
00588     def _write(self, pos, txt, align, font, pencolor):
00589         """Write txt at pos in canvas with specified font
00590         and color.
00591         Return text item and x-coord of right bottom corner
00592         of text's bounding box."""
00593         x, y = pos
00594         x = x * self.xscale
00595         y = y * self.yscale
00596         anchor = {"left":"sw", "center":"s", "right":"se" }
00597         item = self.cv.create_text(x-1, -y, text = txt, anchor = anchor[align],
00598                                         fill = pencolor, font = font)
00599         x0, y0, x1, y1 = self.cv.bbox(item)
00600         self.cv.update()
00601         return item, x1-1

Here is the caller graph for this function:


Member Data Documentation

Definition at line 491 of file turtle.py.

Definition at line 490 of file turtle.py.

Definition at line 482 of file turtle.py.

Definition at line 107 of file object.h.

struct _typeobject* _object::ob_type [inherited]

Definition at line 108 of file object.h.

Reimplemented in turtle.TurtleScreen.

Definition at line 492 of file turtle.py.

Reimplemented in turtle.TurtleScreen.

Definition at line 492 of file turtle.py.


The documentation for this class was generated from the following file: