allpy
changeset 12:bd3d695f9906
In sandbox: added several attempts on different use of wx.TextCtrl
author | Danya Alexeyevsky <dendik@kodomo.fbb.msu.ru> |
---|---|
date | Thu, 10 Jun 2010 18:37:11 +0400 |
parents | 693943fed7b0 |
children | e3ba4c63e622 |
files | sandbox/wx-textctrl.py |
diffstat | 1 files changed, 54 insertions(+), 0 deletions(-) [+] |
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/sandbox/wx-textctrl.py Thu Jun 10 18:37:11 2010 +0400 1.3 @@ -0,0 +1,54 @@ 1.4 +#!/usr/bin/python 1.5 + 1.6 +import wx 1.7 +import common 1.8 + 1.9 +app = wx.App(False) 1.10 +font = wx.FFont(12, wx.FONTFAMILY_MODERN) 1.11 +top = wx.Frame(None, title='Example', size=(1000, 600)) 1.12 +text = wx.TextCtrl(top, style=wx.TE_MULTILINE|wx.TE_READONLY|wx.TE_DONTWRAP|wx.TE_RICH2) 1.13 +text.SetFont(font) 1.14 +top.Show(True) 1.15 + 1.16 +seqs = common.autoload('data/large.fasta') 1.17 + 1.18 +# ## v1: bw 1.19 +# text.AppendText("\n".join(body for name, body, ids, colors in seqs)) 1.20 + 1.21 +# ## v1.1: bw 1.22 +# for name, body, ids, colors in seqs: 1.23 +# text.WriteText(body + "\n") 1.24 + 1.25 +# ## v2: naive color 1.26 +# for name, body, ids, colors in seqs: 1.27 +# for x in xrange(len(body)): 1.28 +# text.SetDefaultStyle(wx.TextAttr('black', colors[x])) 1.29 +# text.AppendText(body[x]) 1.30 +# text.AppendText(body + "\n") 1.31 + 1.32 +# ## v3: preconfigured color 1.33 +# attrs = [] 1.34 +# for i in xrange(11): 1.35 +# c = i * 255 // 10 1.36 +# attrs.append(wx.TextAttr('black', '#%02x%02x%02x' % (c,c,c))) 1.37 +# 1.38 +# for name, body, ids, colors in seqs: 1.39 +# for x in xrange(len(body)): 1.40 +# text.SetDefaultStyle(attrs[ids[x]]) 1.41 +# text.AppendText(body[x]) 1.42 +# text.AppendText(body + "\n") 1.43 + 1.44 +# ## v4: output text, then colorize 1.45 +# text.WriteText("\n".join(body for name, body, ids, colors in seqs)) 1.46 +# 1.47 +# i = 0 1.48 +# text.Freeze() 1.49 +# for name, body, ids, colors in seqs: 1.50 +# print name 1.51 +# for x in xrange(len(body)): 1.52 +# text.SetStyle(i, i+1, wx.TextAttr('black', colors[x])) 1.53 +# i += 1 1.54 +# i += 1 1.55 +# text.Thaw() 1.56 + 1.57 +app.MainLoop()