| 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 |
nino.borges |
189 |
#casesList,casesDir = MCP_Lib.GetCaseList()
|
| 23 |
|
|
self.myCases, self.officeCases, self.allCases, casesDir = MCP_Lib.GetCaseList()
|
| 24 |
|
|
self.casesListChoice = wx.Choice(self.panel, -1, wx.DefaultPosition, choices=self.myCases)
|
| 25 |
ninoborges |
8 |
platformStaticText = wx.StaticText(self.panel, -1, "Select Platform:",wx.DefaultPosition)
|
| 26 |
|
|
platformChoices = ["Concordance DIS","Concordance LN","Relativity"]
|
| 27 |
|
|
self.platformListChoice = wx.Choice(self.panel, -1, wx.DefaultPosition, choices=platformChoices)
|
| 28 |
|
|
workDirStaticText = wx.StaticText(self.panel, -1, "Select Work Dir:",wx.DefaultPosition)
|
| 29 |
|
|
self.workDirControl = wx.TextCtrl(self.panel,-1,os.path.join(os.environ.get("USERPROFILE"),"Desktop\\Working"), size=(296,-1))
|
| 30 |
|
|
workDirBrowseButton = wx.Button(self.panel, -1, "Browse", (10, 10))
|
| 31 |
|
|
|
| 32 |
|
|
|
| 33 |
|
|
self.radio1 = wx.RadioButton(self.panel, -1, 'Individual File',style=wx.RB_GROUP)
|
| 34 |
|
|
self.fileBowserControl = wx.TextCtrl(self.panel, -1,size=(296,-1))
|
| 35 |
|
|
self.fileBowserButton = wx.Button(self.panel, -1, "Browse", (10, 10))
|
| 36 |
|
|
|
| 37 |
|
|
self.requestAssistanceCheckBox = wx.CheckBox(self.panel,-1,": Request Data Analyst Assistance")
|
| 38 |
|
|
self.requestAssistanceCheckBox.Enable(False) ## Change me when you go live with this service.
|
| 39 |
|
|
|
| 40 |
|
|
self.radio2 = wx.RadioButton(self.panel, -1, 'Entire folder of Files')
|
| 41 |
|
|
self.dirBowserControl = wx.TextCtrl(self.panel, -1, size=(296,-1))
|
| 42 |
|
|
self.dirBowserButton = wx.Button(self.panel, -1, "Browse", (10, 10))
|
| 43 |
|
|
self.dirBowserControl.Enable(False)
|
| 44 |
|
|
self.dirBowserButton.Enable(False)
|
| 45 |
|
|
|
| 46 |
|
|
|
| 47 |
|
|
self.CreateBoxesSection()
|
| 48 |
|
|
copyUpTypeStaticBox = wx.StaticBox(self.panel, -1, 'Copy Up:')
|
| 49 |
|
|
copyUpTypeStaticBoxSizer = wx.StaticBoxSizer(copyUpTypeStaticBox, wx.VERTICAL)
|
| 50 |
|
|
|
| 51 |
|
|
radio1Sizer = wx.FlexGridSizer(1,3,10,10)
|
| 52 |
|
|
radio1Sizer.Add(self.radio1, 0, 0)
|
| 53 |
|
|
radio1Sizer.Add(self.fileBowserControl, 0)
|
| 54 |
|
|
radio1Sizer.Add(self.fileBowserButton, 0)
|
| 55 |
|
|
copyUpTypeStaticBoxSizer.Add(radio1Sizer, 0, wx.ALL|wx.ALIGN_LEFT,20)
|
| 56 |
|
|
radio2Sizer = wx.FlexGridSizer(1,3,10,10)
|
| 57 |
|
|
radio2Sizer.Add(self.radio2, 0)
|
| 58 |
|
|
radio2Sizer.Add(self.dirBowserControl, 0)
|
| 59 |
|
|
radio2Sizer.Add(self.dirBowserButton, 0)
|
| 60 |
|
|
copyUpTypeStaticBoxSizer.Add(radio2Sizer, 0, wx.ALL|wx.ALIGN_LEFT,20)
|
| 61 |
|
|
|
| 62 |
|
|
casesSizer = wx.FlexGridSizer(2,2,15,5)
|
| 63 |
|
|
casesSizer.Add(casesListStaticText)
|
| 64 |
|
|
casesSizer.Add(self.casesListChoice)
|
| 65 |
|
|
casesSizer.Add(platformStaticText)
|
| 66 |
|
|
casesSizer.Add(self.platformListChoice)
|
| 67 |
|
|
#casesSizer = wx.BoxSizer(wx.HORIZONTAL)
|
| 68 |
|
|
#casesSizer.Add(casesListStaticText,0,wx.ALL,5)
|
| 69 |
|
|
#casesSizer.Add(self.casesListChoice,0,wx.ALL,5)
|
| 70 |
|
|
#casesSizer.Add(platformStaticText,0,wx.ALL,5)
|
| 71 |
|
|
#casesSizer.Add(self.platformListChoice,0,wx.ALL,5)
|
| 72 |
|
|
workDirSizer = wx.BoxSizer(wx.HORIZONTAL)
|
| 73 |
|
|
workDirSizer.Add(workDirStaticText,0,wx.ALL,5)
|
| 74 |
|
|
workDirSizer.Add(self.workDirControl,0,wx.ALL,5)
|
| 75 |
|
|
workDirSizer.Add(workDirBrowseButton,0,wx.ALL,5)
|
| 76 |
|
|
mainSizer = wx.BoxSizer(wx.VERTICAL)
|
| 77 |
|
|
mainSizer.Add(casesSizer,0,wx.ALL, 20)
|
| 78 |
|
|
mainSizer.Add(workDirSizer,0,wx.ALL, 10)
|
| 79 |
|
|
mainSizer.Add(copyUpTypeStaticBoxSizer, 0, wx.ALL, 10)
|
| 80 |
|
|
mainSizer.Add(self.requestAssistanceCheckBox,0,wx.ALL|wx.ALIGN_CENTER,5)
|
| 81 |
|
|
mainSizer.Add(self.buttonSizer,0, wx.ALL|wx.ALIGN_BOTTOM|wx.ALIGN_CENTER, 10)
|
| 82 |
|
|
|
| 83 |
|
|
self.panel.SetSizer(mainSizer)
|
| 84 |
nino.borges |
189 |
self.CreateMenuBar()
|
| 85 |
ninoborges |
8 |
self.Bind(wx.EVT_RADIOBUTTON, self.OnRadio, self.radio1)
|
| 86 |
|
|
self.Bind(wx.EVT_RADIOBUTTON, self.OnRadio, self.radio2)
|
| 87 |
|
|
self.Bind(wx.EVT_BUTTON, self.OnBrowseClick, workDirBrowseButton)
|
| 88 |
|
|
self.Bind(wx.EVT_BUTTON, self.OnBrowseClick, self.fileBowserButton)
|
| 89 |
|
|
self.Bind(wx.EVT_BUTTON, self.OnBrowseClick, self.dirBowserButton)
|
| 90 |
|
|
self.Bind(wx.EVT_BUTTON, self.OnProcess, self.oKButton)
|
| 91 |
|
|
self.Bind(wx.EVT_BUTTON, self.CloseWindow, self.cancelButton)
|
| 92 |
|
|
|
| 93 |
|
|
def OnRadio(self,event):
|
| 94 |
|
|
radioObj = event.GetEventObject()
|
| 95 |
|
|
selection = radioObj.GetLabel()
|
| 96 |
|
|
if selection == "Individual File":
|
| 97 |
|
|
self.fileBowserControl.Enable(True)
|
| 98 |
|
|
self.fileBowserButton.Enable(True)
|
| 99 |
|
|
|
| 100 |
|
|
self.dirBowserControl.Enable(False)
|
| 101 |
|
|
self.dirBowserButton.Enable(False)
|
| 102 |
|
|
self.dirBowserControl.SetValue("")
|
| 103 |
|
|
else:
|
| 104 |
|
|
self.fileBowserControl.Enable(False)
|
| 105 |
|
|
self.fileBowserButton.Enable(False)
|
| 106 |
|
|
self.fileBowserControl.SetValue("")
|
| 107 |
|
|
|
| 108 |
|
|
self.dirBowserControl.Enable(True)
|
| 109 |
|
|
self.dirBowserButton.Enable(True)
|
| 110 |
|
|
|
| 111 |
|
|
#if self.selectedText:
|
| 112 |
|
|
# self.selectedText.Enable(False)
|
| 113 |
|
|
#radioSelected = event.GetEventObject()
|
| 114 |
|
|
#text = self.texts[radioSelected.GetLabel()]
|
| 115 |
|
|
#text.Enable(True)
|
| 116 |
|
|
#self.selectedText = text
|
| 117 |
|
|
|
| 118 |
|
|
def OnBrowseClick(self,event):
|
| 119 |
|
|
eventCode = event.GetId()
|
| 120 |
|
|
#print eventCode
|
| 121 |
|
|
if eventCode == -209:
|
| 122 |
|
|
dlg = wx.DirDialog(self, message = "Working Directory Path: ", defaultPath = os.path.join(os.environ.get("USERPROFILE"),"Desktop\\Working"))
|
| 123 |
|
|
if dlg.ShowModal() == wx.ID_OK:
|
| 124 |
|
|
dirPath = dlg.GetPath()
|
| 125 |
|
|
dlg.Destroy()
|
| 126 |
|
|
self.workDirControl.SetValue(dirPath)
|
| 127 |
|
|
elif eventCode == -212:
|
| 128 |
|
|
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)
|
| 129 |
|
|
#dlg = wx.FileDialog(self, message = "Select directory to copy up: ", defaultPath = os.path.join(os.environ.get("USERPROFILE"),"Desktop\\Working"))
|
| 130 |
|
|
if dlg.ShowModal() == wx.ID_OK:
|
| 131 |
|
|
filePath = dlg.GetPath()
|
| 132 |
|
|
dlg.Destroy()
|
| 133 |
|
|
self.fileBowserControl.SetValue(filePath)
|
| 134 |
|
|
elif eventCode == -216:
|
| 135 |
|
|
dlg = wx.DirDialog(self, message = "Select directory to copy up:", defaultPath = os.path.join(os.environ.get("USERPROFILE"),"Desktop\\Working"))
|
| 136 |
|
|
if dlg.ShowModal() == wx.ID_OK:
|
| 137 |
|
|
dirPath = dlg.GetPath()
|
| 138 |
|
|
dlg.Destroy()
|
| 139 |
|
|
self.dirBowserControl.SetValue(dirPath)
|
| 140 |
|
|
|
| 141 |
|
|
def CreateBoxesSection(self):
|
| 142 |
|
|
self.oKButton = wx.Button(self.panel, wx.ID_OK)
|
| 143 |
|
|
self.oKButton.SetDefault()
|
| 144 |
|
|
self.oKButton.SetSize(self.oKButton.GetBestSize())
|
| 145 |
|
|
self.cancelButton = wx.Button(self.panel, wx.ID_CANCEL)
|
| 146 |
|
|
self.cancelButton.SetSize(self.cancelButton.GetBestSize())
|
| 147 |
|
|
self.buttonSizer = wx.BoxSizer(wx.HORIZONTAL)
|
| 148 |
|
|
self.buttonSizer.Add(self.oKButton,0,wx.ALL,10)
|
| 149 |
|
|
self.buttonSizer.Add(self.cancelButton,0,wx.ALL,10)
|
| 150 |
|
|
|
| 151 |
nino.borges |
189 |
def MenuData(self):
|
| 152 |
|
|
return(("View",
|
| 153 |
|
|
("My Cases", "Chooses from your assigned cases.",self.OnChangeCaseView,"RADIO"),
|
| 154 |
|
|
("My Office Cases", "Chooses from cases assigned to everyone in your office.",self.OnChangeCaseView,"RADIO"),
|
| 155 |
|
|
("All Cases", "Chooses from all cases.",self.OnChangeCaseView,"RADIO")),
|
| 156 |
|
|
("&Help",
|
| 157 |
|
|
("&About", "Displays the About Window.", self.OnAbout,"")))
|
| 158 |
|
|
|
| 159 |
|
|
def CreateMenuBar(self):
|
| 160 |
|
|
menuBar = wx.MenuBar()
|
| 161 |
|
|
count = 1
|
| 162 |
|
|
for eachMenuData in self.MenuData():
|
| 163 |
|
|
menuLabel = eachMenuData[0]
|
| 164 |
|
|
menuItems = eachMenuData[1:]
|
| 165 |
|
|
menuBar.Append(self.CreateMenu(menuItems), menuLabel)
|
| 166 |
|
|
count = count + 1
|
| 167 |
|
|
self.SetMenuBar(menuBar)
|
| 168 |
|
|
|
| 169 |
|
|
|
| 170 |
|
|
def CreateMenu(self, menuData):
|
| 171 |
|
|
menu = wx.Menu()
|
| 172 |
|
|
for eachLabel, eachStatus, eachHandler, eachType in menuData:
|
| 173 |
|
|
if not eachLabel:
|
| 174 |
|
|
menu.AppendSeparator()
|
| 175 |
|
|
continue
|
| 176 |
|
|
if eachType == "RADIO":
|
| 177 |
|
|
menuItem = menu.AppendRadioItem(-1,eachLabel,eachStatus)
|
| 178 |
|
|
else:
|
| 179 |
|
|
menuItem = menu.Append(-1, eachLabel, eachStatus)
|
| 180 |
|
|
self.Bind(wx.EVT_MENU, eachHandler, menuItem)
|
| 181 |
|
|
return menu
|
| 182 |
|
|
|
| 183 |
ninoborges |
8 |
def CloseWindow(self, event):
|
| 184 |
|
|
self.Close(True)
|
| 185 |
nino.borges |
189 |
|
| 186 |
|
|
def OnChangeCaseView(self,event):
|
| 187 |
|
|
self.casesListChoice.Clear()
|
| 188 |
|
|
eventID = event.GetId()
|
| 189 |
|
|
if eventID == 100:
|
| 190 |
|
|
#change it to my cases
|
| 191 |
|
|
self.casesListChoice.SetItems(self.myCases)
|
| 192 |
|
|
|
| 193 |
|
|
|
| 194 |
|
|
if eventID == 101:
|
| 195 |
|
|
#change it to office cases
|
| 196 |
|
|
self.casesListChoice.SetItems(self.officeCases)
|
| 197 |
|
|
|
| 198 |
|
|
|
| 199 |
|
|
if eventID == 102:
|
| 200 |
|
|
#change it to all cases
|
| 201 |
|
|
self.casesListChoice.SetItems(self.allCases)
|
| 202 |
|
|
|
| 203 |
|
|
|
| 204 |
ninoborges |
8 |
|
| 205 |
|
|
def OnProcess(self, event):
|
| 206 |
|
|
caseName = self.casesListChoice.GetStringSelection()
|
| 207 |
|
|
platform = self.platformListChoice.GetStringSelection()
|
| 208 |
|
|
workDir = self.workDirControl.GetValue()
|
| 209 |
|
|
#workDir = r"E:"
|
| 210 |
|
|
if self.radio1.GetValue():
|
| 211 |
|
|
startSelection = self.fileBowserControl.GetValue()
|
| 212 |
|
|
else:
|
| 213 |
|
|
startSelection = self.dirBowserControl.GetValue()
|
| 214 |
|
|
#startSelection = r"C:\Documents and Settings\eborges\Desktop\Working\Misc_Documents.zip"
|
| 215 |
|
|
self.Show(False)
|
| 216 |
|
|
#print "workdir is %s"%workDir
|
| 217 |
|
|
MCP_CopyUp_Request.Process(caseName, workDir, startSelection, platform)
|
| 218 |
|
|
|
| 219 |
|
|
#diag = wx.MessageDialog(self,"All Items processed and copied!!", "Complete",wx.OK | wx.ICON_INFORMATION)
|
| 220 |
|
|
#diag.ShowModal()
|
| 221 |
|
|
#diag.Destroy()
|
| 222 |
|
|
self.Destroy()
|
| 223 |
|
|
|
| 224 |
nino.borges |
189 |
def OnAbout(self, event):
|
| 225 |
|
|
"""
|
| 226 |
|
|
OnAbout(self,event) Displays an about dialog with developer and bug reporting info
|
| 227 |
|
|
"""
|
| 228 |
|
|
dlg = wx.MessageDialog(self, "MCP is a case organization program.\n"
|
| 229 |
|
|
"\n\n"
|
| 230 |
|
|
"For questions or comments about this program\n"
|
| 231 |
|
|
"or to report a bug, please email the program\n"
|
| 232 |
|
|
"creator at Nino.Borges@gmail.com\n\n"
|
| 233 |
|
|
"MCP is\n"
|
| 234 |
|
|
"Copyright (c) 2011 Emanuel Borges.\n"
|
| 235 |
|
|
"All rights reserved.\n"
|
| 236 |
|
|
"(Nino.Borges@gmail.com)\n",
|
| 237 |
|
|
"About MCP", wx.OK | wx.ICON_INFORMATION)
|
| 238 |
|
|
dlg.ShowModal()
|
| 239 |
|
|
dlg.Destroy()
|
| 240 |
ninoborges |
8 |
|
| 241 |
|
|
|
| 242 |
|
|
|
| 243 |
|
|
class MyApp(wx.App):
|
| 244 |
|
|
def OnInit(self):
|
| 245 |
|
|
prgVersion = MCP_Lib.GetMCPVersion()
|
| 246 |
|
|
self.frame = MyFrame(None, -1, "MCP Copy Up Request %s"%prgVersion)
|
| 247 |
|
|
self.frame.Show(True)
|
| 248 |
|
|
self.SetTopWindow(self.frame)
|
| 249 |
|
|
return True
|
| 250 |
|
|
|
| 251 |
|
|
|
| 252 |
|
|
if __name__ == '__main__':
|
| 253 |
|
|
app = MyApp(0)
|
| 254 |
|
|
app.MainLoop() |