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

Class _Screen

tools/python-3.11.9-amd64/Lib/turtle.py:3683–3814  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3681 return Turtle._screen
3682
3683class _Screen(TurtleScreen):
3684
3685 _root = None
3686 _canvas = None
3687 _title = _CFG["title"]
3688
3689 def __init__(self):
3690 # XXX there is no need for this code to be conditional,
3691 # as there will be only a single _Screen instance, anyway
3692 # XXX actually, the turtle demo is injecting root window,
3693 # so perhaps the conditional creation of a root should be
3694 # preserved (perhaps by passing it as an optional parameter)
3695 if _Screen._root is None:
3696 _Screen._root = self._root = _Root()
3697 self._root.title(_Screen._title)
3698 self._root.ondestroy(self._destroy)
3699 if _Screen._canvas is None:
3700 width = _CFG["width"]
3701 height = _CFG["height"]
3702 canvwidth = _CFG["canvwidth"]
3703 canvheight = _CFG["canvheight"]
3704 leftright = _CFG["leftright"]
3705 topbottom = _CFG["topbottom"]
3706 self._root.setupcanvas(width, height, canvwidth, canvheight)
3707 _Screen._canvas = self._root._getcanvas()
3708 TurtleScreen.__init__(self, _Screen._canvas)
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:

Callers 1

ScreenFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected