Back to index

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

List of all members.

Public Member Functions

def __init__
def setup
def title
def bye
def exitonclick
def clear
def mode
def setworldcoordinates
def register_shape
def colormode
def reset
def turtles
def bgcolor
def tracer
def delay
def update
def window_width
def window_height
def getcanvas
def getshapes
def onclick
def onkey
def onkeypress
def listen
def ontimer
def bgpic
def screensize

Public Attributes

 xscale
 yscale
 cv
 canvwidth
 canvheight
_PyObject_HEAD_EXTRA Py_ssize_t ob_refcnt
struct _typeobjectob_type

Static Public Attributes

 onscreenclick = onclick
 resetscreen = reset
 clearscreen = clear
 addshape = register_shape
 onkeyrelease = onkey

Private Member Functions

def _destroy

Static Private Attributes

 _root = None
 _canvas = None
list _title = _CFG["title"]

Detailed Description

Definition at line 3664 of file turtle.py.


Constructor & Destructor Documentation

def turtle._Screen.__init__ (   self)

Definition at line 3670 of file turtle.py.

03670 
03671     def __init__(self):
03672         # XXX there is no need for this code to be conditional,
03673         # as there will be only a single _Screen instance, anyway
03674         # XXX actually, the turtle demo is injecting root window,
03675         # so perhaps the conditional creation of a root should be
03676         # preserved (perhaps by passing it as an optional parameter)
03677         if _Screen._root is None:
03678             _Screen._root = self._root = _Root()
03679             self._root.title(_Screen._title)
03680             self._root.ondestroy(self._destroy)
03681         if _Screen._canvas is None:
03682             width = _CFG["width"]
03683             height = _CFG["height"]
03684             canvwidth = _CFG["canvwidth"]
03685             canvheight = _CFG["canvheight"]
03686             leftright = _CFG["leftright"]
03687             topbottom = _CFG["topbottom"]
03688             self._root.setupcanvas(width, height, canvwidth, canvheight)
03689             _Screen._canvas = self._root._getcanvas()
03690             TurtleScreen.__init__(self, _Screen._canvas)
03691             self.setup(width, height, leftright, topbottom)

Here is the call graph for this function:

Here is the caller graph for this function:


Member Function Documentation

def turtle._Screen._destroy (   self) [private]

Definition at line 3749 of file turtle.py.

03749 
03750     def _destroy(self):
03751         root = self._root
03752         if root is _Screen._root:
03753             Turtle._pen = None
03754             Turtle._screen = None
03755             _Screen._root = None
03756             _Screen._canvas = None
03757         TurtleScreen._RUNNING = True
03758         root.destroy()

Here is the caller graph for this function:

def turtle.TurtleScreen.bgcolor (   self,
  args 
) [inherited]
Set or return backgroundcolor of the TurtleScreen.

Arguments (if given): a color string or three numbers
in the range 0..colormode or a 3-tuple of such numbers.

Example (for a TurtleScreen instance named screen):
>>> screen.bgcolor("orange")
>>> screen.bgcolor()
'orange'
>>> screen.bgcolor(0.5,0,0.5)
>>> screen.bgcolor()
'#800080'

Definition at line 1215 of file turtle.py.

01215 
01216     def bgcolor(self, *args):
01217         """Set or return backgroundcolor of the TurtleScreen.
01218 
01219         Arguments (if given): a color string or three numbers
01220         in the range 0..colormode or a 3-tuple of such numbers.
01221 
01222         Example (for a TurtleScreen instance named screen):
01223         >>> screen.bgcolor("orange")
01224         >>> screen.bgcolor()
01225         'orange'
01226         >>> screen.bgcolor(0.5,0,0.5)
01227         >>> screen.bgcolor()
01228         '#800080'
01229         """
01230         if args:
01231             color = self._colorstr(args)
01232         else:
01233             color = None
01234         color = self._bgcolor(color)
01235         if color is not None:
01236             color = self._color(color)
01237         return color

Here is the call graph for this function:

def turtle.TurtleScreen.bgpic (   self,
  picname = None 
) [inherited]
Set background image or return name of current backgroundimage.

Optional argument:
picname -- a string, name of a gif-file or "nopic".

If picname is a filename, set the corresponding image as background.
If picname is "nopic", delete backgroundimage, if present.
If picname is None, return the filename of the current backgroundimage.

Example (for a TurtleScreen instance named screen):
>>> screen.bgpic()
'nopic'
>>> screen.bgpic("landscape.gif")
>>> screen.bgpic()
'landscape.gif'

Definition at line 1461 of file turtle.py.

