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: 551
Committed: Wed Jun 18 02:36:18 2014 UTC (11 years, 9 months ago) by nino.borges
Content type: text/x-python
File size: 20333 byte(s)
Log Message:
Finished the settings class that allows you to change the sentance values from the settings tab. Also added the code to ask for upgrade.

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    
260    
261    
262    
263    
264     class MyFrame(wx.Frame):
265     def __init__(self, parent, ID, title, pos=wx.DefaultPosition):
266    
267     wx.Frame.__init__(self, parent, ID, title, pos, size =(570,670),style=wx.DEFAULT_FRAME_STYLE|wx.STAY_ON_TOP)
268     self.panel = wx.Panel(self,-1)
269     self.notebook = wx.Notebook(self.panel)
270    
271     tab1 = MainPage(self.notebook)
272     tab2 = SettingsPage(self.notebook,"test")
273     tab3 = AboutPage(self.notebook)
274    
275     self.notebook.AddPage(tab1, "Home")
276     self.notebook.AddPage(tab2, "Settings")
277     self.notebook.AddPage(tab3, "About")
278    
279    
280     sizer = wx.BoxSizer()
281     sizer.Add(self.notebook, 1, wx.EXPAND)
282     self.panel.SetSizer(sizer)
283     #
284     ##documentTypeList = ['','Email','Presentation','Memorandum','Spreadsheet']
285     ##documentTypeList = ['','Email', 'Email chain', 'Presentation', 'Draft correspondence', 'Draft agreement',
286     ## 'Executed correspondence', 'Executed agreement', 'Spreadsheet']
287     #documentTypeList = ['','Letter','Internal memorandum','Memorandum','Email','Chart','Report','Presentation','Agreement']
288     #
289     ##basisList = ['','sent to legal counsel requesting legal advice',
290     ## 'between attorney-retained consultants',
291     ## 'from legal counsel',
292     ## 'from attorney-retained consultants providing advice',
293     ## 'to attorney-retained consultants',
294     ## 'sent to legal counsel requesting legal review and comment',
295     ## 'sent to legal counsel for the purpose of obtaining legal advice',
296     ## 'forwarding and discussing email providing advice from legal counsel []',
297     ## 'referencing legal advice from legal counsel [] ',
298     ## 'designated "Attorney Client Privileged"',
299     ## ]
300     ##basisList = ['','with', 'from counsel', 'to counsel', 'forwarding email from counsel', 'forwarding email chain with counsel', 'forwarding email chain to counsel']
301     #basisList = ['','by counsel','from counsel','to counsel','with counsel']
302     #
303     ##regardingList = ['','regarding []']
304     #regardingList = ['','seeking legal advice regarding', 'seeking legal review regarding', 'providing legal advice regarding', 'providing legal review regarding', 'seeking and providing legal advice regarding',
305     # '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',
306     # 'providing information to facilitate the provision of legal advice regarding']
307     #
308     ##adendumList = ['',
309     ## 'for purposes of facilitating the provision of legal advice by counsel',
310     ## 'redacted',
311     ## 'and attached to foregoing email',]
312     ##
313     ##adendumList = ['','279 D Street LLC','Bitran Charitable Foundation','Bitran Family LP','Bitran Family Partnership',
314     ## 'Boston Multi-Fam Prop. Dev.','Clearstream Investments','Crepaldi Bitran Charitable Trust','FPG 17 Wensley LLC','FPG Property Acquisition 1',
315     ## 'GMB Capital Partners','Great Pond Mgmt','Isalia Property 1 LLC','Isalia Property Group LLC (fka Fisher)','Lecount Hollow Investments LP',
316     ## 'Marco Bitran 2007 Irr. Fam. Trust','Marco Bitran Family Trust','Sababa Investments','Sabra Inc','Stoney Beach Rev Trust']
317     ##
318     #adendumList = ['','Draft']
319     #
320     #
321     #docType_lbl = wx.StaticText(self.panel, -1, "Document Type : ")
322     #self.docType_SelectBox = wx.Choice(self.panel, -1,(100, 50), choices = documentTypeList)
323     #basis_lbl = wx.StaticText(self.panel, -1, "Basis : ")
324     #self.basis_SelectBox = wx.Choice(self.panel, -1,(100, 50), choices = basisList)
325     #regarding_lbl = wx.StaticText(self.panel, -1, "Regarding : ")
326     #self.regarding_SelectBox = wx.Choice(self.panel, -1,(100, 50), choices = regardingList)
327     #adendum_lbl = wx.StaticText(self.panel, -1, "Draft : ")
328     #self.adendum_SelectBox = wx.Choice(self.panel, -1,(100, 50), choices = adendumList)
329     #
330     #self.privSentanceTextBox = wx.TextCtrl(self.panel,-1,style=wx.TE_MULTILINE, size=(450,100))
331     #
332     #self.CreateBoxesSection()
333     #
334     #mainSizer = wx.BoxSizer(wx.VERTICAL)
335     #mainSizer.Add(adendum_lbl, 0, wx.ALIGN_CENTER|wx.ALL, 5)
336     #mainSizer.Add(self.adendum_SelectBox , 0, wx.ALIGN_CENTER|wx.ALL, 5)
337     #mainSizer.Add(docType_lbl , 0, wx.ALIGN_CENTER|wx.ALL, 5)
338     #mainSizer.Add(self.docType_SelectBox, 0, wx.ALIGN_CENTER|wx.ALL, 5)
339     #mainSizer.Add(basis_lbl, 0, wx.ALIGN_CENTER|wx.ALL, 5)
340     #mainSizer.Add(self.basis_SelectBox, 0, wx.ALIGN_CENTER|wx.ALL, 5)
341     #mainSizer.Add(regarding_lbl, 0, wx.ALIGN_CENTER|wx.ALL, 5)
342     #mainSizer.Add(self.regarding_SelectBox, 0, wx.ALIGN_CENTER|wx.ALL, 5)
343     #
344     #mainSizer.Add(self.privSentanceTextBox, 0, wx.ALIGN_CENTER|wx.ALL, 20)
345     #mainSizer.Add(self.buttonSizer,0, wx.ALL|wx.ALIGN_BOTTOM|wx.ALIGN_CENTER, 10)
346     #self.panel.SetSizer(mainSizer)
347     #
348     #self.Bind(wx.EVT_CHOICE, self.RescanSentance, self.docType_SelectBox)
349     #self.Bind(wx.EVT_CHOICE, self.RescanSentance, self.basis_SelectBox)
350     #self.Bind(wx.EVT_CHOICE, self.RescanSentance, self.regarding_SelectBox)
351     #self.Bind(wx.EVT_CHOICE, self.RescanSentance, self.adendum_SelectBox)
352     #self.Bind(wx.EVT_BUTTON, self.OnProcess, self.oKButton)
353     self.Bind(wx.EVT_BUTTON, self.CloseWindow, tab1.cancelButton)
354    
355     def CloseWindow(self, event):
356     self.Close(True)
357    
358    
359    
360    
361 ninoborges 8 class MyApp(wx.App):
362 nino.borges 551 prgVersion = '1.0.0'
363 ninoborges 8 def OnInit(self):
364 nino.borges 551
365     expireDate = 1434587964 # Just make this 6 months from now. Always put this on your cal for the mwe version.
366     if expireDate > time.time():
367     self.frame = MyFrame(None, -1, "Priv Description Assistant v%s"%self.prgVersion)
368     self.frame.Show(True)
369     self.SetTopWindow(self.frame)
370     return True
371     else:
372     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)
373     deniedDlg.ShowModal()
374     return False
375    
376    
377 ninoborges 8
378    
379     if __name__ == '__main__':
380     app = MyApp(0)
381     app.MainLoop()