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"])
| 3838 | self.setup(width, height, leftright, topbottom) |
| 3839 | |
| 3840 | def setup(self, width=_CFG["width"], height=_CFG["height"], |
| 3841 | startx=_CFG["leftright"], starty=_CFG["topbottom"]): |
| 3842 | """ Set the size and position of the main window. |
| 3843 | |
| 3844 | Arguments: |
| 3845 | width: as integer a size in pixels, as float a fraction of the screen. |
| 3846 | Default is 50% of screen. |
| 3847 | height: as integer the height in pixels, as float a fraction of the |
| 3848 | screen. Default is 75% of screen. |
| 3849 | startx: if positive, starting position in pixels from the left |
| 3850 | edge of the screen, if negative from the right edge |
| 3851 | Default, startx=None is to center window horizontally. |
| 3852 | starty: if positive, starting position in pixels from the top |
| 3853 | edge of the screen, if negative from the bottom edge |
| 3854 | Default, starty=None is to center window vertically. |
| 3855 | |
| 3856 | Examples (for a Screen instance named screen): |
| 3857 | >>> screen.setup (width=200, height=200, startx=0, starty=0) |
| 3858 | |
| 3859 | sets window to 200x200 pixels, in upper left of screen |
| 3860 | |
| 3861 | >>> screen.setup(width=.75, height=0.5, startx=None, starty=None) |
| 3862 | |
| 3863 | sets window to 75% of screen by 50% of screen and centers |
| 3864 | """ |
| 3865 | if not hasattr(self._root, "set_geometry"): |
| 3866 | return |
| 3867 | sw = self._root.win_width() |
| 3868 | sh = self._root.win_height() |
| 3869 | if isinstance(width, float) and 0 <= width <= 1: |
| 3870 | width = sw*width |
| 3871 | if startx is None: |
| 3872 | startx = (sw - width) / 2 |
| 3873 | if isinstance(height, float) and 0 <= height <= 1: |
| 3874 | height = sh*height |
| 3875 | if starty is None: |
| 3876 | starty = (sh - height) / 2 |
| 3877 | self._root.set_geometry(width, height, startx, starty) |
| 3878 | self.update() |
| 3879 | |
| 3880 | def title(self, titlestring): |
| 3881 | """Set title of turtle-window |
no test coverage detected