MCPcopy Create free account
hub / github.com/RT-Thread/env-windows / setup

Method setup

tools/python-3.11.9-amd64/Lib/turtle.py:3711–3749  ·  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

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

Source from the content-addressed store, hash-verified

3709 self.setup(width, height, leftright, topbottom)
3710
3711 def setup(self, width=_CFG["width"], height=_CFG["height"],
3712 startx=_CFG["leftright"], starty=_CFG["topbottom"]):
3713 """ Set the size and position of the main window.
3714
3715 Arguments:
3716 width: as integer a size in pixels, as float a fraction of the screen.
3717 Default is 50% of screen.
3718 height: as integer the height in pixels, as float a fraction of the
3719 screen. Default is 75% of screen.
3720 startx: if positive, starting position in pixels from the left
3721 edge of the screen, if negative from the right edge
3722 Default, startx=None is to center window horizontally.
3723 starty: if positive, starting position in pixels from the top
3724 edge of the screen, if negative from the bottom edge
3725 Default, starty=None is to center window vertically.
3726
3727 Examples (for a Screen instance named screen):
3728 >>> screen.setup (width=200, height=200, startx=0, starty=0)
3729
3730 sets window to 200x200 pixels, in upper left of screen
3731
3732 >>> screen.setup(width=.75, height=0.5, startx=None, starty=None)
3733
3734 sets window to 75% of screen by 50% of screen and centers
3735 """
3736 if not hasattr(self._root, "set_geometry"):
3737 return
3738 sw = self._root.win_width()
3739 sh = self._root.win_height()
3740 if isinstance(width, float) and 0 <= width <= 1:
3741 width = sw*width
3742 if startx is None:
3743 startx = (sw - width) / 2
3744 if isinstance(height, float) and 0 <= height <= 1:
3745 height = sh*height
3746 if starty is None:
3747 starty = (sh - height) / 2
3748 self._root.set_geometry(width, height, startx, starty)
3749 self.update()
3750
3751 def title(self, titlestring):
3752 """Set title of turtle-window

Callers 1

__init__Method · 0.95

Calls 4

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

Tested by

no test coverage detected