| 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 |
nino.borges |
203 |
wx.Frame.__init__(self, parent, ID, title, pos, size =(585,450))
|
| 19 |
ninoborges |
8 |
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 |
nino.borges |
232 |
print "connecting to matter tracking access db..."
|
| 24 |
|
|
self.accessDB = MCP_Lib.AccessDBConnection(r"\\chiads01\app\DS_CaseTrack\TPM_CaseTracking.mdb")
|
| 25 |
|
|
print "connected to DB."
|
| 26 |
|
|
self.myCases, self.officeCases, self.allCases, casesDir = MCP_Lib.GetCaseList('',self.accessDB)
|
| 27 |
nino.borges |
189 |
self.casesListChoice = wx.Choice(self.panel, -1, wx.DefaultPosition, choices=self.myCases)
|
| 28 |
ninoborges |
8 |
platformStaticText = wx.StaticText(self.panel, -1, "Select Platform:",wx.DefaultPosition)
|
| 29 |
|
|
platformChoices = ["Concordance DIS","Concordance LN","Relativity"]
|
| 30 |
|
|
self.platformListChoice = wx.Choice(self.panel, -1, wx.DefaultPosition, choices=platformChoices)
|
| 31 |
nino.borges |
203 |
#workDirStaticText = wx.StaticText(self.panel, -1, "Select Work Dir:",wx.DefaultPosition)
|
| 32 |
|
|
#self.workDirControl = wx.TextCtrl(self.panel,-1,os.path.join(os.environ.get("USERPROFILE"),"Desktop\\Working"), size=(296,-1))
|
| 33 |
|
|
#workDirBrowseButton = wx.Button(self.panel, -1, "Browse", (10, 10))
|
| 34 |
ninoborges |
8 |
|
| 35 |
|
|
|
| 36 |
|
|
self.radio1 = wx.RadioButton(self.panel, -1, 'Individual File',style=wx.RB_GROUP)
|
| 37 |
|
|
self.fileBowserControl = wx.TextCtrl(self.panel, -1,size=(296,-1))
|
| 38 |
|
|
self.fileBowserButton = wx.Button(self.panel, -1, "Browse", (10, 10))
|
| 39 |
|
|
|
| 40 |
|
|
self.requestAssistanceCheckBox = wx.CheckBox(self.panel,-1,": Request Data Analyst Assistance")
|
| 41 |
|
|
self.requestAssistanceCheckBox.Enable(False) ## Change me when you go live with this service.
|
| 42 |
|
|
|
| 43 |
|
|
self.radio2 = wx.RadioButton(self.panel, -1, 'Entire folder of Files')
|
| 44 |
|
|
self.dirBowserControl = wx.TextCtrl(self.panel, -1, size=(296,-1))
|
| 45 |
|
|
self.dirBowserButton = wx.Button(self.panel, -1, "Browse", (10, 10))
|
| 46 |
|
|
self.dirBowserControl.Enable(False)
|
| 47 |
|
|
self.dirBowserButton.Enable(False)
|
| 48 |
|
|
|
| 49 |
nino.borges |
203 |
self.radio3 = wx.RadioButton(self.panel, -1, 'From Vendor Folder')
|
| 50 |
|
|
self.vendorBowserControl = wx.TextCtrl(self.panel, -1, size=(296,-1))
|
| 51 |
|
|
self.vendorBowserButton = wx.Button(self.panel, -1, "Browse", (10, 10))
|
| 52 |
|
|
self.vendorBowserControl.Enable(False)
|
| 53 |
|
|
self.vendorBowserButton.Enable(False)
|
| 54 |
ninoborges |
8 |
|
| 55 |
nino.borges |
203 |
|
| 56 |
ninoborges |
8 |
self.CreateBoxesSection()
|
| 57 |
|
|
copyUpTypeStaticBox = wx.StaticBox(self.panel, -1, 'Copy Up:')
|
| 58 |
|
|
copyUpTypeStaticBoxSizer = wx.StaticBoxSizer(copyUpTypeStaticBox, wx.VERTICAL)
|
| 59 |
|
|
|
| 60 |
|
|
radio1Sizer = wx.FlexGridSizer(1,3,10,10)
|
| 61 |
|
|
radio1Sizer.Add(self.radio1, 0, 0)
|
| 62 |
|
|
radio1Sizer.Add(self.fileBowserControl, 0)
|
| 63 |
|
|
radio1Sizer.Add(self.fileBowserButton, 0)
|
| 64 |
|
|
copyUpTypeStaticBoxSizer.Add(radio1Sizer, 0, wx.ALL|wx.ALIGN_LEFT,20)
|
| 65 |
nino.borges |
203 |
|
| 66 |
ninoborges |
8 |
radio2Sizer = wx.FlexGridSizer(1,3,10,10)
|
| 67 |
|
|
radio2Sizer.Add(self.radio2, 0)
|
| 68 |
|
|
radio2Sizer.Add(self.dirBowserControl, 0)
|
| 69 |
|
|
radio2Sizer.Add(self.dirBowserButton, 0)
|
| 70 |
nino.borges |
203 |
|
| 71 |
ninoborges |
8 |
copyUpTypeStaticBoxSizer.Add(radio2Sizer, 0, wx.ALL|wx.ALIGN_LEFT,20)
|
| 72 |
nino.borges |
203 |
radio3Sizer = wx.FlexGridSizer(1,3,10,10)
|
| 73 |
|
|
radio3Sizer.Add(self.radio3, 0)
|
| 74 |
|
|
radio3Sizer.Add(self.vendorBowserControl, 0)
|
| 75 |
|
|
radio3Sizer.Add(self.vendorBowserButton, 0)
|
| 76 |
|
|
copyUpTypeStaticBoxSizer.Add(radio3Sizer, 0, wx.ALL|wx.ALIGN_LEFT,20)
|
| 77 |
ninoborges |
8 |
|
| 78 |
|
|
casesSizer = wx.FlexGridSizer(2,2,15,5)
|
| 79 |
|
|
casesSizer.Add(casesListStaticText)
|
| 80 |
|
|
casesSizer.Add(self.casesListChoice)
|
| 81 |
|
|
casesSizer.Add(platformStaticText)
|
| 82 |
|
|
casesSizer.Add(self.platformListChoice)
|
| 83 |
|
|
#casesSizer = wx.BoxSizer(wx.HORIZONTAL)
|
| 84 |
|
|
#casesSizer.Add(casesListStaticText,0,wx.ALL,5)
|
| 85 |
|
|
#casesSizer.Add(self.casesListChoice,0,wx.ALL,5)
|
| 86 |
|
|
#casesSizer.Add(platformStaticText,0,wx.ALL,5)
|
| 87 |
|
|
#casesSizer.Add(self.platformListChoice,0,wx.ALL,5)
|
| 88 |
nino.borges |
203 |
#workDirSizer = wx.BoxSizer(wx.HORIZONTAL)
|
| 89 |
|
|
#workDirSizer.Add(workDirStaticText,0,wx.ALL,5)
|
| 90 |
|
|
#workDirSizer.Add(self.workDirControl,0,wx.ALL,5)
|
| 91 |
|
|
#workDirSizer.Add(workDirBrowseButton,0,wx.ALL,5)
|
| 92 |
ninoborges |
8 |
mainSizer = wx.BoxSizer(wx.VERTICAL)
|
| 93 |
|
|
mainSizer.Add(casesSizer,0,wx.ALL, 20)
|
| 94 |
nino.borges |
203 |
#mainSizer.Add(workDirSizer,0,wx.ALL, 10)
|
| 95 |
ninoborges |
8 |
mainSizer.Add(copyUpTypeStaticBoxSizer, 0, wx.ALL, 10)
|
| 96 |
|
|
mainSizer.Add(self.requestAssistanceCheckBox,0,wx.ALL|wx.ALIGN_CENTER,5)
|
| 97 |
nino.borges |
203 |
|
| 98 |
|
|
|
| 99 |
ninoborges |
8 |
mainSizer.Add(self.buttonSizer,0, wx.ALL|wx.ALIGN_BOTTOM|wx.ALIGN_CENTER, 10)
|
| 100 |
|
|
|
| 101 |
|
|
self.panel.SetSizer(mainSizer)
|
| 102 |
nino.borges |
189 |
self.CreateMenuBar()
|
| 103 |
ninoborges |
8 |
self.Bind(wx.EVT_RADIOBUTTON, self.OnRadio, self.radio1)
|
| 104 |
|
|
self.Bind(wx.EVT_RADIOBUTTON, self.OnRadio, self.radio2)
|
| 105 |
nino.borges |
203 |
self.Bind(wx.EVT_RADIOBUTTON, self.OnRadio, self.radio3)
|
| 106 |
|
|
#self.Bind(wx.EVT_BUTTON, self.OnBrowseClick, workDirBrowseButton)
|
| 107 |
ninoborges |
8 |
self.Bind(wx.EVT_BUTTON, self.OnBrowseClick, self.fileBowserButton)
|
| 108 |
|
|
self.Bind(wx.EVT_BUTTON, self.OnBrowseClick, self.dirBowserButton)
|
| 109 |
nino.borges |
203 |
self.Bind(wx.EVT_BUTTON, self.OnBrowseClick, self.vendorBowserButton)
|
| 110 |
ninoborges |
8 |
self.Bind(wx.EVT_BUTTON, self.OnProcess, self.oKButton)
|
| 111 |
|
|
self.Bind(wx.EVT_BUTTON, self.CloseWindow, self.cancelButton)
|
| 112 |
|
|
|
| 113 |
|
|
def OnRadio(self,event):
|
| 114 |
|
|
radioObj = event.GetEventObject()
|
| 115 |
|
|
selection = radioObj.GetLabel()
|
| 116 |
|
|
if selection == "Individual File":
|
| 117 |
|
|
self.fileBowserControl.Enable(True)
|
| 118 |
|
|
self.fileBowserButton.Enable(True)
|
| 119 |
|
|
|
| 120 |
|
|
self.dirBowserControl.Enable(False)
|
| 121 |
|
|
self.dirBowserButton.Enable(False)
|
| 122 |
nino.borges |
203 |
self.vendorBowserControl.Enable(False)
|
| 123 |
|
|
self.vendorBowserButton.Enable(False)
|
| 124 |
|
|
|
| 125 |
ninoborges |
8 |
self.dirBowserControl.SetValue("")
|
| 126 |
nino.borges |
203 |
self.vendorBowserControl.SetValue("")
|
| 127 |
|
|
|
| 128 |
|
|
elif selection == "Entire folder of Files":
|
| 129 |
|
|
self.dirBowserControl.Enable(True)
|
| 130 |
|
|
self.dirBowserButton.Enable(True)
|
| 131 |
|
|
|
| 132 |
|
|
self.fileBowserControl.Enable(False)
|
| 133 |
|
|
self.fileBowserButton.Enable(False)
|
| 134 |
|
|
self.vendorBowserControl.Enable(False)
|
| 135 |
|
|
self.vendorBowserButton.Enable(False)
|
| 136 |
|
|
|
| 137 |
|
|
self.fileBowserControl.SetValue("")
|
| 138 |
|
|
self.vendorBowserControl.SetValue("")
|
| 139 |
|
|
|
| 140 |
ninoborges |
8 |
else:
|
| 141 |
nino.borges |
203 |
self.vendorBowserControl.Enable(True)
|
| 142 |
|
|
self.vendorBowserButton.Enable(True)
|
| 143 |
|
|
|
| 144 |
ninoborges |
8 |
self.fileBowserControl.Enable(False)
|
| 145 |
|
|
self.fileBowserButton.Enable(False)
|
| 146 |
nino.borges |
203 |
self.dirBowserControl.Enable(False)
|
| 147 |
|
|
self.dirBowserButton.Enable(False)
|
| 148 |
|
|
|
| 149 |
ninoborges |
8 |
self.fileBowserControl.SetValue("")
|
| 150 |
nino.borges |
203 |
self.dirBowserControl.SetValue("")
|
| 151 |
ninoborges |
8 |
|
| 152 |
|
|
#if self.selectedText:
|
| 153 |
|
|
# self.selectedText.Enable(False)
|
| 154 |
|
|
#radioSelected = event.GetEventObject()
|
| 155 |
|
|
#text = self.texts[radioSelected.GetLabel()]
|
| 156 |
|
|
#text.Enable(True)
|
| 157 |
|
|
#self.selectedText = text
|
| 158 |
|
|
|
| 159 |
|
|
def OnBrowseClick(self,event):
|
| 160 |
|
|
eventCode = event.GetId()
|
| 161 |
|
|
#print eventCode
|
| 162 |
nino.borges |
203 |
#if eventCode == -209:
|
| 163 |
|
|
# dlg = wx.DirDialog(self, message = "Working Directory Path: ", defaultPath = os.path.join(os.environ.get("USERPROFILE"),"Desktop\\Working"))
|
| 164 |
|
|
# if dlg.ShowModal() == wx.ID_OK:
|
| 165 |
|
|
# dirPath = dlg.GetPath()
|
| 166 |
|
|
# dlg.Destroy()
|
| 167 |
|
|
# self.workDirControl.SetValue(dirPath)
|
| 168 |
ninoborges |
8 |
if eventCode == -209:
|
| 169 |
|
|
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)
|
| 170 |
|
|
#dlg = wx.FileDialog(self, message = "Select directory to copy up: ", defaultPath = os.path.join(os.environ.get("USERPROFILE"),"Desktop\\Working"))
|
| 171 |
|
|
if dlg.ShowModal() == wx.ID_OK:
|
| 172 |
|
|
filePath = dlg.GetPath()
|
| 173 |
|
|
dlg.Destroy()
|
| 174 |
nino.borges |
235 |
## Test here to see if it's a zip. if not, give them warning about uncompressed size.
|
| 175 |
ninoborges |
8 |
self.fileBowserControl.SetValue(filePath)
|
| 176 |
nino.borges |
203 |
elif eventCode == -213:
|
| 177 |
ninoborges |
8 |
dlg = wx.DirDialog(self, message = "Select directory to copy up:", defaultPath = os.path.join(os.environ.get("USERPROFILE"),"Desktop\\Working"))
|
| 178 |
|
|
if dlg.ShowModal() == wx.ID_OK:
|
| 179 |
|
|
dirPath = dlg.GetPath()
|
| 180 |
|
|
dlg.Destroy()
|
| 181 |
|
|
self.dirBowserControl.SetValue(dirPath)
|
| 182 |
nino.borges |
203 |
elif eventCode == -216:
|
| 183 |
nino.borges |
232 |
platform = self.platformListChoice.GetStringSelection()
|
| 184 |
|
|
if platform == 'Concordance LN':
|
| 185 |
|
|
platform = 'Concordance'
|
| 186 |
|
|
elif platform == 'Concordance DIS':
|
| 187 |
|
|
platform = None
|
| 188 |
|
|
if platform:
|
| 189 |
|
|
expdtObj = MCP_Lib.ExpeDatConnection(platform)
|
| 190 |
|
|
caseName = self.casesListChoice.GetStringSelection()
|
| 191 |
|
|
clientMatter = caseName.split("_(")[1]
|
| 192 |
|
|
clientMatter = clientMatter[:-1]
|
| 193 |
|
|
clientMatter = clientMatter.replace('-','.')
|
| 194 |
|
|
vendorFolder = self.accessDB.GetVendorFolderPath(clientMatter)
|
| 195 |
|
|
if vendorFolder:
|
| 196 |
|
|
folderMatrix = expdtObj.GatherFullDirListMatrix('Uploads/%s'%vendorFolder)
|
| 197 |
|
|
dlg = VendorBrowserDialog(self,vendorFolder,folderMatrix)
|
| 198 |
|
|
if dlg.ShowModal() == wx.ID_OK:
|
| 199 |
|
|
vendorPath = dlg.GetValues()
|
| 200 |
|
|
dlg.Destroy()
|
| 201 |
|
|
self.vendorBowserControl.SetValue(vendorPath)
|
| 202 |
|
|
else:
|
| 203 |
|
|
diag = wx.MessageDialog(self,"MCP: No vendor folder is currently linked to this case.","Does not exist",wx.OK | wx.ICON_INFORMATION)
|
| 204 |
|
|
diag.ShowModal()
|
| 205 |
|
|
diag.Destroy()
|
| 206 |
|
|
else:
|
| 207 |
|
|
diag = wx.MessageDialog(self,"MCP: Copying from LN to DIS is not yet supported.","ERROR",wx.OK | wx.ICON_INFORMATION)
|
| 208 |
|
|
diag.ShowModal()
|
| 209 |
|
|
diag.Destroy()
|
| 210 |
ninoborges |
8 |
|
| 211 |
|
|
def CreateBoxesSection(self):
|
| 212 |
|
|
self.oKButton = wx.Button(self.panel, wx.ID_OK)
|
| 213 |
|
|
self.oKButton.SetDefault()
|
| 214 |
|
|
self.oKButton.SetSize(self.oKButton.GetBestSize())
|
| 215 |
|
|
self.cancelButton = wx.Button(self.panel, wx.ID_CANCEL)
|
| 216 |
|
|
self.cancelButton.SetSize(self.cancelButton.GetBestSize())
|
| 217 |
|
|
self.buttonSizer = wx.BoxSizer(wx.HORIZONTAL)
|
| 218 |
|
|
self.buttonSizer.Add(self.oKButton,0,wx.ALL,10)
|
| 219 |
|
|
self.buttonSizer.Add(self.cancelButton,0,wx.ALL,10)
|
| 220 |
|
|
|
| 221 |
nino.borges |
189 |
def MenuData(self):
|
| 222 |
|
|
return(("View",
|
| 223 |
|
|
("My Cases", "Chooses from your assigned cases.",self.OnChangeCaseView,"RADIO"),
|
| 224 |
|
|
("My Office Cases", "Chooses from cases assigned to everyone in your office.",self.OnChangeCaseView,"RADIO"),
|
| 225 |
|
|
("All Cases", "Chooses from all cases.",self.OnChangeCaseView,"RADIO")),
|
| 226 |
nino.borges |
203 |
("&Settings",
|
| 227 |
|
|
("&Working Directory", "Allows you to change the local Buffer directory.", self.OnChangeWorkDir,"")),
|
| 228 |
nino.borges |
189 |
("&Help",
|
| 229 |
|
|
("&About", "Displays the About Window.", self.OnAbout,"")))
|
| 230 |
|
|
|
| 231 |
|
|
def CreateMenuBar(self):
|
| 232 |
|
|
menuBar = wx.MenuBar()
|
| 233 |
|
|
count = 1
|
| 234 |
|
|
for eachMenuData in self.MenuData():
|
| 235 |
|
|
menuLabel = eachMenuData[0]
|
| 236 |
|
|
menuItems = eachMenuData[1:]
|
| 237 |
|
|
menuBar.Append(self.CreateMenu(menuItems), menuLabel)
|
| 238 |
|
|
count = count + 1
|
| 239 |
|
|
self.SetMenuBar(menuBar)
|
| 240 |
|
|
|
| 241 |
|
|
|
| 242 |
|
|
def CreateMenu(self, menuData):
|
| 243 |
|
|
menu = wx.Menu()
|
| 244 |
|
|
for eachLabel, eachStatus, eachHandler, eachType in menuData:
|
| 245 |
|
|
if not eachLabel:
|
| 246 |
|
|
menu.AppendSeparator()
|
| 247 |
|
|
continue
|
| 248 |
|
|
if eachType == "RADIO":
|
| 249 |
|
|
menuItem = menu.AppendRadioItem(-1,eachLabel,eachStatus)
|
| 250 |
|
|
else:
|
| 251 |
|
|
menuItem = menu.Append(-1, eachLabel, eachStatus)
|
| 252 |
|
|
self.Bind(wx.EVT_MENU, eachHandler, menuItem)
|
| 253 |
|
|
return menu
|
| 254 |
|
|
|
| 255 |
ninoborges |
8 |
def CloseWindow(self, event):
|
| 256 |
|
|
self.Close(True)
|
| 257 |
nino.borges |
189 |
|
| 258 |
|
|
def OnChangeCaseView(self,event):
|
| 259 |
|
|
self.casesListChoice.Clear()
|
| 260 |
|
|
eventID = event.GetId()
|
| 261 |
|
|
if eventID == 100:
|
| 262 |
|
|
#change it to my cases
|
| 263 |
|
|
self.casesListChoice.SetItems(self.myCases)
|
| 264 |
|
|
|
| 265 |
|
|
|
| 266 |
|
|
if eventID == 101:
|
| 267 |
|
|
#change it to office cases
|
| 268 |
|
|
self.casesListChoice.SetItems(self.officeCases)
|
| 269 |
|
|
|
| 270 |
|
|
|
| 271 |
|
|
if eventID == 102:
|
| 272 |
|
|
#change it to all cases
|
| 273 |
|
|
self.casesListChoice.SetItems(self.allCases)
|
| 274 |
|
|
|
| 275 |
|
|
|
| 276 |
nino.borges |
203 |
def OnChangeWorkDir(self,event):
|
| 277 |
|
|
pass
|
| 278 |
ninoborges |
8 |
|
| 279 |
|
|
def OnProcess(self, event):
|
| 280 |
|
|
caseName = self.casesListChoice.GetStringSelection()
|
| 281 |
|
|
platform = self.platformListChoice.GetStringSelection()
|
| 282 |
nino.borges |
235 |
## CHANGE to the new place
|
| 283 |
|
|
#workDir = self.workDirControl.GetValue()
|
| 284 |
|
|
workDir = os.path.join(os.environ.get("USERPROFILE"),"Desktop\\Working")
|
| 285 |
|
|
|
| 286 |
ninoborges |
8 |
if self.radio1.GetValue():
|
| 287 |
|
|
startSelection = self.fileBowserControl.GetValue()
|
| 288 |
|
|
else:
|
| 289 |
|
|
startSelection = self.dirBowserControl.GetValue()
|
| 290 |
|
|
#startSelection = r"C:\Documents and Settings\eborges\Desktop\Working\Misc_Documents.zip"
|
| 291 |
|
|
self.Show(False)
|
| 292 |
|
|
#print "workdir is %s"%workDir
|
| 293 |
|
|
MCP_CopyUp_Request.Process(caseName, workDir, startSelection, platform)
|
| 294 |
|
|
|
| 295 |
|
|
#diag = wx.MessageDialog(self,"All Items processed and copied!!", "Complete",wx.OK | wx.ICON_INFORMATION)
|
| 296 |
|
|
#diag.ShowModal()
|
| 297 |
|
|
#diag.Destroy()
|
| 298 |
|
|
self.Destroy()
|
| 299 |
|
|
|
| 300 |
nino.borges |
189 |
def OnAbout(self, event):
|
| 301 |
|
|
"""
|
| 302 |
|
|
OnAbout(self,event) Displays an about dialog with developer and bug reporting info
|
| 303 |
|
|
"""
|
| 304 |
|
|
dlg = wx.MessageDialog(self, "MCP is a case organization program.\n"
|
| 305 |
|
|
"\n\n"
|
| 306 |
|
|
"For questions or comments about this program\n"
|
| 307 |
|
|
"or to report a bug, please email the program\n"
|
| 308 |
|
|
"creator at Nino.Borges@gmail.com\n\n"
|
| 309 |
|
|
"MCP is\n"
|
| 310 |
|
|
"Copyright (c) 2011 Emanuel Borges.\n"
|
| 311 |
|
|
"All rights reserved.\n"
|
| 312 |
|
|
"(Nino.Borges@gmail.com)\n",
|
| 313 |
|
|
"About MCP", wx.OK | wx.ICON_INFORMATION)
|
| 314 |
|
|
dlg.ShowModal()
|
| 315 |
|
|
dlg.Destroy()
|
| 316 |
ninoborges |
8 |
|
| 317 |
|
|
|
| 318 |
nino.borges |
203 |
class VendorBrowserDialog(wx.Dialog):
|
| 319 |
|
|
def __init__(self, parent, vendorFolder, treeMatrix):
|
| 320 |
|
|
wx.Dialog.__init__(self, parent, -1, "Vendor Folder Browser", style = wx.DEFAULT_DIALOG_STYLE, size = (300,400))
|
| 321 |
|
|
#wx.Dialog.__init__(self, parent,title= "Vendor Folder Browser", size = (300,400))
|
| 322 |
|
|
self.vendorFolder = vendorFolder
|
| 323 |
|
|
|
| 324 |
|
|
il = wx.ImageList(16,16)
|
| 325 |
|
|
self.fldridx = il.Add(wx.ArtProvider.GetBitmap(wx.ART_FOLDER,wx.ART_OTHER, (16,16)))
|
| 326 |
|
|
self.fldropenidx = il.Add(wx.ArtProvider.GetBitmap(wx.ART_FILE_OPEN,wx.ART_OTHER, (16,16)))
|
| 327 |
|
|
self.fileidx = il.Add(wx.ArtProvider.GetBitmap(wx.ART_NORMAL_FILE,wx.ART_OTHER, (16,16)))
|
| 328 |
|
|
|
| 329 |
|
|
self.vendorTree = wx.TreeCtrl(self, size=(200,310))
|
| 330 |
|
|
self.vendorTree.AssignImageList(il)
|
| 331 |
|
|
|
| 332 |
|
|
rootVendorFolderId = self.vendorTree.AddRoot(vendorFolder)
|
| 333 |
|
|
|
| 334 |
|
|
self.AddTreeNodes(rootVendorFolderId, treeMatrix)
|
| 335 |
|
|
#childVendorFolderId2 = self.vendorTree.AppendItem(rootVendorFolderId,"test2")
|
| 336 |
|
|
#childVendorFolderId = self.vendorTree.AppendItem(childVendorFolderId2,"test")
|
| 337 |
|
|
self.vendorTree.Expand(rootVendorFolderId)
|
| 338 |
|
|
|
| 339 |
|
|
|
| 340 |
|
|
self.vendorTree.SetItemImage(rootVendorFolderId, self.fldridx, wx.TreeItemIcon_Normal)
|
| 341 |
|
|
self.vendorTree.SetItemImage(rootVendorFolderId, self.fldropenidx, wx.TreeItemIcon_Expanded)
|
| 342 |
|
|
## this will need a if its a file do this else do the previous
|
| 343 |
|
|
#self.vendorTree.SetItemImage(childVendorFolderId, self.fileidx, wx.TreeItemIcon_Normal)
|
| 344 |
|
|
|
| 345 |
|
|
mainSizer = wx.BoxSizer(wx.VERTICAL)
|
| 346 |
|
|
mainSizer.Add(self.vendorTree, 0, wx.EXPAND|wx.ALL, 5)
|
| 347 |
|
|
|
| 348 |
|
|
oKButton = wx.Button(self, wx.ID_OK)
|
| 349 |
|
|
oKButton.SetDefault()
|
| 350 |
|
|
cancelButton = wx.Button(self, wx.ID_CANCEL)
|
| 351 |
|
|
buttonSizer = wx.BoxSizer(wx.HORIZONTAL)
|
| 352 |
|
|
buttonSizer.Add(oKButton,0,wx.ALL,5)
|
| 353 |
|
|
buttonSizer.Add(cancelButton,0,wx.ALL,5)
|
| 354 |
|
|
mainSizer.Add(buttonSizer, 0, wx.ALIGN_CENTER|wx.ALL, 15)
|
| 355 |
|
|
self.SetSizer(mainSizer)
|
| 356 |
|
|
self.Bind(wx.EVT_TREE_SEL_CHANGED, self.OnSelChanged, self.vendorTree)
|
| 357 |
ninoborges |
8 |
|
| 358 |
nino.borges |
203 |
def AddTreeNodes(self, parentItem, items):
|
| 359 |
|
|
"""
|
| 360 |
|
|
Recursively traverses the data structure, adding tree nodes to
|
| 361 |
|
|
match it.
|
| 362 |
|
|
"""
|
| 363 |
|
|
for item in items:
|
| 364 |
|
|
if type(item) == str:
|
| 365 |
|
|
newItem = self.vendorTree.AppendItem(parentItem, item)
|
| 366 |
|
|
#self.tree.SetItemText(newItem, "A description of %s" % item, 1)
|
| 367 |
|
|
self.vendorTree.SetItemImage(newItem, self.fileidx,
|
| 368 |
|
|
wx.TreeItemIcon_Normal)
|
| 369 |
|
|
else:
|
| 370 |
|
|
newItem = self.vendorTree.AppendItem(parentItem, item[0])
|
| 371 |
|
|
#self.tree.SetItemText(newItem, "A description of %s" % item[0], 1)
|
| 372 |
|
|
self.vendorTree.SetItemImage(newItem, self.fldridx,
|
| 373 |
|
|
wx.TreeItemIcon_Normal)
|
| 374 |
|
|
self.vendorTree.SetItemImage(newItem, self.fldropenidx,
|
| 375 |
|
|
wx.TreeItemIcon_Expanded)
|
| 376 |
|
|
|
| 377 |
|
|
self.AddTreeNodes(newItem, item[1])
|
| 378 |
|
|
|
| 379 |
|
|
def OnSelChanged(self, event):
|
| 380 |
|
|
self.item = event.GetItem()
|
| 381 |
|
|
if self.item:
|
| 382 |
|
|
self.vendorFileSelected = self.vendorTree.GetItemText(self.item)
|
| 383 |
|
|
event.Skip()
|
| 384 |
|
|
|
| 385 |
|
|
def GetValues(self):
|
| 386 |
|
|
vendorPath = self.vendorFileSelected
|
| 387 |
|
|
upItem = self.vendorTree.GetItemParent(self.item)
|
| 388 |
|
|
while upItem:
|
| 389 |
|
|
vendorPath = os.path.join(self.vendorTree.GetItemText(upItem),vendorPath)
|
| 390 |
|
|
upItem = self.vendorTree.GetItemParent(upItem)
|
| 391 |
|
|
return vendorPath
|
| 392 |
|
|
|
| 393 |
|
|
|
| 394 |
ninoborges |
8 |
class MyApp(wx.App):
|
| 395 |
|
|
def OnInit(self):
|
| 396 |
|
|
prgVersion = MCP_Lib.GetMCPVersion()
|
| 397 |
|
|
self.frame = MyFrame(None, -1, "MCP Copy Up Request %s"%prgVersion)
|
| 398 |
|
|
self.frame.Show(True)
|
| 399 |
|
|
self.SetTopWindow(self.frame)
|
| 400 |
|
|
return True
|
| 401 |
|
|
|
| 402 |
|
|
|
| 403 |
|
|
if __name__ == '__main__':
|
| 404 |
|
|
app = MyApp(0)
|
| 405 |
|
|
app.MainLoop() |