This is my code and I don't know why I'm getting error when I run this program on terminal.this is my python code python 3.5, I'm new to curses module and unable to handle this error ,thanks in advance
import urllib.request as ur
import time
import curses
def ini(i):
url = 'http://www.top4themes.com/data/out/134/6545537-superman-logo-wallpapers.jpg'
req = ur.urlopen(url)
count = 0
block_size= 1024
avg = 0
smin = []
value = False
t = []
while True:
start = time.time()
buff = req.read(block_size)
stop = time.time()
avg += len(buff)
if not buff:
break;
if (stop-start) < 0.2 :
block_size += 2048
elif (stop-start) > 0.2:
block_size -= 1024
count += 1
stdscr(1,0,"{}".format(block_size))
stdscr.refresh()
t.append(int(block_size))
if(block_size ==0):
block_size=max(t)
if __name__=="__main__":
stdscr = curses.initscr()
curses.noecho()
curses.cbreak()
try:
for i in range(10):
ini(i)
time.sleep(0.5)
finally:
curses.echo()
curses.nocbreak()
curses.endwin()
The error refers to the line stdscr(1,0,"{}".format(block_size))
. Presumably you were going for something like stdscr.addstr(1,0,"{}".format(block_size))
.