def __exit__(self, *_args): assert self.context log("EndPaint") EndPaint(self.hwnd, byref(self.ps)) wglMakeCurrent(0, 0) self.paint_hdc = None self.ps = None
def __enter__(self): log("wglMakeCurrent(%#x, %#x)", self.hdc, self.context) r = wglMakeCurrent(self.hdc, self.context) if not r: raise Exception("wglMakeCurrent failed") self.ps = PAINTSTRUCT() self.paint_hdc = BeginPaint(self.hwnd, byref(self.ps)) assert self.paint_hdc, "BeginPaint: no display device context" log("BeginPaint hdc=%#x", self.paint_hdc) return self