01461 
01462     def bgpic(self, picname=None):
01463         """Set background image or return name of current backgroundimage.
01464 
01465         Optional argument:
01466         picname -- a string, name of a gif-file or "nopic".
01467 
01468         If picname is a filename, set the corresponding image as background.
01469         If picname is "nopic", delete backgroundimage, if present.
01470         If picname is None, return the filename of the current backgroundimage.
01471 
01472         Example (for a TurtleScreen instance named screen):
01473         >>> screen.bgpic()
01474         'nopic'
01475         >>> screen.bgpic("landscape.gif")
01476         >>> screen.bgpic()
01477         'landscape.gif'
01478         """
01479         if picname is None:
01480             return self._bgpicname
01481         if picname not in self._bgpics:
01482             self._bgpics[picname] = self._image(picname)
01483         self._setbgpic(self._bgpic, self._bgpics[picname])
01484         self._bgpicname = picname

Here is the call graph for this function:

def turtle._Screen.bye (   self)
Shut the turtlegraphics window.

Example (for a TurtleScreen instance named screen):
>>> screen.bye()

Definition at line 3759 of file turtle.py.

03759 
03760     def bye(self):
03761         """Shut the turtlegraphics window.
03762 
03763         Example (for a TurtleScreen instance named screen):
03764         >>> screen.bye()
03765         """
03766         self._destroy()

Here is the call graph for this function:

Here is the caller graph for this function:

def turtle.TurtleScreen.clear (   self) [inherited]
Delete all drawings and all turtles from the TurtleScreen.

No argument.

Reset empty TurtleScreen to its initial state: white background,
no backgroundimage, no eventbindings and tracing on.

Example (for a TurtleScreen instance named screen):
screen.clear()

Note: this method is not available as function.

Definition at line 997 of file turtle.py.

00997 
00998     def clear(self):
00999         """Delete all drawings and all turtles from the TurtleScreen.
01000 
01001         No argument.
01002 
01003         Reset empty TurtleScreen to its initial state: white background,
01004         no backgroundimage, no eventbindings and tracing on.
01005 
01006         Example (for a TurtleScreen instance named screen):
01007         screen.clear()
01008 
01009         Note: this method is not available as function.
01010         """
01011         self._delayvalue = _CFG["delay"]
01012         self._colormode = _CFG["colormode"]
01013         self._delete("all")
01014         self._bgpic = self._createimage("")
01015         self._bgpicname = "nopic"
01016         self._tracing = 1
01017         self._updatecounter = 0
01018         self._turtles = []
01019         self.bgcolor("white")
01020         for btn in 1, 2, 3:
01021             self.onclick(None, btn)
01022         self.onkeypress(None)
01023         for key in self._keys[:]:
01024             self.onkey(None, key)
01025             self.onkeypress(None, key)
01026         Turtle._pen = None

Here is the call graph for this function:

def turtle.TurtleScreen.colormode (   self,
  cmode = None 
) [inherited]
Return the colormode or set it to 1.0 or 255.

Optional argument:
cmode -- one of the values 1.0 or 255

r, g, b values of colortriples have to be in range 0..cmode.

Example (for a TurtleScreen instance named screen):
>>> screen.colormode()
1.0
>>> screen.colormode(255)
>>> turtle.pencolor(240,160,80)

Definition at line 1173 of file turtle.py.

01173 
01174     def colormode(self, cmode=None):
01175         """Return the colormode or set it to 1.0 or 255.
01176 
01177         Optional argument:
01178         cmode -- one of the values 1.0 or 255
01179 
01180         r, g, b values of colortriples have to be in range 0..cmode.
01181 
01182         Example (for a TurtleScreen instance named screen):
01183         >>> screen.colormode()
01184         1.0
01185         >>> screen.colormode(255)
01186         >>> turtle.pencolor(240,160,80)
01187         """
01188         if cmode is None:
01189             return self._colormode
01190         if cmode == 1.0:
01191             self._colormode = float(cmode)
01192         elif cmode == 255:
01193             self._colormode = int(cmode)

def turtle.TurtleScreen.delay (   self,
  delay = None 
) [inherited]
Return or set the drawing delay in milliseconds.

Optional argument:
delay -- positive integer

Example (for a TurtleScreen instance named screen):
>>> screen.delay(15)
>>> screen.delay()
15

Definition at line 1266 of file turtle.py.

01266 
01267     def delay(self, delay=None):
01268         """ Return or set the drawing delay in milliseconds.
01269 
01270         Optional argument:
01271         delay -- positive integer
01272 
01273         Example (for a TurtleScreen instance named screen):
01274         >>> screen.delay(15)
01275         >>> screen.delay()
01276         15
01277         """
01278         if delay is None:
01279             return self._delayvalue
01280         self._delayvalue = int(delay)

Go into mainloop until the mouse is clicked.

