ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/ns_dev/Python/NinoCode/Active_prgs/Evidox/IncomingProdAnalyzer/Trunk/IncomingProdAnalyzer_UI.py
Revision: 697
Committed: Wed May 13 21:48:24 2020 UTC (5 years, 10 months ago) by nino.borges
Content type: text/x-python
Original Path: Python/NinoCode/Active_prgs/Evidox/IncomingProdAnalyzer/IncomingProdAnalyzer_UI.py
File size: 4026 byte(s)
Log Message:
Finished up the dat report dialog and added a bit more code to try to determine the encoding.

File Contents

# User Rev Content
1 nino.borges 693 """
2    
3     IncomingProdAnalyzer_UI
4    
5     Created by
6     Emanuel Borges
7     2020.05.12
8    
9     UI for the incoming prod analyzer program.
10    
11     """
12    
13    
14    
15    
16     import wx, os
17     import wx.lib.agw.pybusyinfo as PBI
18 nino.borges 697 import IncomingProdAnalyzer, DatReportDialog
19 nino.borges 693
20    
21    
22     class MyFrame(wx.Frame):
23     def __init__(self, parent, ID, title, pos=wx.DefaultPosition):
24     wx.Frame.__init__(self, parent, ID, title, pos, size = (350,325))
25     #db = ConcordanceConnection()
26     self.panel = wx.Panel(self,-1)
27     self.currentCaseStaticText = wx.StaticText(self.panel, -1, "Simple program for performing analysis on incoming productions before loading.",wx.DefaultPosition)
28    
29    
30     self.CreateBrowseSection()
31     self.fileNameBox = wx.TextCtrl(self.panel, -1, "", size=(190, -1), style=wx.TE_READONLY)
32     self.CreateBoxesSection()
33    
34    
35    
36     mainSizer = wx.BoxSizer(wx.VERTICAL)
37     mainSizer.Add(self.currentCaseStaticText,0,wx.ALL, 25)
38     mainSizer.Add(self.browseSectionSizer, 0, wx.ALIGN_CENTER|wx.ALL, 5)
39     mainSizer.Add(self.fileNameBox, 0, wx.ALIGN_CENTER|wx.ALL, 5)
40     mainSizer.Add(self.buttonSizer, 0, wx.ALIGN_CENTER|wx.ALL,25)
41     self.panel.SetSizer(mainSizer)
42    
43     #self.CreateStatusBar()
44     #self.SetStatusText("Ready.")
45    
46     self.oKButton.Disable()
47    
48     self.Bind(wx.EVT_BUTTON, self.Process, self.oKButton)
49     self.Bind(wx.EVT_BUTTON, self.CloseWindow, self.cancelButton)
50    
51     def CreateBrowseSection(self):
52     self.browseButton = wx.Button(self.panel, -1, "Select DAT File", (50,50))
53     self.Bind(wx.EVT_BUTTON, self.OnBrowseButton, self.browseButton)
54     self.browseSectionSizer = wx.BoxSizer(wx.VERTICAL)
55     self.browseSectionSizer.Add(self.browseButton,0, wx.ALIGN_RIGHT|wx.ALL, 5)
56    
57     def CreateBoxesSection(self):
58     self.oKButton = wx.Button(self.panel, -1, "Ok", (10,10))
59     self.oKButton.SetDefault()
60     self.oKButton.SetSize(self.oKButton.GetBestSize())
61     self.cancelButton = wx.Button(self.panel, -1, "Cancel", (10,10))
62     self.cancelButton.SetSize(self.cancelButton.GetBestSize())
63     self.buttonSizer = wx.BoxSizer(wx.HORIZONTAL)
64     self.buttonSizer.Add(self.oKButton, 0, wx.ALL,10)
65     self.buttonSizer.Add(self.cancelButton,0,wx.ALL,10)
66    
67     def OnBrowseButton(self, event):
68     dlg = wx.FileDialog(
69     self, message="Choose a file",
70     defaultDir=os.path.expanduser("~\\Documents"),
71     defaultFile="",
72     wildcard="DAT files (*.Dat)|*.Dat",
73     style=wx.FD_OPEN |
74     wx.FD_CHANGE_DIR | wx.FD_FILE_MUST_EXIST |
75     wx.FD_PREVIEW
76     )
77     if dlg.ShowModal() == wx.ID_OK:
78     self.rawReportPath = dlg.GetPath()
79     self.fileNameBox.SetValue(os.path.split(dlg.GetPath())[1])
80     self.oKButton.Enable()
81    
82    
83    
84     def Process(self,event):
85     message = "Analyzing your DAT file..."
86     busy = PBI.PyBusyInfo(message, parent=self, title="System Busy: Hold Yer Horses!")
87 nino.borges 697 totalRecordCount, fullFieldList, populatedFieldsList, emptyFieldsList, parsingErrorCount = IncomingProdAnalyzer.AnalyzeDAT(self.rawReportPath)
88 nino.borges 693 del busy
89 nino.borges 697 dlg = DatReportDialog.DatReportDialog(self, totalRecordCount, fullFieldList, populatedFieldsList, emptyFieldsList, parsingErrorCount)
90     dlg.ShowModal()
91     dlg.Destroy()
92     #finishedDiag = wx.MessageDialog(self, "Analysis complete.", "Processing Complete.", wx.OK | wx.ICON_INFORMATION)
93     #finishedDiag.ShowModal()
94     #finishedDiag.Destroy()
95 nino.borges 693 self.Close(True)
96    
97     def CloseWindow(self,event):
98     self.Close(True)
99    
100     class MyApp(wx.App):
101     def OnInit(self):
102 nino.borges 697 self.frame = MyFrame(None, -1, "Incoming Production Analyzer v 1.2")
103 nino.borges 693 self.frame.Show(True)
104     self.SetTopWindow(self.frame)
105     return True
106    
107    
108     if __name__ == '__main__':
109     app = MyApp(0)
110     app.MainLoop()