ich versuche auf die Funktion "pixel_color_in_area_counter" der Bibliothek macropolo (siehe http://ubuntuforums.org/showthread.php?t=2155281) zuzugreifen. Wenn ichs recht verstehe, benötigt diese als ersten Parameter ein Tupel mit vier Werten. Leider bekomme ich es nicht hin, der Funktion ein entsprechendes Tupel als Parameter zu übergeben – was mache ich falsch?
Funktion:
Code: Alles auswählen
def pixel_color_in_area_counter(rectangle, color):
"""
Searches the rectangle area 'rectangle' for the color 'color'.
It returns an integer indicating the times that the 'color'
was found inside the 'rectangle'.
The rectangle is a tuple [x, y, width, height], where x, y the
coordinates of the top left corner and width, height the width
and the height of the rectangle.
The color is a string with a hexadecimal representation of
a color (e.g. #000000)
"""
x = rectangle[0]
y = rectangle[1]
width = rectangle[2]
height = rectangle[3]
color = to_lower(color)
img = QPixmap.grabWindow(QApplication.desktop().winId()).toImage().copy(x, y, width+1, height+1);
counter=cur_y=cur_x=0
while( cur_y <= height ):
cur_x=0
while ( cur_x <= width ):
cur_color = QColor(img.pixel(QPoint(cur_x, cur_y)))
if(str(color)==str(cur_color.name())):
counter+=1
cur_x+=PIXELS_SEARCH_SPEED
cur_y+=1
return counter;Code: Alles auswählen
import macropolo.py
tup = (1,2,3,4)
print macropolo.pixel_color_in_area_counter(tup,#000000)