scrolledtext widget error?

S

shstein2002

I wrote a twitter client which writes the statuses into a ScrolledText
widget, but it rarely gives a error that I can't nail down. The code
is:

twitwin.scrolled.config(state=NORMAL)
twitwin.scrolled.delete("1.0", END)
evens = True
_.links = []
for x in _.parser.tweets:
start = _.scrolled.index(INSERT)
print "start = ",start
_.scrolled.insert(END, x['screen_name']+" ", ("bold",))
txt = _.whitere.sub(" ",x['text']) #the text with whitespace
compressed
islink = False
for y in _.urlre.split(txt): #handle urls
if y != "":
if islink:
a = _.scrolled.index(INSERT)
_.scrolled.insert(END, y)#, ("link",))
b = _.scrolled.index(INSERT)
_.scrolled.tag_add("link", a, b)
_.scrolled.tag_add("href%d"%len(_.links), a, b)
_.links.append((a,b,y)) #save url info and position
in the widget
else:
_.scrolled.insert(END, y)
islink = not islink
_.scrolled.insert(END, "\n")
if evens:
_.scrolled.tag_add("light", start, END) #alternating
background colors
else:
_.scrolled.tag_add("dark", start, END)
evens = not evens
twitwin.scrolled.config(state=DISABLED)

The print statement usually prints a valid index, but rarely prints
"start=None" and it crashes. Should I be using something other than
INSERT or another method here?

Thanks in advance,
-- Rick
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,778
Messages
2,569,605
Members
45,238
Latest member
Top CryptoPodcasts

Latest Threads

Top