No arguments.

Bind bye() method to mouseclick on TurtleScreen.
If "using_IDLE" - value in configuration dictionary is False
(default value), enter mainloop.
If IDLE with -n switch (no subprocess) is used, this value should be
set to True in turtle.cfg. In this case IDLE's mainloop
is active also for the client script.

This is a method of the Screen-class and not available for
TurtleScreen instances.

Example (for a Screen instance named screen):
>>> screen.exitonclick()

Definition at line 3767 of file turtle.py.

03767 
03768     def exitonclick(self):
03769         """Go into mainloop until the mouse is clicked.
03770 
03771         No arguments.
03772 
03773         Bind bye() method to mouseclick on TurtleScreen.
03774         If "using_IDLE" - value in configuration dictionary is False
03775         (default value), enter mainloop.
03776         If IDLE with -n switch (no subprocess) is used, this value should be
03777         set to True in turtle.cfg. In this case IDLE's mainloop
03778         is active also for the client script.
03779 
03780         This is a method of the Screen-class and not available for
03781         TurtleScreen instances.
03782 
03783         Example (for a Screen instance named screen):
03784         >>> screen.exitonclick()
03785 
03786         """
03787         def exitGracefully(x, y):
03788             """Screen.bye() with two dummy-parameters"""
03789             self.bye()
03790         self.onclick(exitGracefully)
03791         if _CFG["using_IDLE"]:
03792             return
03793         try:
03794             mainloop()
03795         except AttributeError:
03796             exit(0)
03797 

Here is the call graph for this function:

def turtle.TurtleScreen.getcanvas (   self) [inherited]
Return the Canvas of this TurtleScreen.

No argument.

Example (for a Screen instance named screen):
>>> cv = screen.getcanvas()
>>> cv
<turtle.ScrolledCanvas instance at 0x010742D8>

Definition at line 1319 of file turtle.py.

01319 
01320     def getcanvas(self):
01321         """Return the Canvas of this TurtleScreen.
01322 
01323         No argument.
01324 
01325         Example (for a Screen instance named screen):
01326         >>> cv = screen.getcanvas()
01327         >>> cv
01328         <turtle.ScrolledCanvas instance at 0x010742D8>
01329         """
01330         return self.cv

def turtle.TurtleScreen.getshapes (   self) [inherited]
Return a list of names of all currently available turtle shapes.

No argument.

Example (for a TurtleScreen instance named screen):
>>> screen.getshapes()
['arrow', 'blank', 'circle', ... , 'turtle']

Definition at line 1331 of file turtle.py.

01331 
01332     def getshapes(self):
01333         """Return a list of names of all currently available turtle shapes.
01334 
01335         No argument.
01336 
01337         Example (for a TurtleScreen instance named screen):
01338         >>> screen.getshapes()
01339         ['arrow', 'blank', 'circle', ... , 'turtle']
01340         """
01341         return sorted(self._shapes.keys())

Here is the call graph for this function:

def turtle.TurtleScreen.listen (   self,
  xdummy = None,
  ydummy = None 
) [inherited]
Set focus on TurtleScreen (in order to collect key-events)

No arguments.
Dummy arguments are provided in order
to be able to pass listen to the onclick method.

Example (for a TurtleScreen instance named screen):
>>> screen.listen()

Definition at line 1428 of file turtle.py.

01428 
01429     def listen(self, xdummy=None, ydummy=None):
01430         """Set focus on TurtleScreen (in order to collect key-events)
01431 
01432         No arguments.
01433         Dummy arguments are provided in order
01434         to be able to pass listen to the onclick method.
01435 
01436         Example (for a TurtleScreen instance named screen):
01437         >>> screen.listen()
01438         """
01439         self._listen()

Here is the caller graph for this function:

def turtle.TurtleScreen.mode (   self,
  mode = None 
) [inherited]
Set turtle-mode ('standard', 'logo' or 'world') and perform reset.

Optional argument:
mode -- on of the strings 'standard', 'logo' or 'world'

Mode 'standard' is compatible with turtle.py.
Mode 'logo' is compatible with most Logo-Turtle-Graphics.
Mode 'world' uses userdefined 'worldcoordinates'. *Attention*: in
this mode angles appear distorted if x/y unit-ratio doesn't equal 1.
If mode is not given, return the current mode.

     Mode      Initial turtle heading     positive angles
 ------------|-------------------------|-------------------
  'standard'    to the right (east)       counterclockwise
    'logo'        upward    (north)         clockwise

Examples:
>>> mode('logo')   # resets turtle heading to north
>>> mode()
'logo'

Definition at line 1027 of file turtle.py.

