def set_size(self, width, height):
if self._fullscreen:
raise WindowException('Cannot set size of fullscreen window.')
self._width = max(1, int(width))
self._height = max(1, int(height))
# Move frame origin down so that top-left corner of window doesn't move.
window_frame = self._nswindow.frame()
rect = self._nswindow.contentRectForFrameRect_(window_frame)
rect.origin.y += rect.size.height - self._height
rect.size.width = self._width
rect.size.height = self._height
new_frame = self._nswindow.frameRectForContentRect_(rect)
# The window background flashes when the frame size changes unless it's
# animated, but we can set the window's animationResizeTime to zero.
is_visible = self._nswindow.isVisible()
self._nswindow.setFrame_display_animate_(new_frame, True, is_visible)
评论列表
文章目录