d2jsp
Log InRegister
d2jsp Forums > Off-Topic > General Chat > Homework Help > Elementary Programming Question > Jython
Prev12
Add Reply New Topic New Poll
Member
Posts: 5,299
Joined: Jul 4 2009
Gold: 2,632.57
Oct 28 2013 10:19pm
Quote (Azrad @ Oct 28 2013 11:16pm)
Code
def main():
    # Create empty list, request media path, starting file, ending file, and file type.
    frameList=[]
    setMediaPath()
    startingPicture=requestInteger("Enter the number of the first picture to use.")
    endingPicture=requestInteger("Enter the number of the last picture to use.")
    suffix=requestString("Enter the file type suffix (png or jpg)")

    for x in range(startingPicture, endingPicture+1):
        frameList.append("frame" + str(x) + "." + suffix

    for frame in frameList:
        show(makePicture(getMediaPath(frameList[frame])))


Still getting same error in

Code
for frame in frameList:
show(makePicture(getMediaPath(frameList[frame])))


I know my populate worked with the while loop, and the while loop I have initially worked too.
The only problem I'm having is it opens each picture in a new window. If I want to run the animation for 10 seconds, there will be ~70 windows open.

/e As for the str(suffix), I don't know. It doesn't give an error there. I also tried it removing the str(), but nothing changed.

This post was edited by furbyjs on Oct 28 2013 10:21pm
Member
Posts: 10,812
Joined: Oct 15 2009
Gold: Locked
Warn: 20%
Oct 28 2013 10:21pm
Quote (furbyjs @ Oct 28 2013 09:19pm)
Still getting same error in
yeah read my edit above, its frameList[frame] that is bad


Member
Posts: 5,299
Joined: Jul 4 2009
Gold: 2,632.57
Oct 28 2013 10:22pm
Quote (Azrad @ Oct 28 2013 11:21pm)
yeah read my edit above, its frameList[frame] that is bad


That made it work in the for loop, but it's still opening a new window each time =/




/e I'm gonna go to sleep now xD
Thanks for all the help though, I'm going to email my professor tomorrow and I'll get back to this thread when he responds.
It's completely possible I'm making this much more difficult than it's meant to be.

This post was edited by furbyjs on Oct 28 2013 10:27pm
Member
Posts: 10,812
Joined: Oct 15 2009
Gold: Locked
Warn: 20%
Oct 28 2013 10:23pm
Quote (furbyjs @ Oct 28 2013 09:22pm)
That made it work in the for loop, but it's still opening a new window each time =/


heh now your into the territory of the function you are using to draw with, do you have a link to a manual for it? Maybe it has a method for updating/refreshing or something.

This post was edited by Azrad on Oct 28 2013 10:23pm
Member
Posts: 6,586
Joined: Jun 26 2011
Gold: 5,676.00
Oct 28 2013 10:24pm
Splicing is used when indexing, not for for loops. A for loop goes through one item at a time in the list, instead of your indexing which goes through and adds one to move onto the next item.
Code
for frame in frameList:
show(makePicture(getMediaPath(frame)))


/e delayed response because chrome is being a ^%@W to me and saying it's not connected.
Don't worry, for loops confused the crap out of me at first too, didn't understand them until a TA read my code and said indexing was awful and to use for loops, and explained what they did because I wasn't sure.

This post was edited by Dapwnzor on Oct 28 2013 10:31pm
Member
Posts: 5,299
Joined: Jul 4 2009
Gold: 2,632.57
Oct 29 2013 09:57pm
Okay, I figured it out.

I have to make an empty picture they size of the frames, then use a function "copyInto" inside the loop which will replace each previous picture with a new one.

Thanks for the help though xD
Go Back To Homework Help Topic List
Prev12
Add Reply New Topic New Poll