Mar-03-2017, 08:18 AM
I'm coding a program that captures a section of the screen as an image by drawing a rectangle with cursor, yet the process creates glitched rectangles. Is there a way to refresh the screen or maybe a completely different code that works? The dc.Clear() doesn't seem to clear the screen.
import wx import win32gui app = wx.PySimpleApp() dc = wx.ScreenDC() dc.StartDrawingOnTop(None) dc.SetPen(wx.Pen('red', 2)) dc.SetBrush(wx.TRANSPARENT_BRUSH) int_x = win32gui.GetCursorPos()[0] int_y = win32gui.GetCursorPos()[1] while 1: dc.DrawRectangle(int_x,int_y,win32gui.GetCursorPos()[0]-int_x,win32gui.GetCursorPos()[1]-int_y) dc.Clear()