Документ взят из кэша поисковой машины. Адрес оригинального документа : http://kodomo.fbb.msu.ru/hg/allpy/file/632a0708ab33/sandbox/wx-dc.py
Дата изменения: Unknown
Дата индексирования: Mon Feb 4 06:08:33 2013
Кодировка:
allpy: 632a0708ab33 sandbox/wx-dc.py

allpy

view sandbox/wx-dc.py @ 735:632a0708ab33

blocks3d/www: allow blocks not to be continuous Changes: * javascript * blocks_to_html method of AlignmentMixin * test for blocks viewer (add one non-continuous block) Currently block can have either "start" and "end" or "positions" attribute, but not both. "start" and "end" attributes are not deprecated and can be used if blocks are known to be continuous or while writting blocks javascript by hands. close #71
author boris <bnagaev@gmail.com>
date Fri, 08 Jul 2011 20:21:39 +0200
parents
children 61e5d8e146c7
line source
1 #!/usr/bin/python
3 import wx
4 import bufferedcanvas
5 import common
7 class Text(bufferedcanvas.BufferedCanvas):
9 def __init__(self, seqs, *args, **kw):
10 self.seqs = seqs
11 self.font = wx.FFont(12, wx.FONTFAMILY_MODERN)
12 bufferedcanvas.BufferedCanvas.__init__(self, *args, **kw)
14 dc = wx.ClientDC(self)
15 dc.SetFont(self.font)
16 w = (len(seqs[0][1])+1) * dc.GetCharWidth()
17 h = (len(seqs)+1) * (dc.GetCharHeight() + 1)
18 self.size = w, h
19 self.SetVirtualSize(self.size)
21 self.Bind(wx.EVT_SCROLL, self.onPaint)
23 self.SetupScrolling()
25 def draw(self, dc):
26 dc.SetBackground(wx.Brush("White"))
27 dc.Clear()
28 dc.SetFont(self.font)
30 w = dc.GetCharWidth()
31 h = dc.GetCharHeight()
32 for i, (name, body, ids, colors) in enumerate(self.seqs):
33 for j in xrange(len(body)):
34 x = j * w
35 y = i * (h + 1)
36 dc.SetBrush(wx.Brush(colors[j]))
37 dc.SetPen(wx.Pen(colors[j]))
38 dc.DrawRectangle(x, y, x + w, y + h)
39 dc.SetPen(wx.Pen("Black"))
40 dc.DrawText(body[j], x, y)
42 if hasattr(self, 'size'):
43 self.SetVirtualSize(self.size)
45 seqs = common.autoload('data/small.fasta')
47 app = wx.App(False)
48 top = wx.Frame(None, title='Example', size=(500, 500))
49 text = Text(seqs, top)
50 top.Show(True)
52 app.MainLoop()