def set_position(self, pos, update=True): """Set the window position. :pos: list or tuple: the new position (x, y).""" if DEBUG_WM: print "Setting position to", pos if type(pos) in (list, tuple): self.first_pos = False x, y = pos if update: flags, showCmd, ptMin, ptMax, rect = win32gui.GetWindowPlacement( self.base_handler_id) if DEBUG_WM: print "set_position rect", rect, "ptMin", ptMin, "ptMax", ptMax realW = rect[2] - rect[0] realH = rect[3] - rect[1] if DEBUG_WM: print 'rect[0]', rect[0], 'rect[1]', rect[1] print 'realW', realW, 'realH', realH print 'cursor pos', win32gui.GetCursorPos() rect = (x, y, x + realW, y + realH) win32gui.SetWindowPlacement(self.base_handler_id, (0, showCmd, ptMin, ptMax, rect)) else: # Raise a Type error. raise TypeError, "%s is not a list or a tuple." % repr(pos)
def set_size(self, size, update=True): """Set the window size. :size: list or tuple: the new size. :mode: bool: (re)set the pygame.display mode; self.mode must be a pygame display mode object. Raises a TypeError if something else than a list or a tuple is sent.""" if type(size) in (list, tuple): w, h = size cx, cy = win32gui.GetCursorPos() if DEBUG_WM: print "Settin size to", size print "actual size", self.get_size() print "actual position", self.get_position() print 'cursor pos', cx, cy flags, showCmd, ptMin, ptMax, rect = win32gui.GetWindowPlacement( self.base_handler_id) if DEBUG_WM: print "set_size rect", rect, "ptMin", ptMin, "ptMax", ptMax, "flags", flags x = rect[0] y = rect[1] rect = (x, y, x + w, y + h) win32gui.SetWindowPlacement(self.base_handler_id, (0, showCmd, ptMin, ptMax, rect)) else: # Raise a Type error. raise TypeError, "%s is not a list or a tuple." % repr(size)