Beispiel #1
0
def additems(i, doreturn=False, bgcolor="#555"):
	returnable = []
	for item in i:
		global totalitems
		totalitems += 1
		ff = Frame(f, bg=bgcolor)
		item.body = item.author.name + ' || ' + item.fullname + '\n' + item.body
		item.body = str(totalitems) + '\n' + item.body
		ibody = item.body.replace('\n\n', '\n')
		ifinal = ''
		for paragraph in ibody.split('\n'):
			ifinal += '\n'.join(textwrap.wrap(paragraph))
			ifinal += '\n'  
	
		item.body = ifinal
		ww = 680
		wh = 10 
		wx = 20
		wy = 20 
		#print(ww, wh, wx, wy)
		ff.ww = ww
		ff.wh = wh
		ff.wx = wx
		ff.wy = wy
		ff.body = item.body
		ff.sourceitem = item
		ff.configure(width=ww, height=wh)
		ff.place(x=wx, y=wy)
		ff.bind("<B1-Motion>", framedrag)
		ff.bind("<ButtonRelease-1>", resetdrag)
		ff.pack_propagate(0)
		l = Label(ff, text=item.body, bg="#777")
		l.place(x=10,y=10)
		rt = Text(ff, width= 15, height= (len(ifinal.split('\n'))) - 2)
		rt.sourceitem = item
		rt.place(x=400,y=10)
		rb = Button(ff, text="Reply", command= lambda rep=rt: reply(rep))
		rb.place(x=400,y=wh-20)
		ff.rt = rt
		ff.rb = rb
		if not doreturn:
			widgets.append(ff)
		else:
			returnable.append(ff)
	if doreturn:
		return returnable
	else:
		refreshscreen()