01027 
01028     def mode(self, mode=None):
01029         """Set turtle-mode ('standard', 'logo' or 'world') and perform reset.
01030 
01031         Optional argument:
01032         mode -- on of the strings 'standard', 'logo' or 'world'
01033 
01034         Mode 'standard' is compatible with turtle.py.
01035         Mode 'logo' is compatible with most Logo-Turtle-Graphics.
01036         Mode 'world' uses userdefined 'worldcoordinates'. *Attention*: in
01037         this mode angles appear distorted if x/y unit-ratio doesn't equal 1.
01038         If mode is not given, return the current mode.
01039 
01040              Mode      Initial turtle heading     positive angles
01041          ------------|-------------------------|-------------------
01042           'standard'    to the right (east)       counterclockwise
01043             'logo'        upward    (north)         clockwise
01044 
01045         Examples:
01046         >>> mode('logo')   # resets turtle heading to north
01047         >>> mode()
01048         'logo'
01049         """
01050         if mode is None:
01051             return self._mode
01052         mode = mode.lower()
01053         if mode not in ["standard", "logo", "world"]:
01054             raise TurtleGraphicsError("No turtle-graphics-mode %s" % mode)
01055         self._mode = mode
01056         if mode in ["standard", "logo"]:
01057             self._setscrollregion(-self.canvwidth//2, -self.canvheight//2,
01058                                        self.canvwidth//2, self.canvheight//2)
01059             self.xscale = self.yscale = 1.0
01060         self.reset()

Here is the caller graph for this function:

def turtle.TurtleScreen.onclick (   self,
  fun,
  btn = 1,
  add = None 
) [inherited]
Bind fun to mouse-click event on canvas.

Arguments:
fun -- a function with two arguments, the coordinates of the
       clicked point on the canvas.
num -- the number of the mouse-button, defaults to 1

Example (for a TurtleScreen instance named screen
and a Turtle instance named turtle):

>>> screen.onclick(turtle.goto)

### Subsequently clicking into the TurtleScreen will
### make the turtle move to the clicked point.
>>> screen.onclick(None)

### event-binding will be removed

Definition at line 1342 of file turtle.py.

01342 
01343     def onclick(self, fun, btn=1, add=None):
01344         """Bind fun to mouse-click event on canvas.
01345 
01346         Arguments:
01347         fun -- a function with two arguments, the coordinates of the
01348                clicked point on the canvas.
01349         num -- the number of the mouse-button, defaults to 1
01350 
01351         Example (for a TurtleScreen instance named screen
01352         and a Turtle instance named turtle):
01353 
01354         >>> screen.onclick(turtle.goto)
01355 
01356         ### Subsequently clicking into the TurtleScreen will
01357         ### make the turtle move to the clicked point.
01358         >>> screen.onclick(None)
01359 
01360         ### event-binding will be removed
01361         """
01362         self._onscreenclick(fun, btn, add)

Here is the caller graph for this function:

def turtle.TurtleScreen.onkey (   self,
  fun,
  key 
) [inherited]
Bind fun to key-release event of key.

Arguments:
fun -- a function with no arguments
key -- a string: key (e.g. "a") or key-symbol (e.g. "space")

In order to be able to register key-events, TurtleScreen
must have focus. (See method listen.)

Example (for a TurtleScreen instance named screen
and a Turtle instance named turtle):

>>> def f():
fd(50)
lt(60)


>>> screen.onkey(f, "Up")
>>> screen.listen()

### Subsequently the turtle can be moved by
### repeatedly pressing the up-arrow key,
### consequently drawing a hexagon

Definition at line 1363 of file turtle.py.

01363 
01364     def onkey(self, fun, key):
01365         """Bind fun to key-release event of key.
01366 
01367         Arguments:
01368         fun -- a function with no arguments
01369         key -- a string: key (e.g. "a") or key-symbol (e.g. "space")
01370 
01371         In order to be able to register key-events, TurtleScreen
01372         must have focus. (See method listen.)
01373 
01374         Example (for a TurtleScreen instance named screen
01375         and a Turtle instance named turtle):
01376 
01377         >>> def f():
01378                 fd(50)
01379                 lt(60)
01380 
01381 
01382         >>> screen.onkey(f, "Up")
01383         >>> screen.listen()
01384 
01385         ### Subsequently the turtle can be moved by
01386         ### repeatedly pressing the up-arrow key,
01387         ### consequently drawing a hexagon
01388         """
01389         if fun is None:
01390             if key in self._keys:
01391                 self._keys.remove(key)
01392         elif key not in self._keys:
01393             self._keys.append(key)
01394         self._onkeyrelease(fun, key)

def turtle.TurtleScreen.onkeypress (   self,
  fun,
  key = None 
) [inherited]
Bind fun to key-press event of key if key is given,
or to any key-press-event if no key is given.

Arguments:
fun -- a function with no arguments
key -- a string: key (e.g. "a") or key-symbol (e.g. "space")

In order to be able to register key-events, TurtleScreen
must have focus. (See method listen.)

Example (for a TurtleScreen instance named screen
and a Turtle instance named turtle):

>>> def f():
fd(50)


>>> screen.onkey(f, "Up")
>>> screen.listen()

### Subsequently the turtle can be moved by
### repeatedly pressing the up-arrow key,
### or by keeping pressed the up-arrow key.
### consequently drawing a hexagon.

Definition at line 1395 of file turtle.py.

01395 
01396     def onkeypress(self, fun, key=None):
01397         """Bind fun to key-press event of key if key is given,
01398         or to any key-press-event if no key is given.
01399 
01400         Arguments:
01401         fun -- a function with no arguments
01402         key -- a string: key (e.g. "a") or key-symbol (e.g. "space")
01403 
01404         In order to be able to register key-events, TurtleScreen
01405         must have focus. (See method listen.)
01406 
01407         Example (for a TurtleScreen instance named screen
01408         and a Turtle instance named turtle):
01409 
01410         >>> def f():
01411                 fd(50)
01412 
01413 
01414         >>> screen.onkey(f, "Up")
01415         >>> screen.listen()
01416 
01417         ### Subsequently the turtle can be moved by
01418         ### repeatedly pressing the up-arrow key,
01419         ### or by keeping pressed the up-arrow key.
01420         ### consequently drawing a hexagon.
01421         """
01422         if fun is None:
01423             if key in self._keys:
01424                 self._keys.remove(key)
01425         elif key is not None and key not in self._keys:
01426             self._keys.append(key)
01427         self._onkeypress(fun, key)

def turtle.TurtleScreen.ontimer (   self,
  fun,
  t = 0 
) [inherited]
Install a timer, which calls fun after t milliseconds.

Arguments:
fun -- a function with no arguments.
t -- a number >= 0

Example (for a TurtleScreen instance named screen):

>>> running = True
>>> def f():
if running:
        fd(50)
        lt(60)
        screen.ontimer(f, 250)

>>> f()   ### makes the turtle marching around
>>> running = False

Definition at line 1440 of file turtle.py.

01440 
01441     def ontimer(self, fun, t=0):
01442         """Install a timer, which calls fun after t milliseconds.
01443 
01444         Arguments:
01445         fun -- a function with no arguments.
01446         t -- a number >= 0
01447 
01448         Example (for a TurtleScreen instance named screen):
01449 
01450         >>> running = True
01451         >>> def f():
01452                 if running:
01453                         fd(50)
01454                         lt(60)
01455                         screen.ontimer(f, 250)
01456 
01457         >>> f()   ### makes the turtle marching around
01458         >>> running = False
01459         """
01460         self._ontimer(fun, t)

def turtle.TurtleScreen.register_shape (   self,
  name,
  shape = None 
) [inherited]
Adds a turtle shape to TurtleScreen's shapelist.

Arguments:
(1) name is the name of a gif-file and shape is None.
    Installs the corresponding image shape.
    !! Image-shapes DO NOT rotate when turning the turtle,
    !! so they do not display the heading of the turtle!
(2) name is an arbitrary string and shape is a tuple
    of pairs of coordinates. Installs the corresponding
    polygon shape
(3) name is an arbitrary string and shape is a
    (compound) Shape object. Installs the corresponding
    compound shape.
To use a shape, you have to issue the command shape(shapename).

call: register_shape("turtle.gif")
--or: register_shape("tri", ((0,0), (10,10), (-10,10)))

Example (for a TurtleScreen instance named screen):
>>> screen.register_shape("triangle", ((5,-3),(0,5),(-5,-3)))

Definition at line 1100 of file turtle.py.

01100 
01101     def register_shape(self, name, shape=None):
01102         """Adds a turtle shape to TurtleScreen's shapelist.
01103 
01104         Arguments:
01105         (1) name is the name of a gif-file and shape is None.
01106             Installs the corresponding image shape.
01107             !! Image-shapes DO NOT rotate when turning the turtle,
01108             !! so they do not display the heading of the turtle!
01109         (2) name is an arbitrary string and shape is a tuple
01110             of pairs of coordinates. Installs the corresponding
01111             polygon shape
01112         (3) name is an arbitrary string and shape is a
01113             (compound) Shape object. Installs the corresponding
01114             compound shape.
01115         To use a shape, you have to issue the command shape(shapename).
01116 
01117         call: register_shape("turtle.gif")
01118         --or: register_shape("tri", ((0,0), (10,10), (-10,10)))
01119 
01120         Example (for a TurtleScreen instance named screen):
01121         >>> screen.register_shape("triangle", ((5,-3),(0,5),(-5,-3)))
01122 
01123         """
01124         if shape is None:
01125             # image
01126             if name.lower().endswith(".gif"):
01127                 shape = Shape("image", self._image(name))
01128             else:
01129                 raise TurtleGraphicsError("Bad arguments for register_shape.\n"
01130                                           + "Use  help(register_shape)" )
01131         elif isinstance(shape, tuple):
01132             shape = Shape("polygon", shape)
01133         ## else shape assumed to be Shape-instance
01134         self._shapes[name] = shape

Here is the call graph for this function:

def turtle.TurtleScreen.reset (   self) [inherited]
Reset all Turtles on the Screen to their initial state.

No argument.

Example (for a TurtleScreen instance named screen):
>>> screen.reset()

Definition at line 1194 of file turtle.py.

01194 
01195     def reset(self):
01196         """Reset all Turtles on the Screen to their initial state.
01197 
01198         No argument.
01199 
01200         Example (for a TurtleScreen instance named screen):
01201         >>> screen.reset()
01202         """
01203         for turtle in self._turtles:
01204             turtle._setmode(self._mode)
01205             turtle.reset()

Here is the caller graph for this function:

def turtle.TurtleScreen.screensize (   self,
  canvwidth = None,
  canvheight = None,
  bg = None 
) [inherited]
Resize the canvas the turtles are drawing on.

Optional arguments:
canvwidth -- positive integer, new width of canvas in pixels
canvheight --  positive integer, new height of canvas in pixels
bg -- colorstring or color-tuple, new backgroundcolor
If no arguments are given, return current (canvaswidth, canvasheight)

Do not alter the drawing window. To observe hidden parts of
the canvas use the scrollbars. (Can make visible those parts
of a drawing, which were outside the canvas before!)

Example (for a Turtle instance named turtle):
>>> turtle.screensize(2000,1500)
    ### e. g. to search for an erroneously escaped turtle ;-)

Definition at line 1485 of file turtle.py.

01485 
01486     def screensize(self, canvwidth=None, canvheight=None, bg=None):
01487         """Resize the canvas the turtles are drawing on.
01488 
01489         Optional arguments:
01490         canvwidth -- positive integer, new width of canvas in pixels
01491         canvheight --  positive integer, new height of canvas in pixels
01492         bg -- colorstring or color-tuple, new backgroundcolor
01493         If no arguments are given, return current (canvaswidth, canvasheight)
01494 
01495         Do not alter the drawing window. To observe hidden parts of
01496         the canvas use the scrollbars. (Can make visible those parts
01497         of a drawing, which were outside the canvas before!)
01498 
01499         Example (for a Turtle instance named turtle):
01500         >>> turtle.screensize(2000,1500)
01501             ### e. g. to search for an erroneously escaped turtle ;-)
01502         """
01503         return self._resize(canvwidth, canvheight, bg)

Here is the caller graph for this function:

def turtle._Screen.setup (   self,
  width = _CFG["width"],
  height = _CFG["height"],
  startx = _CFG["leftright"],
  starty = _CFG["topbottom"] 
)
Set the size and position of the main window.

Arguments:
width: as integer a size in pixels, as float a fraction of the screen.
  Default is 50% of screen.
height: as integer the height in pixels, as float a fraction of the
  screen. Default is 75% of screen.
startx: if positive, starting position in pixels from the left
  edge of the screen, if negative from the right edge
  Default, startx=None is to center window horizontally.
starty: if positive, starting position in pixels from the top
  edge of the screen, if negative from the bottom edge
  Default, starty=None is to center window vertically.

Examples (for a Screen instance named screen):
>>> screen.setup (width=200, height=200, startx=0, starty=0)

sets window to 200x200 pixels, in upper left of screen

>>> screen.setup(width=.75, height=0.5, startx=None, starty=None)

sets window to 75% of screen by 50% of screen and centers

Definition at line 3693 of file turtle.py.

03693 
03694               startx=_CFG["leftright"], starty=_CFG["topbottom"]):
03695         """ Set the size and position of the main window.
03696 
03697         Arguments:
03698         width: as integer a size in pixels, as float a fraction of the screen.
03699           Default is 50% of screen.
03700         height: as integer the height in pixels, as float a fraction of the
03701           screen. Default is 75% of screen.
03702         startx: if positive, starting position in pixels from the left
03703           edge of the screen, if negative from the right edge
03704           Default, startx=None is to center window horizontally.
03705         starty: if positive, starting position in pixels from the top
03706           edge of the screen, if negative from the bottom edge
03707           Default, starty=None is to center window vertically.
03708 
03709         Examples (for a Screen instance named screen):
03710         >>> screen.setup (width=200, height=200, startx=0, starty=0)
03711 
03712         sets window to 200x200 pixels, in upper left of screen
03713 
03714         >>> screen.setup(width=.75, height=0.5, startx=None, starty=None)
03715 
03716         sets window to 75% of screen by 50% of screen and centers
03717         """
03718         if not hasattr(self._root, "set_geometry"):
03719             return
03720         sw = self._root.win_width()
03721         sh = self._root.win_height()
03722         if isinstance(width, float) and 0 <= width <= 1:
03723             width = sw*width
03724         if startx is None:
03725             startx = (sw - width) / 2
03726         if isinstance(height, float) and 0 <= height <= 1:
03727             height = sh*height
03728         if starty is None:
03729             starty = (sh - height) / 2
03730         self._root.set_geometry(width, height, startx, starty)
03731         self.update()

