ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/ns_dev/Python/NinoCode/Active_prgs/MCP/Trunk/MCP_CopyUp_Request_UI.py
Revision: 8
Committed: Sat May 5 04:21:19 2012 UTC (13 years, 10 months ago) by ninoborges
Content type: text/x-python
Original Path: Python/NinoCode/Active_prgs/MCP/MCP_CopyUp_Request_UI.py
File size: 8697 byte(s)
Log Message:
Initial Import

File Contents

# User Rev Content
1 ninoborges 8 """
2    
3     MCP_CopyUp_Request_UI
4    
5     Created by
6     Emanuel Borges
7     10.25.2010
8    
9     This is the GUI to the MCP_CopyUp_Request program.
10    
11     """
12    
13     import wx, MCP_Lib, MCP_CopyUp_Request,os
14     import wx.lib.filebrowsebutton as filebrowse
15    
16     class MyFrame(wx.Frame):
17     def __init__(self, parent, ID, title, pos=wx.DefaultPosition):
18     wx.Frame.__init__(self, parent, ID, title, pos, size =(585,430))
19     self.panel = wx.Panel(self,-1)
20     #self.panel.SetBackgroundColour("yellow green")
21     casesListStaticText = wx.StaticText(self.panel, -1, "Select Case: ",wx.DefaultPosition)
22     casesList,casesDir = MCP_Lib.GetCaseList()
23     self.casesListChoice = wx.Choice(self.panel, -1, wx.DefaultPosition, choices=casesList)
24     platformStaticText = wx.StaticText(self.panel, -1, "Select Platform:",wx.DefaultPosition)
25     platformChoices = ["Concordance DIS","Concordance LN","Relativity"]
26     self.platformListChoice = wx.Choice(self.panel, -1, wx.DefaultPosition, choices=platformChoices)
27     workDirStaticText = wx.StaticText(self.panel, -1, "Select Work Dir:",wx.DefaultPosition)
28     self.workDirControl = wx.TextCtrl(self.panel,-1,os.path.join(os.environ.get("USERPROFILE"),"Desktop\\Working"), size=(296,-1))
29     workDirBrowseButton = wx.Button(self.panel, -1, "Browse", (10, 10))
30    
31    
32     self.radio1 = wx.RadioButton(self.panel, -1, 'Individual File',style=wx.RB_GROUP)
33     self.fileBowserControl = wx.TextCtrl(self.panel, -1,size=(296,-1))
34     self.fileBowserButton = wx.Button(self.panel, -1, "Browse", (10, 10))
35    
36     self.requestAssistanceCheckBox = wx.CheckBox(self.panel,-1,": Request Data Analyst Assistance")
37     self.requestAssistanceCheckBox.Enable(False) ## Change me when you go live with this service.
38    
39     self.radio2 = wx.RadioButton(self.panel, -1, 'Entire folder of Files')
40     self.dirBowserControl = wx.TextCtrl(self.panel, -1, size=(296,-1))
41     self.dirBowserButton = wx.Button(self.panel, -1, "Browse", (10, 10))
42     self.dirBowserControl.Enable(False)
43     self.dirBowserButton.Enable(False)
44    
45    
46     self.CreateBoxesSection()
47     copyUpTypeStaticBox = wx.StaticBox(self.panel, -1, 'Copy Up:')
48     copyUpTypeStaticBoxSizer = wx.StaticBoxSizer(copyUpTypeStaticBox, wx.VERTICAL)
49    
50     radio1Sizer = wx.FlexGridSizer(1,3,10,10)
51     radio1Sizer.Add(self.radio1, 0, 0)
52     radio1Sizer.Add(self.fileBowserControl, 0)
53     radio1Sizer.Add(self.fileBowserButton, 0)
54     copyUpTypeStaticBoxSizer.Add(radio1Sizer, 0, wx.ALL|wx.ALIGN_LEFT,20)
55     radio2Sizer = wx.FlexGridSizer(1,3,10,10)
56     radio2Sizer.Add(self.radio2, 0)
57     radio2Sizer.Add(self.dirBowserControl, 0)
58     radio2Sizer.Add(self.dirBowserButton, 0)
59     copyUpTypeStaticBoxSizer.Add(radio2Sizer, 0, wx.ALL|wx.ALIGN_LEFT,20)
60    
61     casesSizer = wx.FlexGridSizer(2,2,15,5)
62     casesSizer.Add(casesListStaticText)
63     casesSizer.Add(self.casesListChoice)
64     casesSizer.Add(platformStaticText)
65     casesSizer.Add(self.platformListChoice)
66     #casesSizer = wx.BoxSizer(wx.HORIZONTAL)
67     #casesSizer.Add(casesListStaticText,0,wx.ALL,5)
68     #casesSizer.Add(self.casesListChoice,0,wx.ALL,5)
69     #casesSizer.Add(platformStaticText,0,wx.ALL,5)
70     #casesSizer.Add(self.platformListChoice,0,wx.ALL,5)
71     workDirSizer = wx.BoxSizer(wx.HORIZONTAL)
72     workDirSizer.Add(workDirStaticText,0,wx.ALL,5)
73     workDirSizer.Add(self.workDirControl,0,wx.ALL,5)
74     workDirSizer.Add(workDirBrowseButton,0,wx.ALL,5)
75     mainSizer = wx.BoxSizer(wx.VERTICAL)
76     mainSizer.Add(casesSizer,0,wx.ALL, 20)
77     mainSizer.Add(workDirSizer,0,wx.ALL, 10)
78     mainSizer.Add(copyUpTypeStaticBoxSizer, 0, wx.ALL, 10)
79     mainSizer.Add(self.requestAssistanceCheckBox,0,wx.ALL|wx.ALIGN_CENTER,5)
80     mainSizer.Add(self.buttonSizer,0, wx.ALL|wx.ALIGN_BOTTOM|wx.ALIGN_CENTER, 10)
81    
82     self.panel.SetSizer(mainSizer)
83     self.Bind(wx.EVT_RADIOBUTTON, self.OnRadio, self.radio1)
84     self.Bind(wx.EVT_RADIOBUTTON, self.OnRadio, self.radio2)
85     self.Bind(wx.EVT_BUTTON, self.OnBrowseClick, workDirBrowseButton)
86     self.Bind(wx.EVT_BUTTON, self.OnBrowseClick, self.fileBowserButton)
87     self.Bind(wx.EVT_BUTTON, self.OnBrowseClick, self.dirBowserButton)
88     self.Bind(wx.EVT_BUTTON, self.OnProcess, self.oKButton)
89     self.Bind(wx.EVT_BUTTON, self.CloseWindow, self.cancelButton)
90    
91     def OnRadio(self,event):
92     radioObj = event.GetEventObject()
93     selection = radioObj.GetLabel()
94     if selection == "Individual File":
95     self.fileBowserControl.Enable(True)
96     self.fileBowserButton.Enable(True)
97    
98     self.dirBowserControl.Enable(False)
99     self.dirBowserButton.Enable(False)
100     self.dirBowserControl.SetValue("")
101     else:
102     self.fileBowserControl.Enable(False)
103     self.fileBowserButton.Enable(False)
104     self.fileBowserControl.SetValue("")
105    
106     self.dirBowserControl.Enable(True)
107     self.dirBowserButton.Enable(True)
108    
109     #if self.selectedText:
110     # self.selectedText.Enable(False)
111     #radioSelected = event.GetEventObject()
112     #text = self.texts[radioSelected.GetLabel()]
113     #text.Enable(True)
114     #self.selectedText = text
115    
116     def OnBrowseClick(self,event):
117     eventCode = event.GetId()
118     #print eventCode
119     if eventCode == -209:
120     dlg = wx.DirDialog(self, message = "Working Directory Path: ", defaultPath = os.path.join(os.environ.get("USERPROFILE"),"Desktop\\Working"))
121     if dlg.ShowModal() == wx.ID_OK:
122     dirPath = dlg.GetPath()
123     dlg.Destroy()
124     self.workDirControl.SetValue(dirPath)
125     elif eventCode == -212:
126     dlg = wx.FileDialog(self, message="Select file to copy up:",defaultDir=os.path.join(os.environ.get("USERPROFILE"),"Desktop\\Working"), defaultFile="",wildcard= "*.*",style=wx.OPEN | wx.CHANGE_DIR)
127     #dlg = wx.FileDialog(self, message = "Select directory to copy up: ", defaultPath = os.path.join(os.environ.get("USERPROFILE"),"Desktop\\Working"))
128     if dlg.ShowModal() == wx.ID_OK:
129     filePath = dlg.GetPath()
130     dlg.Destroy()
131     self.fileBowserControl.SetValue(filePath)
132     elif eventCode == -216:
133     dlg = wx.DirDialog(self, message = "Select directory to copy up:", defaultPath = os.path.join(os.environ.get("USERPROFILE"),"Desktop\\Working"))
134     if dlg.ShowModal() == wx.ID_OK:
135     dirPath = dlg.GetPath()
136     dlg.Destroy()
137     self.dirBowserControl.SetValue(dirPath)
138    
139     def CreateBoxesSection(self):
140     self.oKButton = wx.Button(self.panel, wx.ID_OK)
141     self.oKButton.SetDefault()
142     self.oKButton.SetSize(self.oKButton.GetBestSize())
143     self.cancelButton = wx.Button(self.panel, wx.ID_CANCEL)
144     self.cancelButton.SetSize(self.cancelButton.GetBestSize())
145     self.buttonSizer = wx.BoxSizer(wx.HORIZONTAL)
146     self.buttonSizer.Add(self.oKButton,0,wx.ALL,10)
147     self.buttonSizer.Add(self.cancelButton,0,wx.ALL,10)
148    
149     def CloseWindow(self, event):
150     self.Close(True)
151    
152     def OnProcess(self, event):
153     caseName = self.casesListChoice.GetStringSelection()
154     platform = self.platformListChoice.GetStringSelection()
155     workDir = self.workDirControl.GetValue()
156     #workDir = r"E:"
157     if self.radio1.GetValue():
158     startSelection = self.fileBowserControl.GetValue()
159     else:
160     startSelection = self.dirBowserControl.GetValue()
161     #startSelection = r"C:\Documents and Settings\eborges\Desktop\Working\Misc_Documents.zip"
162     self.Show(False)
163     #print "workdir is %s"%workDir
164     MCP_CopyUp_Request.Process(caseName, workDir, startSelection, platform)
165    
166     #diag = wx.MessageDialog(self,"All Items processed and copied!!", "Complete",wx.OK | wx.ICON_INFORMATION)
167     #diag.ShowModal()
168     #diag.Destroy()
169     self.Destroy()
170    
171    
172    
173    
174    
175     class MyApp(wx.App):
176     def OnInit(self):
177     prgVersion = MCP_Lib.GetMCPVersion()
178     self.frame = MyFrame(None, -1, "MCP Copy Up Request %s"%prgVersion)
179     self.frame.Show(True)
180     self.SetTopWindow(self.frame)
181     return True
182    
183    
184     if __name__ == '__main__':
185     app = MyApp(0)
186     app.MainLoop()