ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/ns_dev/Python/NinoCode/Active_prgs/PrivDescriptionAssistant/trunk/PrivDescriptionAssistant_UI.py
Revision: 556
Committed: Wed Jun 18 21:31:14 2014 UTC (11 years, 9 months ago) by nino.borges
Content type: text/x-python
File size: 21284 byte(s)
Log Message:
Added a simple about.

File Contents

# User Rev Content
1 ninoborges 8 """
2    
3     PrivDescriptionAssistantUI
4    
5     Created by
6     Emanuel Borges
7     05.02.2011
8    
9 nino.borges 346 This program will allow Concordance (Or any tool) users to speed up the process of creating
10 ninoborges 8 priv description sentances.
11    
12     """
13    
14 nino.borges 551 import wx,pickle, os, time
15     import wx.lib.agw.pybusyinfo as PBI
16 ninoborges 8
17 nino.borges 551 class SettingGenerator(object):
18     '''Will read and write to a pickle file, like winpbx.sts'''
19     def __init__(self,settingsFile):
20     self.settingsFile = settingsFile
21    
22    
23     def load_obj(self):
24     if os.path.exists(self.settingsFile):
25     with open(self.settingsFile, 'rb') as f:
26     return pickle.load(f)
27     else:
28     print "%s file not found!"% os.path.splitext(self.settingsFile)[1]
29    
30     def save_obj(self,obj):
31     #with open('obj/'+ name + '.pkl', 'wb') as f:
32     with open(self.settingsFile, 'wb') as f:
33     pickle.dump(obj, f, pickle.HIGHEST_PROTOCOL)
34    
35    
36    
37     class MainPage(wx.Panel):
38     ''' The main notebook tab'''
39     def __init__(self,parent):
40     wx.Panel.__init__(self, parent)
41     settingsLoader = SettingGenerator('winpbx.sts')
42     rawObj = settingsLoader.load_obj()
43     documentTypeList = rawObj['documentTypeList']
44     basisList = rawObj['basisList']
45     regardingList = rawObj['regardingList']
46     adendumList = rawObj['adendumList']
47     #documentTypeList = ['','Email', 'Email chain', 'Presentation', 'Draft correspondence', 'Draft agreement',
48     # 'Executed correspondence', 'Executed agreement', 'Spreadsheet']
49 nino.borges 346 #documentTypeList = ['','Email','Presentation','Memorandum','Spreadsheet']
50 nino.borges 551 #documentTypeList = ['','Letter','Internal memorandum','Memorandum','Email','Chart','Report','Presentation','Agreement']
51 ninoborges 8
52 nino.borges 551 #basisList = ['',
53     # 'sent to legal counsel requesting legal advice',
54 nino.borges 346 # 'between attorney-retained consultants',
55     # 'from legal counsel',
56     # 'from attorney-retained consultants providing advice',
57     # 'to attorney-retained consultants',
58     # 'sent to legal counsel requesting legal review and comment',
59     # 'sent to legal counsel for the purpose of obtaining legal advice',
60     # 'forwarding and discussing email providing advice from legal counsel []',
61     # 'referencing legal advice from legal counsel [] ',
62     # 'designated "Attorney Client Privileged"',
63     # ]
64 nino.borges 518 #basisList = ['','with', 'from counsel', 'to counsel', 'forwarding email from counsel', 'forwarding email chain with counsel', 'forwarding email chain to counsel']
65 nino.borges 551 #basisList = ['','by counsel','from counsel','to counsel','with counsel']
66 nino.borges 346
67 nino.borges 551
68     #regardingList = ['','seeking legal advice regarding', 'seeking legal review regarding', 'providing legal advice regarding', 'providing legal review regarding', 'seeking and providing legal advice regarding',
69     # 'referencing legal advice provided by [fill in then delete brackets] regarding', 'forwarding and discussing legal advice provided by [fill in then delete brackets] regarding','seeking information to facilitate the provision of legal advice regarding',
70     # 'providing information to facilitate the provision of legal advice regarding']
71    
72 nino.borges 346 #regardingList = ['','regarding []']
73    
74     #adendumList = ['',
75     # 'for purposes of facilitating the provision of legal advice by counsel',
76     # 'redacted',
77     # 'and attached to foregoing email',]
78     #
79 nino.borges 518 #adendumList = ['','279 D Street LLC','Bitran Charitable Foundation','Bitran Family LP','Bitran Family Partnership',
80     # 'Boston Multi-Fam Prop. Dev.','Clearstream Investments','Crepaldi Bitran Charitable Trust','FPG 17 Wensley LLC','FPG Property Acquisition 1',
81     # 'GMB Capital Partners','Great Pond Mgmt','Isalia Property 1 LLC','Isalia Property Group LLC (fka Fisher)','Lecount Hollow Investments LP',
82     # 'Marco Bitran 2007 Irr. Fam. Trust','Marco Bitran Family Trust','Sababa Investments','Sabra Inc','Stoney Beach Rev Trust']
83     #
84 nino.borges 551 #adendumList = ['','Draft']
85     #t = {'documentTypeList':documentTypeList,'basisList':basisList,'regardingList':regardingList,'adendumList':adendumList}
86     #test = SettingGenerator('winpbx.sts')
87     #test.save_obj(t)
88 nino.borges 346
89 nino.borges 551 docType_lbl = wx.StaticText(self, -1, "Document Type : ")
90     self.docType_SelectBox = wx.Choice(self, -1,(100, 50), choices = documentTypeList)
91     basis_lbl = wx.StaticText(self, -1, "Basis : ")
92     self.basis_SelectBox = wx.Choice(self, -1,(100, 50), choices = basisList)
93     regarding_lbl = wx.StaticText(self, -1, "Regarding : ")
94     self.regarding_SelectBox = wx.Choice(self, -1,(100, 50), choices = regardingList)
95     adendum_lbl = wx.StaticText(self, -1, "Draft : ")
96     self.adendum_SelectBox = wx.Choice(self, -1,(100, 50), choices = adendumList)
97 nino.borges 518
98 nino.borges 551 self.privSentanceTextBox = wx.TextCtrl(self,-1,style=wx.TE_MULTILINE, size=(450,100))
99 ninoborges 8
100     self.CreateBoxesSection()
101    
102     mainSizer = wx.BoxSizer(wx.VERTICAL)
103 nino.borges 551 contentSizer = wx.BoxSizer(wx.VERTICAL)
104     contentSizer.Add(adendum_lbl, 0, wx.ALIGN_CENTER|wx.ALL, 10)
105     contentSizer.Add(self.adendum_SelectBox , 0, wx.ALIGN_CENTER|wx.BOTTOM, 15)
106     contentSizer.Add(docType_lbl , 0, wx.ALIGN_CENTER|wx.ALL, 10)
107     contentSizer.Add(self.docType_SelectBox, 0, wx.ALIGN_CENTER|wx.BOTTOM, 15)
108     contentSizer.Add(basis_lbl, 0, wx.ALIGN_CENTER|wx.ALL, 10)
109     contentSizer.Add(self.basis_SelectBox, 0, wx.ALIGN_CENTER|wx.BOTTOM, 15)
110     contentSizer.Add(regarding_lbl, 0, wx.ALIGN_CENTER|wx.ALL, 10)
111     contentSizer.Add(self.regarding_SelectBox, 0, wx.ALIGN_CENTER|wx.BOTTOM, 30)
112 nino.borges 518
113 nino.borges 551 contentSizer.Add(self.privSentanceTextBox, 0, wx.ALIGN_CENTER|wx.ALL, 25)
114     contentSizer.Add(self.buttonSizer,0, wx.ALL|wx.ALIGN_BOTTOM|wx.ALIGN_CENTER, 20)
115     mainSizer.Add(contentSizer,0,wx.ALIGN_CENTER|wx.TOP,45)
116     self.SetSizer(mainSizer)
117 ninoborges 8
118     self.Bind(wx.EVT_CHOICE, self.RescanSentance, self.docType_SelectBox)
119     self.Bind(wx.EVT_CHOICE, self.RescanSentance, self.basis_SelectBox)
120     self.Bind(wx.EVT_CHOICE, self.RescanSentance, self.regarding_SelectBox)
121     self.Bind(wx.EVT_CHOICE, self.RescanSentance, self.adendum_SelectBox)
122     self.Bind(wx.EVT_BUTTON, self.OnProcess, self.oKButton)
123 nino.borges 551 #self.Bind(wx.EVT_BUTTON, self.CloseWindow, self.cancelButton)
124    
125 ninoborges 8 def RescanSentance(self,event):
126     self.privSentanceTextBox.Clear()
127 nino.borges 518 if self.adendum_SelectBox.GetStringSelection():
128     self.privSentanceTextBox.AppendText(self.adendum_SelectBox.GetStringSelection() + " ")
129 ninoborges 8 if self.docType_SelectBox.GetStringSelection():
130     self.privSentanceTextBox.AppendText(self.docType_SelectBox.GetStringSelection() + " ")
131     if self.basis_SelectBox.GetStringSelection():
132     self.privSentanceTextBox.AppendText(self.basis_SelectBox.GetStringSelection() + " ")
133 nino.borges 518 #if self.regarding_SelectBox.GetStringSelection():
134     # self.privSentanceTextBox.AppendText(self.regarding_SelectBox.GetStringSelection() + ".")
135 ninoborges 8 if self.regarding_SelectBox.GetStringSelection():
136     self.privSentanceTextBox.AppendText(self.regarding_SelectBox.GetStringSelection() + " ")
137    
138     def CreateBoxesSection(self):
139 nino.borges 551 self.oKButton = wx.Button(self, wx.ID_OK)
140 ninoborges 8 self.oKButton.SetDefault()
141     self.oKButton.SetSize(self.oKButton.GetBestSize())
142 nino.borges 551 self.cancelButton = wx.Button(self, wx.ID_CANCEL)
143 ninoborges 8 self.cancelButton.SetSize(self.cancelButton.GetBestSize())
144     self.buttonSizer = wx.BoxSizer(wx.HORIZONTAL)
145     self.buttonSizer.Add(self.oKButton,0,wx.ALL,10)
146     self.buttonSizer.Add(self.cancelButton,0,wx.ALL,10)
147    
148     def CloseWindow(self, event):
149     self.Close(True)
150    
151     def OnProcess(self, event):
152     print self.privSentanceTextBox.GetValue()
153     cb_DataObj = wx.TextDataObject(self.privSentanceTextBox.GetValue())
154     if wx.TheClipboard.Open():
155     wx.TheClipboard.SetData(cb_DataObj)
156     wx.TheClipboard.Close()
157     self.privSentanceTextBox.Clear()
158 nino.borges 518 self.adendum_SelectBox.SetSelection(0)
159 ninoborges 8 self.docType_SelectBox.SetSelection(0)
160     self.basis_SelectBox.SetSelection(0)
161     self.regarding_SelectBox.SetSelection(0)
162 nino.borges 518
163 nino.borges 551 class SettingsPage(wx.Panel):
164     '''The settings notebook tab'''
165     def __init__(self,parent,text):
166     wx.Panel.__init__(self, parent)
167     t = wx.StaticText(self, -1, text, (60,60))
168     settingsLoader = SettingGenerator('winpbx.sts')
169     rawObj = settingsLoader.load_obj()
170    
171     documentTypeContents = self.ConvertContents(rawObj['documentTypeList'])
172     regardingListContents = self.ConvertContents(rawObj['regardingList'])
173     adendumListContents = self.ConvertContents(rawObj['adendumList'])
174     basisListContents = self.ConvertContents(rawObj['basisList'])
175    
176     self.documentTypeTextCtrl = wx.TextCtrl(self,-1,documentTypeContents,size=(505, 90),style=wx.TE_MULTILINE)
177     self.regardingTextCtrl = wx.TextCtrl(self,-1,regardingListContents,size=(505, 90),style=wx.TE_MULTILINE)
178     self.adendumTextCtrl = wx.TextCtrl(self,-1,adendumListContents,size=(505, 90),style=wx.TE_MULTILINE)
179     self.basisTextCtrl = wx.TextCtrl(self,-1,basisListContents,size=(505, 90),style=wx.TE_MULTILINE)
180    
181     documentTypeStaticBox = wx.StaticBox(self,-1,'Document Type List')
182     documentTypeSizer = wx.StaticBoxSizer(documentTypeStaticBox)
183     documentTypeSizer.Add(self.documentTypeTextCtrl,0,wx.ALL,10)
184    
185     regardingStaticBox = wx.StaticBox(self,-1,'Regarding List')
186     regardingSizer = wx.StaticBoxSizer(regardingStaticBox)
187     regardingSizer.Add(self.regardingTextCtrl,0,wx.ALL,10)
188    
189    
190     adendumStaticBox = wx.StaticBox(self,-1,'Draft List')
191     adendumSizer = wx.StaticBoxSizer(adendumStaticBox)
192     adendumSizer.Add(self.adendumTextCtrl,0,wx.ALL,10)
193    
194    
195     basisStaticBox = wx.StaticBox(self,-1,'Basis List')
196     basisSizer = wx.StaticBoxSizer(basisStaticBox)
197     basisSizer.Add(self.basisTextCtrl,0,wx.ALL,10)
198    
199     mainSizer = wx.BoxSizer(wx.VERTICAL)
200     mainSizer.Add(documentTypeSizer, 0, wx.ALL, 5)
201     mainSizer.Add(basisSizer, 0, wx.ALL, 5)
202     mainSizer.Add(adendumSizer, 0, wx.ALL, 5)
203     mainSizer.Add(regardingSizer, 0, wx.ALL, 5)
204    
205     self.saveButton = wx.Button(self, wx.ID_OK,'Save')
206     self.saveButton.Disable()
207     mainSizer.Add(self.saveButton,0,wx.ALIGN_CENTER|wx.ALL,5)
208    
209     self.SetSizer(mainSizer)
210    
211     self.Bind(wx.EVT_TEXT, self.OnFormChanged, self.documentTypeTextCtrl)
212     self.Bind(wx.EVT_TEXT, self.OnFormChanged, self.regardingTextCtrl)
213     self.Bind(wx.EVT_TEXT, self.OnFormChanged, self.adendumTextCtrl)
214     self.Bind(wx.EVT_TEXT, self.OnFormChanged, self.basisTextCtrl)
215     self.Bind(wx.EVT_BUTTON, self.WriteContents, self.saveButton)
216    
217     def ConvertContents(self,contentList):
218     '''Will Convert a list of contents to a string of those contents per line'''
219     newContents = ""
220     for i in contentList:
221     if i:
222     newContents = newContents + i + "\n"
223     return newContents
224    
225     def PrepContentsForSave(self,contentString):
226     '''Will take the values in the controls content and add an empty value.'''
227     newList = ['']
228     contentString = contentString.split("\n")
229     for i in contentString:
230     if i:
231     newList.append(i)
232     return newList
233    
234    
235     def WriteContents(self,event):
236     '''Will write the values to the text file and also change the values in main program'''
237     print "Saving values..."
238     message = "Updating selection values. One moment please..."
239     busy = PBI.PyBusyInfo(message, parent=self, title="MCP: System Busy.")
240     payload = {'documentTypeList':self.PrepContentsForSave(self.documentTypeTextCtrl.GetValue()),'basisList':self.PrepContentsForSave(self.basisTextCtrl.GetValue()),'regardingList':self.PrepContentsForSave(self.regardingTextCtrl.GetValue()),'adendumList':self.PrepContentsForSave(self.adendumTextCtrl.GetValue())}
241     sg = SettingGenerator('winpbx.sts')
242     sg.save_obj(payload)
243     del busy
244     print "Values saved."
245     doneDlg = wx.MessageDialog(self, "All selection entries saved sucessfully.\nPlease restart program for the update to take effect.", "Saved",wx.OK, wx.DefaultPosition)
246     doneDlg.ShowModal()
247     doneDlg.Destroy()
248     self.saveButton.Disable()
249    
250     def OnFormChanged(self,event):
251     self.saveButton.Enable()
252 ninoborges 8
253 nino.borges 551
254    
255     class AboutPage(wx.Panel):
256     '''The about notebook tab'''
257     def __init__(self,parent):
258     wx.Panel.__init__(self, parent)
259 nino.borges 556 text = '''
260     Privilege Description Assistant is a program that automates and normalizes the sometimes long process
261     of creating and adding privilege descriptions to your databases. This program is unique because it works
262     with any privilege system, whether you use an actual database or track your descriptions in a
263     spreadsheet or other document.
264 nino.borges 551
265 nino.borges 556 This program was created by
266     Emanuel Borges
267     For questions, comments or to update this program, please visit
268     http://ninosystems.com
269    
270     Privilege Description Assistant
271     Copyright (c) 2009 - 2014 Emanuel Borges
272     All rights reserved
273     (Nino.Borges@gmail.com)
274     '''
275     aboutMessage = wx.StaticText(self,-1,text)
276    
277     mainSizer = wx.BoxSizer(wx.VERTICAL)
278     mainSizer.Add(aboutMessage, 0, wx.ALIGN_CENTER|wx.ALL, 80)
279     self.SetSizer(mainSizer)
280    
281 nino.borges 551
282    
283    
284    
285     class MyFrame(wx.Frame):
286     def __init__(self, parent, ID, title, pos=wx.DefaultPosition):
287    
288     wx.Frame.__init__(self, parent, ID, title, pos, size =(570,670),style=wx.DEFAULT_FRAME_STYLE|wx.STAY_ON_TOP)
289     self.panel = wx.Panel(self,-1)
290     self.notebook = wx.Notebook(self.panel)
291    
292     tab1 = MainPage(self.notebook)
293     tab2 = SettingsPage(self.notebook,"test")
294     tab3 = AboutPage(self.notebook)
295    
296     self.notebook.AddPage(tab1, "Home")
297     self.notebook.AddPage(tab2, "Settings")
298     self.notebook.AddPage(tab3, "About")
299    
300    
301     sizer = wx.BoxSizer()
302     sizer.Add(self.notebook, 1, wx.EXPAND)
303     self.panel.SetSizer(sizer)
304     #
305     ##documentTypeList = ['','Email','Presentation','Memorandum','Spreadsheet']
306     ##documentTypeList = ['','Email', 'Email chain', 'Presentation', 'Draft correspondence', 'Draft agreement',
307     ## 'Executed correspondence', 'Executed agreement', 'Spreadsheet']
308     #documentTypeList = ['','Letter','Internal memorandum','Memorandum','Email','Chart','Report','Presentation','Agreement']
309     #
310     ##basisList = ['','sent to legal counsel requesting legal advice',
311     ## 'between attorney-retained consultants',
312     ## 'from legal counsel',
313     ## 'from attorney-retained consultants providing advice',
314     ## 'to attorney-retained consultants',
315     ## 'sent to legal counsel requesting legal review and comment',
316     ## 'sent to legal counsel for the purpose of obtaining legal advice',
317     ## 'forwarding and discussing email providing advice from legal counsel []',
318     ## 'referencing legal advice from legal counsel [] ',
319     ## 'designated "Attorney Client Privileged"',
320     ## ]
321     ##basisList = ['','with', 'from counsel', 'to counsel', 'forwarding email from counsel', 'forwarding email chain with counsel', 'forwarding email chain to counsel']
322     #basisList = ['','by counsel','from counsel','to counsel','with counsel']
323     #
324     ##regardingList = ['','regarding []']
325     #regardingList = ['','seeking legal advice regarding', 'seeking legal review regarding', 'providing legal advice regarding', 'providing legal review regarding', 'seeking and providing legal advice regarding',
326     # 'referencing legal advice provided by [fill in then delete brackets] regarding', 'forwarding and discussing legal advice provided by [fill in then delete brackets] regarding','seeking information to facilitate the provision of legal advice regarding',
327     # 'providing information to facilitate the provision of legal advice regarding']
328     #
329     ##adendumList = ['',
330     ## 'for purposes of facilitating the provision of legal advice by counsel',
331     ## 'redacted',
332     ## 'and attached to foregoing email',]
333     ##
334     ##adendumList = ['','279 D Street LLC','Bitran Charitable Foundation','Bitran Family LP','Bitran Family Partnership',
335     ## 'Boston Multi-Fam Prop. Dev.','Clearstream Investments','Crepaldi Bitran Charitable Trust','FPG 17 Wensley LLC','FPG Property Acquisition 1',
336     ## 'GMB Capital Partners','Great Pond Mgmt','Isalia Property 1 LLC','Isalia Property Group LLC (fka Fisher)','Lecount Hollow Investments LP',
337     ## 'Marco Bitran 2007 Irr. Fam. Trust','Marco Bitran Family Trust','Sababa Investments','Sabra Inc','Stoney Beach Rev Trust']
338     ##
339     #adendumList = ['','Draft']
340     #
341     #
342     #docType_lbl = wx.StaticText(self.panel, -1, "Document Type : ")
343     #self.docType_SelectBox = wx.Choice(self.panel, -1,(100, 50), choices = documentTypeList)
344     #basis_lbl = wx.StaticText(self.panel, -1, "Basis : ")
345     #self.basis_SelectBox = wx.Choice(self.panel, -1,(100, 50), choices = basisList)
346     #regarding_lbl = wx.StaticText(self.panel, -1, "Regarding : ")
347     #self.regarding_SelectBox = wx.Choice(self.panel, -1,(100, 50), choices = regardingList)
348     #adendum_lbl = wx.StaticText(self.panel, -1, "Draft : ")
349     #self.adendum_SelectBox = wx.Choice(self.panel, -1,(100, 50), choices = adendumList)
350     #
351     #self.privSentanceTextBox = wx.TextCtrl(self.panel,-1,style=wx.TE_MULTILINE, size=(450,100))
352     #
353     #self.CreateBoxesSection()
354     #
355     #mainSizer = wx.BoxSizer(wx.VERTICAL)
356     #mainSizer.Add(adendum_lbl, 0, wx.ALIGN_CENTER|wx.ALL, 5)
357     #mainSizer.Add(self.adendum_SelectBox , 0, wx.ALIGN_CENTER|wx.ALL, 5)
358     #mainSizer.Add(docType_lbl , 0, wx.ALIGN_CENTER|wx.ALL, 5)
359     #mainSizer.Add(self.docType_SelectBox, 0, wx.ALIGN_CENTER|wx.ALL, 5)
360     #mainSizer.Add(basis_lbl, 0, wx.ALIGN_CENTER|wx.ALL, 5)
361     #mainSizer.Add(self.basis_SelectBox, 0, wx.ALIGN_CENTER|wx.ALL, 5)
362     #mainSizer.Add(regarding_lbl, 0, wx.ALIGN_CENTER|wx.ALL, 5)
363     #mainSizer.Add(self.regarding_SelectBox, 0, wx.ALIGN_CENTER|wx.ALL, 5)
364     #
365     #mainSizer.Add(self.privSentanceTextBox, 0, wx.ALIGN_CENTER|wx.ALL, 20)
366     #mainSizer.Add(self.buttonSizer,0, wx.ALL|wx.ALIGN_BOTTOM|wx.ALIGN_CENTER, 10)
367     #self.panel.SetSizer(mainSizer)
368     #
369     #self.Bind(wx.EVT_CHOICE, self.RescanSentance, self.docType_SelectBox)
370     #self.Bind(wx.EVT_CHOICE, self.RescanSentance, self.basis_SelectBox)
371     #self.Bind(wx.EVT_CHOICE, self.RescanSentance, self.regarding_SelectBox)
372     #self.Bind(wx.EVT_CHOICE, self.RescanSentance, self.adendum_SelectBox)
373     #self.Bind(wx.EVT_BUTTON, self.OnProcess, self.oKButton)
374     self.Bind(wx.EVT_BUTTON, self.CloseWindow, tab1.cancelButton)
375    
376     def CloseWindow(self, event):
377     self.Close(True)
378    
379    
380    
381    
382 ninoborges 8 class MyApp(wx.App):
383 nino.borges 551 prgVersion = '1.0.0'
384 ninoborges 8 def OnInit(self):
385 nino.borges 551
386     expireDate = 1434587964 # Just make this 6 months from now. Always put this on your cal for the mwe version.
387     if expireDate > time.time():
388     self.frame = MyFrame(None, -1, "Priv Description Assistant v%s"%self.prgVersion)
389     self.frame.Show(True)
390     self.SetTopWindow(self.frame)
391     return True
392     else:
393     deniedDlg = wx.MessageDialog(None, "A newer version of this program exists. Please visit www.ninosystems.com to upgrade your copy.", "Please upgrade.",wx.OK, wx.DefaultPosition)
394     deniedDlg.ShowModal()
395     return False
396    
397    
398 ninoborges 8
399    
400     if __name__ == '__main__':
401     app = MyApp(0)
402     app.MainLoop()