Here is the call graph for this function:

Here is the caller graph for this function:

def turtle.TurtleScreen.setworldcoordinates (   self,
  llx,
  lly,
  urx,
  ury 
) [inherited]
Set up a user defined coordinate-system.

Arguments:
llx -- a number, x-coordinate of lower left corner of canvas
lly -- a number, y-coordinate of lower left corner of canvas
urx -- a number, x-coordinate of upper right corner of canvas
ury -- a number, y-coordinate of upper right corner of canvas

Set up user coodinat-system and switch to mode 'world' if necessary.
This performs a screen.reset. If mode 'world' is already active,
all drawings are redrawn according to the new coordinates.

But ATTENTION: in user-defined coordinatesystems angles may appear
distorted. (see Screen.mode())

Example (for a TurtleScreen instance named screen):
>>> screen.setworldcoordinates(-10,-0.5,50,1.5)
>>> for _ in range(36):
left(10)
forward(0.5)

Definition at line 1061 of file turtle.py.

01061 
01062     def setworldcoordinates(self, llx, lly, urx, ury):
01063         """Set up a user defined coordinate-system.
01064 
01065         Arguments:
01066         llx -- a number, x-coordinate of lower left corner of canvas
01067         lly -- a number, y-coordinate of lower left corner of canvas
01068         urx -- a number, x-coordinate of upper right corner of canvas
01069         ury -- a number, y-coordinate of upper right corner of canvas
01070 
01071         Set up user coodinat-system and switch to mode 'world' if necessary.
01072         This performs a screen.reset. If mode 'world' is already active,
01073         all drawings are redrawn according to the new coordinates.
01074 
01075         But ATTENTION: in user-defined coordinatesystems angles may appear
01076         distorted. (see Screen.mode())
01077 
01078         Example (for a TurtleScreen instance named screen):
01079         >>> screen.setworldcoordinates(-10,-0.5,50,1.5)
01080         >>> for _ in range(36):
01081                 left(10)
01082                 forward(0.5)
01083         """
01084         if self.mode() != "world":
01085             self.mode("world")
01086         xspan = float(urx - llx)
01087         yspan = float(ury - lly)
01088         wx, wy = self._window_size()
01089         self.screensize(wx-20, wy-20)
01090         oldxscale, oldyscale = self.xscale, self.yscale
01091         self.xscale = self.canvwidth / xspan
01092         self.yscale = self.canvheight / yspan
01093         srx1 = llx * self.xscale
01094         sry1 = -ury * self.yscale
01095         srx2 = self.canvwidth + srx1
01096         sry2 = self.canvheight + sry1
01097         self._setscrollregion(srx1, sry1, srx2, sry2)
01098         self._rescale(self.xscale/oldxscale, self.yscale/oldyscale)
01099         self.update()

