Discussion:
[Urwid] TagMarkupException Error
SHAIKH TAUSEEF HUSSAIN
2013-08-06 04:09:50 UTC
Permalink
Hi Ian
I have a yml file that contains a map as below :
university:
$io: input
$type: selection
$display: "What university do you attend?"
"Peking University": 'Peking University'
'Tsinghua University': 'Tsinghua University'

I read the map as an ordered dictionary and try to create a listbox that
contains the university selection choices as checkboxes to be displayed on
console.
My map is read at tmpMap for the code below :


listofKeysIntmpMap = tmpMap.keys()
idx = 1

font_buttons = []
radioGroup = []
for j in range(3,len(tmpMap)) :
userChoicesText =
urwid.Text(tmpMap.get(listofKeysIntmpMap[j])) #this text gets updated so
the forloop works

idx+=1
rb = urwid.AttrMap(urwid.RadioButton(radioGroup,
userChoicesText, state=False), 'Bg')
font_buttons.append( rb )


#create a pile of the checkboxes
pileOfSel = urwid.Pile([urwid.Text("Selections :")] +
font_buttons, focus_item=1)

box =
urwid.BoxAdapter(urwid.ListBox(urwid.SimpleListWalker(pileOfSel)),
height=idx)

However running above code gives a *urwid.util.TagMarkupException* error.
as below :
File "./yamlUrwidUI.py", line 246, in createBlock
rb = urwid.RadioButton(radioGroup, userChoicesText, state=False)
File "/wimp.py", line 366, in __init__
user_data)
File "/wimp.py", line 153, in __init__
self.set_label(label)
File "/wimp.py", line 178, in set_label
self._label.set_text(label)
File "/widget.py", line 880, in set_text
self._text, self._attrib = decompose_tagmarkup(markup)
File "/util.py", line 371, in decompose_tagmarkup
tl, al = _tagmarkup_recurse(tm, None)
File "/util.py", line 412, in _tagmarkup_recurse
raise TagMarkupException, "Invalid markup element: %r" % tm
urwid.util.TagMarkupException: Invalid markup element: <Text flow widget
b'Peking University'>

I am using the latest Urwid version (VERSION = (1, 1, 1)).
Could you tell what's going wrong here ? Is it something to do with the yml
file I am reading
or is it because of the way I am using the call to RadioButton widget ?
On a different note I will propose that you move the urwid mailing list
questions to stackoverflow.com as
that will help a lot of users.
--
Kind Regards
Tauseef Hussain
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.excess.org/pipermail/urwid/attachments/20130806/a792348b/attachment.htm
Ian Ward
2013-08-08 21:32:48 UTC
Permalink
On Tue, Aug 6, 2013 at 12:09 AM, SHAIKH TAUSEEF HUSSAIN
Post by SHAIKH TAUSEEF HUSSAIN
userChoicesText =
urwid.Text(tmpMap.get(listofKeysIntmpMap[j])) #this text gets updated so the
forloop works
idx+=1
rb = urwid.AttrMap(urwid.RadioButton(radioGroup,
userChoicesText, state=False), 'Bg')
RadioButton expects text markup, not a Text widget, try using:

userChoicesText = tmpMap.get(listofKeysIntmpMap[j])

Ian

Loading...