-
Notifications
You must be signed in to change notification settings - Fork 0
/
gui.py
237 lines (162 loc) · 7.28 KB
/
gui.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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
# coding: utf-8
# In[5]:
import os
import wx
import wx.lib.agw.multidirdialog as MDD
from mtgMgr import dataMgr
from mtgMgr import treasMgr
from bloombergBooks import books as books
from washSales import washMgr
wildcard = "Python source (*.py)|*.py|" "All files (*.*)|*.*"
# In[6]:
class Example(wx.Frame):
def __init__(self, parent, title, *args, **kw):
super(Example, self).__init__(parent, title=title)
self.currentDirectory = os.getcwd()
panel = wx.Panel(self)
sizer = wx.GridBagSizer(5, 5)
#----------------------------------------------------
text1 = wx.StaticText(panel, label="Compliance Manager")
sizer.Add(text1, pos=(0, 0), flag=wx.TOP|wx.LEFT|wx.BOTTOM,
border=15)
icon = wx.StaticBitmap(panel, bitmap=wx.Bitmap(''))
sizer.Add(icon, pos=(0, 4), flag=wx.TOP|wx.RIGHT|wx.ALIGN_RIGHT,
border=5)
line = wx.StaticLine(panel)
sizer.Add(line, pos=(1, 0), span=(1, 5),
flag=wx.EXPAND|wx.BOTTOM, border=10)
#----------------------------------------------------
#text next to date box
dateText = wx.StaticText(panel, label="Date use YYYY-MM-DD Format")
sizer.Add(dateText, pos=(2, 0), flag=wx.LEFT, border=10)
#positing in contorl panel
self.tc1 = wx.TextCtrl(panel)
sizer.Add(self.tc1, pos=(2, 1), span=(1, 3), flag=wx.TOP|wx.EXPAND)
#----------------------------------------------------
#File Lcoation
fileLocText = wx.StaticText(panel, label="File Location")
sizer.Add(fileLocText, pos=(3, 0), flag=wx.LEFT|wx.TOP, border=10)
#Text box next to file location
self.tc2 = wx.TextCtrl(panel, value='C:\\')
sizer.Add(self.tc2, pos=(3, 1), span=(1, 3), flag=wx.TOP|wx.EXPAND,
border=5)
button1 = wx.Button(panel, label="Browse")
sizer.Add(button1, pos=(3, 4), flag=wx.TOP|wx.RIGHT, border=5)
button1.Bind(wx.EVT_BUTTON, self.onDir)
#---------------------------------------------------
text4 = wx.StaticText(panel, label="Save Location")
sizer.Add(text4, pos=(4, 0), flag=wx.TOP|wx.LEFT, border=10)
self.tc3 = wx.TextCtrl(panel)
sizer.Add(self.tc3, pos=(4, 1), span=(1, 3),
flag=wx.TOP|wx.EXPAND, border=5)
button2 = wx.Button(panel, label="Browse...")
sizer.Add(button2, pos=(4, 4), flag=wx.TOP|wx.RIGHT, border=5)
button2.Bind(wx.EVT_BUTTON, self.onDirSave)
#----------------------------------------------------
button3 = wx.Button(panel, label='Help')
sizer.Add(button3, pos=(7, 0), flag=wx.LEFT, border=10)
button4 = wx.Button(panel, label="Ok")
button4.Bind(wx.EVT_BUTTON, self.onOk)
sizer.Add(button4, pos=(7, 3))
#----------------------------------------------------
self.radio1 = wx.RadioButton(panel, label = 'Mortgage Best Ex')
sizer.Add(self.radio1, pos=(6,1))
#-----------------------------------------------------
self.radio2 = wx.RadioButton(panel, label = 'Treasury Best Ex')
sizer.Add(self.radio2, pos=(6,2))
#-------------
self.radio3 = wx.RadioButton(panel, label = 'Wash Sale Report Bloomberg')
sizer.Add(self.radio3, pos=(6,3))
sizer.AddGrowableCol(2)
panel.SetSizer(sizer)
sizer.Fit(self)
self.Bind(wx.EVT_CLOSE, self.OnCloseWindow)
self.SetTitle('Compliance Manager')
self.Centre()
#path = onDir(self)
#def fileLocation(self, e):
def OnCloseWindow(self, e):
dial = wx.MessageDialog(None, 'Are you sure to quit?', 'Question',
wx.YES_NO | wx.NO_DEFAULT | wx.ICON_QUESTION)
ret = dial.ShowModal()
if ret == wx.ID_YES:
self.Destroy()
else:
e.Veto()
def onDir(self, event):
"""
Show the DirDialog and print the user's choice to stdout
"""
dlg = wx.DirDialog(self, "Choose a directory:",
style=wx.DD_DEFAULT_STYLE
#| wx.DD_DIR_MUST_EXIST
#| wx.DD_CHANGE_DIR
)
if dlg.ShowModal() == wx.ID_OK:
path = dlg.GetPath()
self.tc2.SetValue(path)
def onDirSave(self, event):
"""
Show the DirDialog and print the user's choice to stdout
"""
dlg = wx.DirDialog(self, "Choose a directory:",
style=wx.DD_DEFAULT_STYLE
#| wx.DD_DIR_MUST_EXIST
#| wx.DD_CHANGE_DIR
)
if dlg.ShowModal() == wx.ID_OK:
path = dlg.GetPath()
self.tc3.SetValue(path)
def onOk(self, event):
if self.radio1.GetValue() == True:
dlg = wx.MessageDialog(self, "Run Mortage Best Ex Rept?",
style=wx.DD_DEFAULT_STYLE
#| wx.DD_DIR_MUST_EXIST
#| wx.DD_CHANGE_DIR
)
if dlg.ShowModal() == wx.ID_OK:
date = self.tc1.GetValue()
bloomy = self.tc2.GetValue() + '\\'
save = self.tc3.GetValue()+ "\\"
mtgMgr = dataMgr(date, bloomy, save)
mtgMgr.save()
elif self.radio2.GetValue() == True:
dlg = wx.MessageDialog(self, "Run Treasury Best Ex Rept",
style=wx.DD_DEFAULT_STYLE
#| wx.DD_DIR_MUST_EXIST
#| wx.DD_CHANGE_DIR
)
if dlg.ShowModal() == wx.ID_OK:
date = self.tc1.GetValue()
bloomy = self.tc2.GetValue()+"\\"
save = self.tc3.GetValue()+"\\"
treasMgr1 = treasMgr(date, bloomy, save)
treasMgr1.save()
elif self.radio3.GetValue() == True:
dlg = wx.MessageDialog(self, "Run Wash Report?",
style=wx.DD_DEFAULT_STYLE
#| wx.DD_DIR_MUST_EXIST
#| wx.DD_CHANGE_DIR
)
if dlg.ShowModal() == wx.ID_OK:
date = self.tc1.GetValue()
bloomy = self.tc2.GetValue()+"\\"
save = self.tc3.GetValue()+"\\"
wash = washMgr(bloomy, save, date)
wash.save()
elif OSError:
dlg = wx.MessageDialog(self, "File Location Incorrect",
style = wx.DD_DEFAULT_STYLE)
dlg.ShowModal()
else:
dlg = wx.MessageDialog(self, "choose a report type",
style = wx.DD_DEFAULT_STYLE)
dlg.ShowModal()
def main():
app = wx.App()
ex = Example(None, title="Compliance manager")
ex.Show()
app.MainLoop()
if __name__ == '__main__':
main()
# In[ ]: