plotting slows down

2014-01-13 Thread norman . elliott
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]


-- 
https://mail.python.org/mailman/listinfo/python-list


Re: plotting slows down

2014-01-13 Thread Norman Elliott
On Monday, 13 January 2014 08:15:08 UTC, Norman Elliott  wrote:
> 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]
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: plotting slows down

2014-01-13 Thread Norman Elliott
I am running ubuntu 12.04 with all updates installed.

I got the graphics here:
http://mcsp.wartburg.edu/zelle/python/graphics/graphics/index.html

I cannot see how to change from html to text mode in chromium or within the 
group.

I read the link about double spacing so I will watch out for it.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: plotting slows down

2014-01-13 Thread Norman Elliott
On Monday, 13 January 2014 18:05:52 UTC, Dave Angel  wrote:
> Chris Angelico  Wrote in message:
> 


Well Ian's suggestion has really done the job. Now each iteration takes just 
0.14 seconds now.
changed to:
[code]
win = GraphWin("My Circle", xpos, ypos, autoflush=False)
[/code]

and added 
[code]
update()
[/code]

immediately after the line
[code]
for y in range(1,12):
[/code]

previously the first iteration took 0.48 seconds and the the 10th 4.76
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: plotting slows down

2014-01-14 Thread Norman Elliott
@Dave, no problem. I am using gedit to write the files and have it set to 
translate tabs into 4 spaces which is what was recommended to me as the right 
amount of indenting for python scripts.

On Monday, 13 January 2014 08:15:08 UTC, Norman Elliott  wrote:
> 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]

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: plotting slows down

2014-01-14 Thread Norman Elliott
On Monday, 13 January 2014 08:15:08 UTC, Norman Elliott  wrote:
> 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]

Okay, maybe I misunderstood what it was doing. I have checked and I will do a 
find and replace of the tabs with 4 spaces in future. 
-- 
https://mail.python.org/mailman/listinfo/python-list