当前位置:   article > 正文

python用 号画空心矩形_如何使用Python在屏幕上绘制空白矩形

python画空心矩形

I am not an expert and I am trying to show a rectangle on screen which follows mouse movements from a settle starting point, just as when you select something in word or paint. I came with this code:

import win32gui

m=win32gui.GetCursorPos()

while True:

n=win32gui.GetCursorPos()

for i in range(n[0]-m[0]):

win32gui.SetPixel(dc, m[0]+i, m[1], 0)

win32gui.SetPixel(dc, m[0]+i, n[1], 0)

for i in range(n[1]-m[1]):

win32gui.SetPixel(dc, m[0], m[1]+i, 0)

win32gui.SetPixel(dc, n[0], m[1]+i, 0)

As you can see, the code will draw the rectangle, but the previous ones will remain until the screen updates.

The only solution I've came with is to take the pixel values i will paint before set them black, and redraw them every time, but this makes my code pretty slow. Is there an easy way t

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/秋刀鱼在做梦/article/detail/742879
推荐阅读
相关标签
  

闽ICP备14008679号