Документ взят из кэша поисковой машины. Адрес оригинального документа : http://kodomo.fbb.msu.ru/hg/allpy/rev/693943fed7b0
Дата изменения: Unknown
Дата индексирования: Tue Oct 2 00:23:25 2012
Кодировка:
allpy: 693943fed7b0

allpy

changeset 11:693943fed7b0

Sandbox: another failed attempt at using python+tk+text for rendering.
author Danya Alexeyevsky <dendik@kodomo.fbb.msu.ru>
date Thu, 10 Jun 2010 15:03:09 +0400
parents ea7a761d3f70
children bd3d695f9906
files sandbox/tk-text.py
diffstat 1 files changed, 51 insertions(+), 0 deletions(-) [+]
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/sandbox/tk-text.py	Thu Jun 10 15:03:09 2010 +0400
     1.3 @@ -0,0 +1,51 @@
     1.4 +from Tkinter import *
     1.5 +import common
     1.6 +
     1.7 +root = Tk()
     1.8 +
     1.9 +t = Text(root, wrap='no', font='Courier 12')
    1.10 +w = Scrollbar(orient='horizontal', command=t.xview)
    1.11 +h = Scrollbar(orient='vertical', command=t.yview)
    1.12 +t.grid(row=0, column=0, sticky='nsew')
    1.13 +w.grid(row=1, column=0, sticky='we')
    1.14 +h.grid(row=0, column=1, sticky='ns')
    1.15 +root.grid_rowconfigure(0, weight=1)
    1.16 +root.grid_columnconfigure(0, weight=1)
    1.17 +
    1.18 +seqs = common.autoload('data/large.fasta')
    1.19 +
    1.20 +print "loaded"
    1.21 +root.update()
    1.22 +
    1.23 +## v1: bw
    1.24 +## a few seconds
    1.25 +t.insert('end', "\n".join(body for name, body, ids, colors in seqs))
    1.26 +
    1.27 +# ## v2: tag per color
    1.28 +# for name, body, ids, colors in seqs:
    1.29 +# 	for i in xrange(len(body)):
    1.30 +# 		t.insert('end', body[i], 'c%d' % ids[i])
    1.31 +# 	t.insert('end', '\n')
    1.32 +# 
    1.33 +# for i in xrange(11):
    1.34 +# 	c = i * 255 // 10
    1.35 +# 	t.tag_configure('c%d' % i, background='#%02x%02x%02x' % (c,c,c))
    1.36 +
    1.37 +# ## v3: tag per color inside one line
    1.38 +# ## a few minutes to draw
    1.39 +# ## vertical scrolling is extremely slow (horizontal is lagless though)
    1.40 +# for y, (name, body, ids, colors) in enumerate(seqs):
    1.41 +# 	for i in xrange(len(body)):
    1.42 +# 		t.insert('end', body[i], 'l%dc%d' % (y, ids[i]))
    1.43 +# 	t.insert('end', '\n')
    1.44 +# 	root.update()
    1.45 +# 
    1.46 +# print "text created"
    1.47 +# root.update()
    1.48 +# 
    1.49 +# for y in xrange(len(seqs)):
    1.50 +# 	for i in xrange(11):
    1.51 +# 		c = i * 255 // 10
    1.52 +# 		t.tag_configure('l%dc%d' % (y, i), background='#%02x%02x%02x' % (c,c,c))
    1.53 +
    1.54 +root.mainloop()