-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathcolorwrite.py
executable file
·150 lines (119 loc) · 4.52 KB
/
colorwrite.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
import wx
from document import Document
from corpus import Corpus
from channel import Channel
from log import Log
from sourceboard import SourceBoard
from settingsbox import SettingsBox
from controlpanel import ControlPanel
from entrypad import EntryPad
import threading
########################################################################
class Rainbowrite(wx.Panel):
""""""
#----------------------------------------------------------------------
def __init__(self, parent):
wx.Panel.__init__(self, parent, size = (1100,700))
self.frame = parent
self.SetBackgroundColour((40,40,40))
self.SetForegroundColour((255,255,255))
self.color_writing = True
self.speech = True
self.highlighting = True
self.mainSizer = wx.BoxSizer(wx.HORIZONTAL)
self.SetSizer(self.mainSizer)
self.inputPanel = wx.Panel(self)
self.inputSizer = wx.BoxSizer(wx.VERTICAL)
self.inputPanel.SetSizer(self.inputSizer)
self.outputPanel = wx.Panel(self)
self.outputSizer = wx.BoxSizer(wx.VERTICAL)
self.outputPanel.SetSizer(self.outputSizer)
self.log = Log(self.outputPanel, self) # text control for text output
#self.outputSizer.AddSpacer((0,50))
self.outputSizer.Add(self.log)
self.controlPanel = ControlPanel(self.inputPanel, self, size=wx.Size(205,-1))
self.sourceboard = SourceBoard(self.inputPanel, self, self.log, channels=[])
self.ep = EntryPad(self.outputPanel,self.sourceboard,self.log,self)
#self.outputSizer.AddSpacer((0,10))
self.outputSizer.Add(self.ep)
self.inputSizer.Add(self.controlPanel)
self.inputSizer.Add(self.sourceboard)
self.mainSizer.Add(self.inputPanel)
#self.mainSizer.AddSpacer((10,0))
self.mainSizer.Add(self.outputPanel)
#self.load_TED()
#self.load_assembly_module()
self.addChannel(['/Users/jbrew/Desktop/library/spaceneedle_low'])
#self.addChannel(['/Users/jbrew/Desktop/library/lyrics/bowie'])
#self.addPathAsChannel('/Users/jbrew/Desktop/library/beehive_manual.txt')
#self.addPathAsChannel('/Users/jbrew/Desktop/library/prose/bible/genesis')
#self.addPathAsChannel('/Users/jbrew/Desktop/library/speeches/feynman/1/_cleaner/all')
"""
if len(self.sourceboard.channels) == 0:
self.loadDialog()
"""
def load_TED(self):
self.sourceboard.clear_all_channels()
self.addChannel(['/Users/jbrew/Desktop/library/TED/data/counts/1gram_counts',
'/Users/jbrew/Desktop/library/TED/data/counts/2gram_counts',
'/Users/jbrew/Desktop/library/TED/data/counts/3gram_counts',
'/Users/jbrew/Desktop/library/TED/data/counts/4gram_counts'])
self.addChannel(['/Users/jbrew/Desktop/library/TED/data/rawtranscripts/ai'])
def load_lyrics_module(self):
self.sourceboard.clear_all_channels()
self.addChannel(['/Users/jbrew/Desktop/library/lyrics/bowie'])
self.addChannel(['/Users/jbrew/Desktop/library/lyrics/bjork.txt'])
self.addChannel(['/Users/jbrew/Desktop/library/lyrics/bieber.txt'])
#----------------------------------------------------------------------
def refresh(self):
self.sourceboard.refresh()
self.ep.Destroy()
self.ep = EntryPad(self.outputPanel,self.sourceboard,self.log,self)
self.outputSizer.Add(self.ep, wx.BOTTOM)
self.Layout()
#----------------------------------------------------------------------
def addChannel(self, paths):
c = Corpus()
for path in paths:
print path
with open(path) as f:
text = f.read()
name = path.split('/')[-1]
d = Document(name, text)
c.add_document(d)
self.sourceboard.addChannel(c)
self.refresh()
self.frame.fSizer.Layout()
self.frame.Fit()
def openSettingsBox(self):
sb = SettingsBox(self, self)
def loadDialog(self):
loadChannelDialog = wx.FileDialog(self, style = wx.FD_MULTIPLE)
loadChannelDialog.SetMessage("Select a source text.")
loadChannelDialog.ShowModal()
paths = loadChannelDialog.GetPaths()
self.addChannel(paths)
loadChannelDialog.Destroy()
########################################################################
class TopFrame(wx.Frame):
""""""
#----------------------------------------------------------------------
def __init__(self):
"""Constructor"""
wx.Frame.__init__(self, parent=None, title="Voicebox")
menubar = wx.MenuBar()
fileMenu = wx.Menu()
menubar.Append(fileMenu, '&File')
self.SetMenuBar(menubar)
self.fSizer = wx.BoxSizer(wx.VERTICAL)
panel = Rainbowrite(self)
self.fSizer.Add(panel, 1, wx.EXPAND)
self.SetSizer(self.fSizer)
self.Fit()
self.Center()
self.Show()
#----------------------------------------------------------------------
if __name__ == "__main__":
app = wx.App(False)
frame = TopFrame()
app.MainLoop()