Hi, attached is a small test program that adds one line per second to a list. With the raw_ display module, the screen is updated as intended. With the web_ and curses_ display modules however, the screen is only updated upon keypresses. What am I missing?
Cheers HC
import curses
import os
import signal
import socket
import subprocess
import threading
import time
import traceback
import urwid
import urwid.curses_display
import urwid.web_display
import sys
redraw_rd, redraw_wr = os.pipe()
if urwid.web_display.is_web_request():
Screen = urwid.web_display.Screen
else:
print "Which module? enter 1 for curses, anything else means raw."
if sys.stdin.readline() == "1\n":
print "Using curses display module."
Screen = urwid.curses_display.Screen
else:
print "Using raw display module."
Screen = urwid.raw_display.Screen
# delay two seconds so as to allow the user to see which module is
# being used
time.sleep(2)
class DoIt(threading.Thread):
def __init__(self, lst, pipe):
threading.Thread.__init__(self)
self.lst = lst
self.pipe = pipe
def run(self):
while True:
self.lst.append(urwid.Text("The time is %d" % time.time()))
os.write(self.pipe, 'x')
time.sleep(1)
if __name__=='__main__':
urwid.web_display.set_preferences("Asterisk Events.")
if urwid.web_display.handle_short_request():
sys.exit(0)
title = urwid.Text("Console test foo")
lstLog = []
lswLog = urwid.SimpleListWalker(lstLog)
txtLog = urwid.ListBox(lstLog)
frame = urwid.Frame(body=txtLog, header=title)
loop = urwid.MainLoop(frame, (), handle_mouse=True, \
screen=Screen())
doit = DoIt(lstLog, redraw_wr)
doit.start()
def pipe_redraw_screen():
os.read(redraw_rd, 1)
loop.draw_screen()
loop.event_loop.watch_file(redraw_rd, pipe_redraw_screen)
loop.run()
doit.disconnect()
signature.asc
Description: Digital signature
_______________________________________________ Urwid mailing list [email protected] http://lists.excess.org/mailman/listinfo/urwid
