[Urwid] still very confused (error makes no sense)
Eric S. Johansson
esj at harvee.org
Tue Jul 4 22:51:31 EDT 2006
esj at piedoggie:~/projects/2red$ python redui.py
Traceback (most recent call last):
File "redui.py", line 288, in ?
td.main()
File "redui.py", line 133, in main
self.ui.run_wrapper( self.run )
File "/home/esj/projects/2red/urwid/curses_display.py", line 177, in
run_wrapper
return fn()
File "redui.py", line 139, in run
self.draw_screen( size )
File "redui.py", line 150, in draw_screen
canvas = self.top.render( size, focus=True )
File "/home/esj/projects/2red/urwid/listbox.py", line 235, in render
middle, top, bottom = self.calculate_visible(
File "/home/esj/projects/2red/urwid/listbox.py", line 134, in
calculate_visible
offset_rows, inset_rows = self.get_focus_offset_inset(
File "/home/esj/projects/2red/urwid/listbox.py", line 537, in
get_focus_offset_inset
focus_rows = focus_widget.rows((maxcol,), True)
AttributeError: 'list' object has no attribute 'rows'
esj at piedoggie:~/projects/2red$
I didn't verify that at this point that yes it truly is getting a list I
don't know how it's getting a list or why. I thought I was copying the
example model correctly but obviously I've missed something.
and the appropriate bit of code (I think)
def __init__(self):
syslog("__init__")
self.current_color = 'GREEN'
self.edit_array = {}
if os.path.isdir("./ipcop"):
self.system = configuration("ethernet", 'settings', "r+",
"./ipcop")
self.alt_red = configuration("ethernet", 'altsettings',
"r+", "./ipcop")
else:
self.system = configuration("ethernet", 'settings', "r+")
self.alt_red = configuration("ethernet", 'altsettings', "r+")
self.translate_color = {}
radio_group = []
self.l = []
# each button has attributes
for networks in ['GREEN','ORANGE','BLUE','RED','ALT']:
# set up a color to index translation for handling button
presses
self.translate_color[networks] = len(self.l)
b = urwid.RadioButton( radio_group, networks,
on_state_change = self.location_select )
b.network_list = {}
b.network_list = self.color_keys(networks)
self.l.append( b )
# gridflow controls buttons layout
# self.location_select( l[0], True )
#print "ccc",self.l[0].network_list
location = urwid.GridFlow( self.l, 15, 2, 0, 'left' )
self.items=[]
self.base_items = [ location, urwid.Divider()]
#print "ccc",self.l[0].network_list
self.items.append(self.base_items )
for key,item in self.l[0].network_list.items():
self.color_net = urwid.Edit(key,item)
# one_row = urwid.Columns([('fixed', 15, self.color_net)])
one_row = ('fixed', 15, self.color_net)
self.items.append(one_row )
self.location_select(self.l[0], True)
self.listbox = urwid.ListBox( self.items )
self.top = self.listbox
def location_select( self, button, state ):
if not state:
return
return
del self.items[2:]
index = self.translate_color[button.get_label()]
b = self.l[index]
#print "CCCCC: ",b
for key,item in self.l[index].network_list.items():
self.color_net = urwid.Edit(key,item)
one_row = urwid.Columns([('fixed', 15, self.color_net)])
self.items.append(one_row )
def main(self):
self.ui = urwid.curses_display.Screen()
self.ui.run_wrapper( self.run )
def run(self):
size = self.ui.get_cols_rows()
while True:
self.draw_screen( size )
keys = self.ui.get_input()
for k in keys:
if k == "window resize":
size = self.ui.get_cols_rows()
continue
if k == "q":
return
self.top.keypress( size, k )
def draw_screen(self, size):
canvas = self.top.render( size, focus=True )
self.ui.draw_screen( size, canvas )
More information about the Urwid
mailing list