Here is the call graph for this function:

def turtle._Screen.title (   self,
  titlestring 
)
Set title of turtle-window

Argument:
titlestring -- a string, to appear in the titlebar of the
       turtle graphics window.

This is a method of Screen-class. Not available for TurtleScreen-
objects.

Example (for a Screen instance named screen):
>>> screen.title("Welcome to the turtle-zoo!")

Definition at line 3732 of file turtle.py.

03732 
03733     def title(self, titlestring):
03734         """Set title of turtle-window
03735 
03736         Argument:
03737         titlestring -- a string, to appear in the titlebar of the
03738                        turtle graphics window.
03739 
03740         This is a method of Screen-class. Not available for TurtleScreen-
03741         objects.
03742 
03743         Example (for a Screen instance named screen):
03744         >>> screen.title("Welcome to the turtle-zoo!")
03745         """
03746         if _Screen._root is not None:
03747             _Screen._root.title(titlestring)
03748         _Screen._title = titlestring

def turtle.TurtleScreen.tracer (   self,
  n = None,
  delay = None 
) [inherited]
Turns turtle animation on/off and set delay for update drawings.

Optional arguments:
n -- nonnegative  integer
delay -- nonnegative  integer

If n is given, only each n-th regular screen update is really performed.
(Can be used to accelerate the drawing of complex graphics.)
Second arguments sets delay value (see RawTurtle.delay())

