ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/ns_dev/Python/NinoCode/Active_prgs/Evidox/EvidenceItemLogCreator/EvidenceItemLogCreator_UI.py
Revision: 681
Committed: Thu May 7 15:31:41 2020 UTC (5 years, 10 months ago) by nino.borges
Content type: text/x-python
File size: 3593 byte(s)
Log Message:
Updated by adding a GUI and making the main program GUI friendly.

File Contents

# User Rev Content
1 nino.borges 681 """
2     Created by Emanuel Borges
3     2020.05.04
4    
5     GUI for the Evidence Item Log Creator Program
6    
7     """
8    
9    
10     import wx, os
11     import EvidenceItemLogCreator
12    
13    
14    
15     class MyFrame(wx.Frame):
16     def __init__(self, parent, ID, title, pos=wx.DefaultPosition):
17     wx.Frame.__init__(self, parent, ID, title, pos, size = (350,325))
18     #db = ConcordanceConnection()
19     self.panel = wx.Panel(self,-1)
20     self.currentCaseStaticText = wx.StaticText(self.panel, -1, "This simple program will take an exported evidence\nreport from the XPM app and convert it to a report\nthat can be shared with a client.",wx.DefaultPosition)
21    
22    
23     self.CreateBrowseSection()
24     self.fileNameBox = wx.TextCtrl(self.panel, -1, "", size=(190, -1), style=wx.TE_READONLY)
25     self.CreateBoxesSection()
26    
27    
28    
29     mainSizer = wx.BoxSizer(wx.VERTICAL)
30     mainSizer.Add(self.currentCaseStaticText,0,wx.ALL, 25)
31     mainSizer.Add(self.browseSectionSizer, 0, wx.ALIGN_CENTER|wx.ALL, 5)
32     mainSizer.Add(self.fileNameBox, 0, wx.ALIGN_CENTER|wx.ALL, 5)
33     mainSizer.Add(self.buttonSizer, 0, wx.ALIGN_CENTER|wx.ALL,25)
34     self.panel.SetSizer(mainSizer)
35    
36     self.CreateStatusBar()
37     self.SetStatusText("Ready.")
38    
39     self.oKButton.Disable()
40    
41     self.Bind(wx.EVT_BUTTON, self.Process, self.oKButton)
42     self.Bind(wx.EVT_BUTTON, self.CloseWindow, self.cancelButton)
43    
44     def CreateBrowseSection(self):
45     self.browseButton = wx.Button(self.panel, -1, "SelectReport", (50,50))
46     self.Bind(wx.EVT_BUTTON, self.OnBrowseButton, self.browseButton)
47     self.browseSectionSizer = wx.BoxSizer(wx.VERTICAL)
48     self.browseSectionSizer.Add(self.browseButton,0, wx.ALIGN_RIGHT|wx.ALL, 5)
49    
50     def CreateBoxesSection(self):
51     self.oKButton = wx.Button(self.panel, -1, "Ok", (10,10))
52     self.oKButton.SetDefault()
53     self.oKButton.SetSize(self.oKButton.GetBestSize())
54     self.cancelButton = wx.Button(self.panel, -1, "Cancel", (10,10))
55     self.cancelButton.SetSize(self.cancelButton.GetBestSize())
56     self.buttonSizer = wx.BoxSizer(wx.HORIZONTAL)
57     self.buttonSizer.Add(self.oKButton, 0, wx.ALL,10)
58     self.buttonSizer.Add(self.cancelButton,0,wx.ALL,10)
59    
60     def OnBrowseButton(self, event):
61     dlg = wx.FileDialog(
62     self, message="Choose a file",
63     defaultDir=os.path.expanduser("~\\Downloads"),
64     defaultFile="",
65     wildcard="All files (*.*)|*.*",
66     style=wx.FD_OPEN |
67     wx.FD_CHANGE_DIR | wx.FD_FILE_MUST_EXIST |
68     wx.FD_PREVIEW
69     )
70     if dlg.ShowModal() == wx.ID_OK:
71     self.rawReportPath = dlg.GetPath()
72     self.fileNameBox.SetValue(os.path.split(dlg.GetPath())[1])
73     self.oKButton.Enable()
74    
75    
76    
77     def Process(self,event):
78     EvidenceItemLogCreator.CreateEvidenceItemLog(self.rawReportPath)
79     finishedDiag = wx.MessageDialog(self, "Report has been created and saved to the same path.", "Processing Complete.", wx.OK | wx.ICON_INFORMATION)
80     finishedDiag.ShowModal()
81     finishedDiag.Destroy()
82     self.Close(True)
83    
84     def CloseWindow(self,event):
85     self.Close(True)
86    
87     class MyApp(wx.App):
88     def OnInit(self):
89     self.frame = MyFrame(None, -1, "Evidence Item Log Creator v 1.0")
90     self.frame.Show(True)
91     self.SetTopWindow(self.frame)
92     return True
93    
94    
95     if __name__ == '__main__':
96     app = MyApp(0)
97     app.MainLoop()