-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathAquariusUploadDialog2.py
117 lines (87 loc) · 3.65 KB
/
AquariusUploadDialog2.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
# All works in this code have been curated by ECCC and licensed under the GNU General Public License v3.0.
# Read more: https://www.gnu.org/licenses/gpl-3.0.en.html
import wx
import os
class AquariusUploadDialog2(wx.Dialog):
def __init__(self, mode, dir, manager, *args, **kwargs):
super(AquariusUploadDialog2, self).__init__(*args, **kwargs)
self.manager = manager
self.mode = mode
self.dir = dir if dir is not None else str(os.getcwd())
self.header = "Save and Upload"
self.desc = "All eHSN files must be saved at the time of upload. Where would you like this file to be saved?"
self.browseButtonDesc = "Browse"
self.cancelButtonDesc = "Cancel"
self.uploadSaveButtonDesc = "OK"
self.browseTitleLbl = "Choose directory for xml and pdf file"
self.SetSize((600, 230))
self.InitUI()
def InitUI(self):
if self.mode == "DEBUG":
print("Aquarius Upload Dialog 2")
self.layoutSizer = wx.BoxSizer(wx.VERTICAL)
headerTxt = wx.StaticText(self, label=self.header)
font = wx.Font(13, wx.DECORATIVE, wx.NORMAL, wx.BOLD)
headerTxt.SetFont(font)
descTxt = wx.StaticText(self, label=self.desc)
font2 = wx.Font(13, wx.ROMAN, wx.NORMAL, wx.NORMAL)
descTxt.SetFont(font2)
browsePanel = wx.Panel(self, style=wx.BORDER_NONE)
browseSizer = wx.BoxSizer(wx.HORIZONTAL)
browsePanel.SetSizer(browseSizer)
self.browseCtrl = wx.TextCtrl(browsePanel, style=wx.TE_READONLY)
self.browseCtrl.SetValue(self.dir)
browseBtn = wx.Button(browsePanel, label=self.browseButtonDesc)
browseBtn.Bind(wx.EVT_BUTTON, self.OnBrowse)
browseSizer.Add(self.browseCtrl, 2, wx.EXPAND)
browseSizer.Add(browseBtn, 1, wx.EXPAND)
uploadPanel = wx.Panel(self, style=wx.BORDER_NONE)
uploadSizer = wx.BoxSizer(wx.HORIZONTAL)
uploadPanel.SetSizer(uploadSizer)
self.uploadBtn = wx.Button(uploadPanel, label=self.uploadSaveButtonDesc)
cancelBtn = wx.Button(uploadPanel, label=self.cancelButtonDesc)
cancelBtn.Bind(wx.EVT_BUTTON, self.OnCancel)
uploadSizer.Add(self.uploadBtn, 1, wx.EXPAND)
uploadSizer.Add(cancelBtn, 1, wx.EXPAND)
self.layoutSizer.Add(headerTxt, 0, wx.EXPAND)
self.layoutSizer.Add((-1, -1), 1)
self.layoutSizer.Add(descTxt, 1, wx.EXPAND)
self.layoutSizer.Add((-1, -1), 1)
self.layoutSizer.Add(browsePanel, 0, wx.EXPAND)
self.layoutSizer.Add(uploadPanel, 0, wx.EXPAND)
self.SetSizer(self.layoutSizer)
if self.manager is not None:
self.uploadBtn.Bind(wx.EVT_BUTTON, self.manager.OnChoosePress)
def OnCancel(self, event):
self.Destroy()
def OnBrowse(self, e):
fileOpenDialog = wx.DirDialog(self, self.browseTitleLbl, self.dir)
if fileOpenDialog.ShowModal() == wx.ID_CANCEL:
fileOpenDialog.Destroy()
return
self.dir = fileOpenDialog.GetPath()
self.browseCtrl.SetValue(self.dir)
self.layoutSizer.Layout()
self.Update()
self.Refresh()
def GetPath(self):
return self.dir
def GetUploadBtn(self):
return self.uploadBtn
def main():
app = wx.App()
AUD = AquariusUploadDialog2("DEBUG", None, None, None, title="Upload Field Visit to Aquarius")
val = True
while val:
re = AUD.ShowModal()
if re == wx.ID_YES:
print("YES")
else:
print("Cancel")
val = False
AUD.Destroy()
print("TEST")
AUD.Destroy()
app.MainLoop()
if __name__ == '__main__':
main()