| 1 |
ninoborges |
8 |
"""
|
| 2 |
|
|
Version .01
|
| 3 |
|
|
Created by Emanuel Borges
|
| 4 |
|
|
11.21.06
|
| 5 |
|
|
|
| 6 |
|
|
This is the GUI to the SumReporter program. See that doc string for more information.
|
| 7 |
|
|
|
| 8 |
|
|
DEPENDS:
|
| 9 |
|
|
- SumReporter.py
|
| 10 |
|
|
|
| 11 |
|
|
"""
|
| 12 |
|
|
|
| 13 |
|
|
import wx, SumReporter
|
| 14 |
|
|
import wx.lib.filebrowsebutton as filebrowse
|
| 15 |
|
|
|
| 16 |
|
|
|
| 17 |
|
|
class MyFrame(wx.Frame):
|
| 18 |
|
|
def __init__(self, parent, ID, title, pos, size):
|
| 19 |
|
|
wx.Frame.__init__(self, parent, ID, title, pos, size)
|
| 20 |
|
|
self.mainNbk = wx.Notebook(self)
|
| 21 |
|
|
mainPanel = wx.Panel(self.mainNbk)
|
| 22 |
|
|
historyPanel = wx.Panel(self.mainNbk)
|
| 23 |
|
|
|
| 24 |
|
|
#casesPathStatic = wx.StaticText(mainPanel, -1, "Cases Path")
|
| 25 |
|
|
self.casesPathWig = filebrowse.DirBrowseButton(mainPanel, -1, size=(450, -1))
|
| 26 |
|
|
self.casesPathWig.SetLabel("Cases Path")
|
| 27 |
|
|
#outputPathStatic = wx.StaticText(mainPanel, -1, "Output Path")
|
| 28 |
|
|
self.outputPathWig = filebrowse.DirBrowseButton(mainPanel, -1, size=(450, -1))
|
| 29 |
|
|
self.outputPathWig.SetLabel("Output Path")
|
| 30 |
|
|
|
| 31 |
|
|
formatList = ["HTML Page","Comma Seperated (CSV) "]
|
| 32 |
|
|
self.outputFormatWig = wx.RadioBox(
|
| 33 |
|
|
mainPanel, -1, " Output Format Preference ", wx.DefaultPosition, wx.DefaultSize,
|
| 34 |
|
|
formatList, 1, wx.RA_SPECIFY_COLS
|
| 35 |
|
|
)
|
| 36 |
|
|
self.outputFormatWig.SetToolTip(wx.ToolTip("HTML is better for viewing but CSV is better for sorting."))
|
| 37 |
|
|
|
| 38 |
|
|
buttonSizer = wx.BoxSizer(wx.HORIZONTAL)
|
| 39 |
|
|
processButton = wx.Button(mainPanel, -1, "Process", (10, 10))
|
| 40 |
|
|
processButton.Bind(wx.EVT_BUTTON, self.ProcessFiles, processButton)
|
| 41 |
|
|
processButton.SetDefault()
|
| 42 |
|
|
processButton.SetSize(processButton.GetBestSize())
|
| 43 |
|
|
cancelButton = wx.Button(mainPanel, -1, "Cancel", (10, 10))
|
| 44 |
|
|
cancelButton.Bind(wx.EVT_BUTTON, self.CloseWindow, cancelButton)
|
| 45 |
|
|
cancelButton.SetSize(cancelButton.GetBestSize())
|
| 46 |
|
|
buttonSizer.Add(processButton,0,wx.ALL,5)
|
| 47 |
|
|
buttonSizer.Add(cancelButton,0,wx.ALL,5)
|
| 48 |
|
|
|
| 49 |
|
|
sizer2 = wx.BoxSizer(wx.VERTICAL)
|
| 50 |
|
|
sizer = wx.BoxSizer(wx.VERTICAL)#HORIZONTAL)
|
| 51 |
|
|
sizer.Add(self.casesPathWig,0, wx.ALIGN_LEFT|wx.ALL, 5)
|
| 52 |
|
|
sizer.Add(self.outputPathWig,0, wx.ALIGN_LEFT|wx.ALL, 5)
|
| 53 |
|
|
sizer.Add(self.outputFormatWig,0, wx.ALIGN_LEFT|wx.ALL, 20)
|
| 54 |
|
|
sizer.Add(buttonSizer,0, wx.ALIGN_CENTER|wx.ALL, 30)
|
| 55 |
|
|
sizer2.Add(sizer, 0, wx.ALIGN_CENTER|wx.ALL, 20)
|
| 56 |
|
|
mainPanel.SetSizer(sizer2)
|
| 57 |
|
|
#self.Fit()
|
| 58 |
|
|
|
| 59 |
|
|
self.historyChoicesDict = {}
|
| 60 |
|
|
historyFileContents = open("History.Dat",'r').readlines()
|
| 61 |
|
|
for line in historyFileContents:
|
| 62 |
|
|
line = line.split("\n")[0]
|
| 63 |
|
|
self.historyChoicesDict[line] = "1"
|
| 64 |
|
|
# change to self something from file
|
| 65 |
|
|
self.historyChoices = self.historyChoicesDict.keys()
|
| 66 |
|
|
#self.historyChoices = [r"\\jac\iblazej\cases",r"\\mwcase001\iblazer\cases"]
|
| 67 |
|
|
|
| 68 |
|
|
historySelectDiscriptor = wx.StaticText(historyPanel, -1, "Double-Click on previous Case locations to use that profile:")
|
| 69 |
|
|
self.historyListSelect = wx.ListBox(historyPanel, -1, size=(-1, -1), choices=self.historyChoices, style=wx.LB_SINGLE)
|
| 70 |
|
|
self.historyListSelect.Bind(wx.EVT_LISTBOX_DCLICK,self.UpdateCasesPath)
|
| 71 |
|
|
historySizer = wx.BoxSizer(wx.VERTICAL)
|
| 72 |
|
|
historySizer.Add(historySelectDiscriptor, 0, wx.ALIGN_CENTER|wx.ALL,10)
|
| 73 |
|
|
historySizer.Add(self.historyListSelect,0, wx.ALIGN_CENTER|wx.ALL,10)
|
| 74 |
|
|
mainHistorySizer = wx.BoxSizer(wx.VERTICAL)
|
| 75 |
|
|
mainHistorySizer.Add(historySizer, 0, wx.ALIGN_CENTER|wx.ALL, 40)
|
| 76 |
|
|
historyPanel.SetSizer(mainHistorySizer)
|
| 77 |
|
|
|
| 78 |
|
|
# Add panels to the notebook
|
| 79 |
|
|
self.mainNbk.AddPage(mainPanel, "Process Report")
|
| 80 |
|
|
self.mainNbk.AddPage(historyPanel,"Other Install Point History")
|
| 81 |
|
|
|
| 82 |
|
|
def CloseWindow(self, null):
|
| 83 |
|
|
self.Close(True)
|
| 84 |
|
|
|
| 85 |
|
|
def UpdateCasesPath(self,null):
|
| 86 |
|
|
for choice in self.historyListSelect.GetSelections():
|
| 87 |
|
|
self.casesPathWig.SetValue(self.historyChoices[choice])
|
| 88 |
|
|
self.mainNbk.SetSelection(0)
|
| 89 |
|
|
|
| 90 |
|
|
def ProcessFiles(self, null):
|
| 91 |
|
|
if self.outputFormatWig.GetSelection() == 0:
|
| 92 |
|
|
outputFormat = "HTML"
|
| 93 |
|
|
else:
|
| 94 |
|
|
outputFormat = "TXT"
|
| 95 |
|
|
test = wx.StockCursor(wx.CURSOR_ARROWWAIT)
|
| 96 |
|
|
wx.SetCursor(test)
|
| 97 |
|
|
SumReporter.compileReport(self.casesPathWig.GetValue(), self.outputPathWig.GetValue(),outputFormat)
|
| 98 |
|
|
self.historyChoicesDict[self.casesPathWig.GetValue()] = "1"
|
| 99 |
|
|
output = open("History.Dat",'w')
|
| 100 |
|
|
for newLine in self.historyChoicesDict.keys():
|
| 101 |
|
|
output.write(newLine + "\n")
|
| 102 |
|
|
output.close()
|
| 103 |
|
|
diag = wx.MessageDialog(self,"Processing Complete!\n Your output file was written to %s\\sumReporterIndex.%s"%(self.outputPathWig.GetValue(),outputFormat), "SumReporter",wx.OK | wx.ICON_INFORMATION)
|
| 104 |
|
|
diag.ShowModal()
|
| 105 |
|
|
diag.Destroy()
|
| 106 |
|
|
self.casesPathWig.SetValue("")
|
| 107 |
|
|
self.outputPathWig.SetValue("")
|
| 108 |
|
|
|
| 109 |
|
|
|
| 110 |
|
|
class MyApp(wx.App):
|
| 111 |
|
|
def OnInit(self):
|
| 112 |
|
|
frame = MyFrame(None, -1, "Summation Case Report Tool v.01", (50,60),(490,320))
|
| 113 |
|
|
frame.Show()
|
| 114 |
|
|
self.SetTopWindow(frame)
|
| 115 |
|
|
return True
|
| 116 |
|
|
|
| 117 |
|
|
|
| 118 |
|
|
if __name__ == '__main__':
|
| 119 |
|
|
app = MyApp(redirect=False)
|
| 120 |
|
|
app.MainLoop()
|
| 121 |
|
|
|