Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #63814

plotting slows down

Newsgroups comp.lang.python
Date 2014-01-13 00:15 -0800
Message-ID <4c51b5e8-e7b4-4a09-95d4-daefbfe27b28@googlegroups.com> (permalink)
Subject plotting slows down
From norman.elliott@gmail.com

Show all headers | View raw


First let me say I have not done much python programming!
I am running Python 2.7.3.
I am trying to use python as a front end to a simple oscilloscope.
Ultimately I intend to use it with my micropython board.

At the moment I am just developing it. All it does is use a module I found called graphics.py to create a window and display randomly generated data.

Each time it goes through the outer loop it gets slower and slower.
I put in a small delay just so I could observe what is happening and for the first line it draws it takes about a second. If I set it to loop 20 times the final loop takes more than 6 seconds.
Can anyone explain what I am doing wrong please?
Here is the code:
[code]
#!/usr/bin/python
from graphics import *
import random
import time

xpos=1200
ypos=400
ypnt=ypos/2
pos=1
#setBackground("white")
def main():
	win = GraphWin("My Circle", xpos, ypos)
#	win.setBackGround('white')
	for y in range(1,5):
		cir2 = Circle(Point(xpos/2,20), 10)
		cir2.setFill("white")
		cir2.draw(win)
		message = Text(Point(win.getWidth()/2, 20), y)
		message.draw(win)
		j = random.randint(1,ypos)
		for x in range(1,xpos):
			updown = random.randint(0,1)
			if updown:
				j=j+1
			else:
				j=j-1
			if j <1:
				j=ypos/2
			if j>ypos-1:
				j=ypos/2
			win.plot(x,j,"red")
			time.sleep(.0001)

main()
time.sleep(5)
[/code]

Back to comp.lang.python | Previous | NextNext in thread | Find similar | Unroll thread


Thread

plotting slows down norman.elliott@gmail.com - 2014-01-13 00:15 -0800
  Re:plotting slows down Dave Angel <davea@davea.name> - 2014-01-13 08:26 -0500
    Re:plotting slows down Steven D'Aprano <steve@pearwood.info> - 2014-01-13 20:33 +0000
      Re:plotting slows down Dave Angel <davea@davea.name> - 2014-01-14 04:39 -0500
      Re: plotting slows down Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2014-01-14 08:48 -0500
  Re: plotting slows down Norman Elliott <norman.elliott@gmail.com> - 2014-01-13 05:32 -0800
  Re: plotting slows down Norman Elliott <norman.elliott@gmail.com> - 2014-01-13 05:45 -0800
    Re: plotting slows down Dave Angel <davea@davea.name> - 2014-01-14 04:32 -0500
  Re: plotting slows down Ian Kelly <ian.g.kelly@gmail.com> - 2014-01-13 10:39 -0700
  Re: plotting slows down Chris Angelico <rosuav@gmail.com> - 2014-01-14 04:45 +1100
  Re: plotting slows down Dave Angel <davea@davea.name> - 2014-01-13 13:05 -0500
    Re: plotting slows down Norman Elliott <norman.elliott@gmail.com> - 2014-01-13 10:33 -0800
  Re: plotting slows down Ian Kelly <ian.g.kelly@gmail.com> - 2014-01-13 11:05 -0700
  Re: plotting slows down Terry Reedy <tjreedy@udel.edu> - 2014-01-13 16:42 -0500
  Re: plotting slows down Norman Elliott <norman.elliott@gmail.com> - 2014-01-14 05:04 -0800
    Re: plotting slows down Rustom Mody <rustompmody@gmail.com> - 2014-01-14 05:15 -0800
      Re: plotting slows down Chris Angelico <rosuav@gmail.com> - 2014-01-15 00:36 +1100
  Re: plotting slows down Norman Elliott <norman.elliott@gmail.com> - 2014-01-14 09:06 -0800

csiph-web