Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Python threads and queue

Name: Anonymous 2010-11-03 19:33

Hey /prog/ why is my program broke?
info on graphics.py
http://mcsp.wartburg.edu/zelle/python/graphics/graphics/index.html


from graphics import *
import queue
import random
import threading
import gc


WINDOW_SIZE = 500
NUMBER_OF_STARS = 100
iYModify = 0
iXModify = 0
iSpeed = []
oRespawnQ = queue.Queue()
oElminationQ = queue.Queue()
iX = 0
iY = 0
oStarSpeck = [Point(0, 0) for _ in range(NUMBER_OF_STARS)]
oSelectStar = Point(0,0)

def main():

    #Draw the window and paint it black
    formMain = GraphWin("stars", WINDOW_SIZE, WINDOW_SIZE)
    formMain.setBackground("black")
    #Draw crosshairs in the background
    threading.Thread(target=drawCrossHair(formMain)).start()
    #formMain.
    #Put the initial stars up on the screen
    for iStarIndex in range(NUMBER_OF_STARS):
        iSpeed.append(random.randint(1, 25))
        oStarSpeck[iStarIndex] = drawStar(oStarSpeck[iStarIndex], formMain)
       
    while (0 == 0):
        #Randomly select a star to work with
        iStarIndex = random.randint(0, NUMBER_OF_STARS - 1)
        oSelectStar = oStarSpeck[iStarIndex]
        iX = int(oSelectStar.getX())   
        iY = int(oSelectStar.getY())
        #Move selected star outwards according to it's speed variable
        if iX > (WINDOW_SIZE/2): iXModify = (iSpeed[iStarIndex])
        else: iXModify = -(iSpeed[iStarIndex])
        if iY > (WINDOW_SIZE/2): iYModify = (iSpeed[iStarIndex])
        else: iYModify = -(iSpeed[iStarIndex])
       
        oSelectStar.move(iXModify, iYModify)
       
        if (iX > WINDOW_SIZE) | (iY > WINDOW_SIZE) | (iY < 0) | (iX < 0) :
            ### A THREAD IS CREATED HERE
            ### A THREAD IS CREATED HERE
            ### A THREAD IS CREATED HERE
            tdDrawStar = threading.Thread(target = drawStar, arg = oElminationQ, oRespawnQ, formMain)
           
            #oStarSpeck[iStarIndex] = drawStar(oStarSpeck[iStarIndex], formMain)
            if (oRespawnQ.empty() != 1): oStarSpeck[iStarIndex] = oRespawnQ.get()
        gc.collect()
            
           

       
def drawStar(oIncomingQ, oOutgoingQ, oForm):       
    while (0==0):
        while (oIncomingQ.empty() != 1):
            oStarSpeck = Point(random.randint(1, WINDOW_SIZE), random.randint(1,WINDOW_SIZE))
   
            if (random.randint(1,2)    > 1): oStarSpeck.setFill("white")
            elif (random.randint(1,3)  > 1): oStarSpeck.setFill("gray")
            elif (random.randint(1,10) > 1): oStarSpeck.setFill("orange")
            elif (random.randint(1,3)  > 1): oStarSpeck.setFill("red")
            else:                            oStarSpeck.setFill("blue")
            oStarSpeck.draw(oForm)
            oOutgoingQ.put(oStarSpeck)
   
       
def drawCrossHair(oForm):
    oCallibrate = Point(WINDOW_SIZE/2, WINDOW_SIZE/2)
    oCallibrate.setFill("cyan")
    oCallibrate.draw(oForm)
   
    oCrossHair1 = Line(Point(WINDOW_SIZE/2 + 10, WINDOW_SIZE/2 +10 ), Point(WINDOW_SIZE/2 +10 , WINDOW_SIZE/2 - 10))
    oCrossHair1.setFill("red")
    oCrossHair2 = Line(Point(WINDOW_SIZE/2 - 10, WINDOW_SIZE/2 -10 ), Point(WINDOW_SIZE/2 -10 , WINDOW_SIZE/2 + 10))
    oCrossHair2.setFill("red")
    #oCrossHair2.setArrow("both")
   
    oCrossHair3 = Line(Point(WINDOW_SIZE/2  , WINDOW_SIZE/2 -1 ), Point(WINDOW_SIZE/2 -1 , WINDOW_SIZE/2 -1 ))
    oCrossHair3.setFill("red")
    oCrossHair3.setArrow("both")
    oCrossHair3.draw(oForm)
   
    oCrossHair3 = Line(Point(WINDOW_SIZE/2   , WINDOW_SIZE/2 +1 ), Point(WINDOW_SIZE/2 +1 , WINDOW_SIZE/2 +1 ))
    oCrossHair3.setFill("red")
    oCrossHair3.setArrow("both")
    oCrossHair3.draw(oForm)
   
    oCrossHair1.draw(oForm)
    oCrossHair2.draw(oForm)

def getRelPos(oForm):
    oForm.checkMouse()              
              
 #   formMain.getMouse()
   
main()

Name: Anonymous 2010-11-03 19:34

error returned is:

line 53
    tdDrawStar = threading.Thread(target = drawStar, arg = oElminationQ, oRespawnQ, formMain)
SyntaxError: non-keyword arg after keyword arg

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List