MCPcopy Create free account
hub / github.com/codemistic/Data-Structures-and-Algorithms / setup

Method setup

Python/Turtle.py:3592–3630  ·  view source on GitHub ↗

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

(self, width=_CFG["width"], height=_CFG["height"],
              startx=_CFG["leftright"], starty=_CFG["topbottom"])

Source from the content-addressed store, hash-verified

3590 self.setup(width, height, leftright, topbottom)
3591
3592 def setup(self, width=_CFG["width"], height=_CFG["height"],
3593 startx=_CFG["leftright"], starty=_CFG["topbottom"]):
3594 """ Set the size and position of the main window.
3595
3596 Arguments:
3597 width: as integer a size in pixels, as float a fraction of the screen.
3598 Default is 50% of screen.
3599 height: as integer the height in pixels, as float a fraction of the
3600 screen. Default is 75% of screen.
3601 startx: if positive, starting position in pixels from the left
3602 edge of the screen, if negative from the right edge
3603 Default, startx=None is to center window horizontally.
3604 starty: if positive, starting position in pixels from the top
3605 edge of the screen, if negative from the bottom edge
3606 Default, starty=None is to center window vertically.
3607
3608 Examples (for a Screen instance named screen):
3609 >>> screen.setup (width=200, height=200, startx=0, starty=0)
3610
3611 sets window to 200x200 pixels, in upper left of screen
3612
3613 >>> screen.setup(width=.75, height=0.5, startx=None, starty=None)
3614
3615 sets window to 75% of screen by 50% of screen and centers
3616 """
3617 if not hasattr(self._root, "set_geometry"):
3618 return
3619 sw = self._root.win_width()
3620 sh = self._root.win_height()
3621 if isinstance(width, float) and 0 <= width <= 1:
3622 width = sw*width
3623 if startx is None:
3624 startx = (sw - width) / 2
3625 if isinstance(height, float) and 0 <= height <= 1:
3626 height = sh*height
3627 if starty is None:
3628 starty = (sh - height) / 2
3629 self._root.set_geometry(width, height, startx, starty)
3630 self.update()
3631
3632 def title(self, titlestring):
3633 """Set title of turtle-window

Callers 2

__init__Method · 0.95
pong.pyFile · 0.80

Calls 4

win_widthMethod · 0.80
win_heightMethod · 0.80
set_geometryMethod · 0.80
updateMethod · 0.45

Tested by

no test coverage detected