Example (for a TurtleScreen instance named screen):
>>> screen.tracer(8, 25)
>>> dist = 2
>>> for i in range(200):
fd(dist)
rt(90)
dist += 2

Definition at line 1238 of file turtle.py.

01238 
01239     def tracer(self, n=None, delay=None):
01240         """Turns turtle animation on/off and set delay for update drawings.
01241 
01242         Optional arguments:
01243         n -- nonnegative  integer
01244         delay -- nonnegative  integer
01245 
01246         If n is given, only each n-th regular screen update is really performed.
01247         (Can be used to accelerate the drawing of complex graphics.)
01248         Second arguments sets delay value (see RawTurtle.delay())
01249 
01250         Example (for a TurtleScreen instance named screen):
01251         >>> screen.tracer(8, 25)
01252         >>> dist = 2
01253         >>> for i in range(200):
01254                 fd(dist)
01255                 rt(90)
01256                 dist += 2
01257         """
01258         if n is None:
01259             return self._tracing
01260         self._tracing = int(n)
01261         self._updatecounter = 0
01262         if delay is not None:
01263             self._delayvalue = int(delay)
01264         if self._tracing:
01265             self.update()

Here is the call graph for this function:

def turtle.TurtleScreen.turtles (   self) [inherited]
Return the list of turtles on the screen.

Example (for a TurtleScreen instance named screen):
>>> screen.turtles()
[<turtle.Turtle object at 0x00E11FB0>]

Definition at line 1206 of file turtle.py.

01206 
01207     def turtles(self):
01208         """Return the list of turtles on the screen.
01209 
01210         Example (for a TurtleScreen instance named screen):
01211         >>> screen.turtles()
01212         [<turtle.Turtle object at 0x00E11FB0>]
01213         """
01214         return self._turtles

Here is the caller graph for this function:

def turtle.TurtleScreen.update (   self) [inherited]
Perform a TurtleScreen update.

Definition at line 1290 of file turtle.py.

01290 
01291     def update(self):
01292         """Perform a TurtleScreen update.
01293         """
01294         tracing = self._tracing
01295         self._tracing = True
01296         for t in self.turtles():
01297             t._update_data()
01298             t._drawturtle()
01299         self._tracing = tracing
01300         self._update()

Here is the call graph for this function:

Here is the caller graph for this function:

def turtle.TurtleScreen.window_height (   self) [inherited]
Return the height of the turtle window.

Example (for a TurtleScreen instance named screen):
>>> screen.window_height()
480

Definition at line 1310 of file turtle.py.

01310 
01311     def window_height(self):
01312         """ Return the height of the turtle window.
01313 
01314         Example (for a TurtleScreen instance named screen):
01315         >>> screen.window_height()
01316         480
01317         """
01318         return self._window_size()[1]

def turtle.TurtleScreen.window_width (   self) [inherited]
Return the width of the turtle window.

Example (for a TurtleScreen instance named screen):
>>> screen.window_width()
640

Definition at line 1301 of file turtle.py.

01301 
01302     def window_width(self):
01303         """ Return the width of the turtle window.
01304 
01305         Example (for a TurtleScreen instance named screen):
01306         >>> screen.window_width()
01307         640
01308         """
01309         return self._window_size()[0]


Member Data Documentation

turtle._Screen._canvas = None [static, private]

Definition at line 3667 of file turtle.py.

turtle._Screen._root = None [static, private]

Definition at line 3666 of file turtle.py.

list turtle._Screen._title = _CFG["title"] [static, private]

Definition at line 3668 of file turtle.py.

Definition at line 1507 of file turtle.py.

Definition at line 491 of file turtle.py.

Definition at line 490 of file turtle.py.

turtle.TurtleScreen.clearscreen = clear [static, inherited]

Definition at line 1506 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.

turtle.TurtleScreen.onkeyrelease = onkey [static, inherited]

Definition at line 1508 of file turtle.py.

Definition at line 1504 of file turtle.py.

turtle.TurtleScreen.resetscreen = reset [static, inherited]

Definition at line 1505 of file turtle.py.

Reimplemented from turtle.TurtleScreenBase.

Definition at line 1058 of file turtle.py.

Reimplemented from turtle.TurtleScreenBase.

Definition at line 1058 of file turtle.py.


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