| 1 |
nino.borges |
894 |
|
| 2 |
|
|
"""
|
| 3 |
|
|
|
| 4 |
|
|
RelativitySearchReport_UI
|
| 5 |
|
|
|
| 6 |
|
|
Created by:
|
| 7 |
|
|
Emanuel Borges
|
| 8 |
|
|
05.25.2025
|
| 9 |
|
|
|
| 10 |
|
|
UI for the program that creates the Relativity Saved Search Report.
|
| 11 |
|
|
|
| 12 |
|
|
"""
|
| 13 |
|
|
|
| 14 |
|
|
import wx
|
| 15 |
|
|
import os
|
| 16 |
|
|
|
| 17 |
nino.borges |
897 |
version = '0.03'
|
| 18 |
nino.borges |
896 |
|
| 19 |
nino.borges |
894 |
class MyFrame(wx.Frame):
|
| 20 |
|
|
def __init__(self, parent, ID, title, pos=wx.DefaultPosition):
|
| 21 |
|
|
wx.Frame.__init__(self, parent, ID, title, pos, size=(600, 300))
|
| 22 |
|
|
self.panel = wx.Panel(self, -1)
|
| 23 |
|
|
|
| 24 |
|
|
self.serviceProviders = ["Foo", "Bar"]
|
| 25 |
|
|
self.workspaceOptions = {
|
| 26 |
|
|
"Foo": ["Spam", "Eggs", "EggsEggs"],
|
| 27 |
|
|
"Bar": ["Rabbit", "Lamp"]
|
| 28 |
|
|
}
|
| 29 |
|
|
|
| 30 |
|
|
self.CreateControls()
|
| 31 |
|
|
self.CreateButtons()
|
| 32 |
|
|
|
| 33 |
|
|
mainSizer = wx.BoxSizer(wx.VERTICAL)
|
| 34 |
|
|
mainSizer.Add(self.controlsSizer, 0, wx.ALL | wx.EXPAND, 20)
|
| 35 |
|
|
mainSizer.Add(self.filePicker, 0, wx.ALL | wx.EXPAND, 20)
|
| 36 |
|
|
mainSizer.Add(self.buttonSizer, 0, wx.ALL | wx.CENTER, 10)
|
| 37 |
|
|
|
| 38 |
|
|
self.panel.SetSizer(mainSizer)
|
| 39 |
|
|
self.CreateStatusBar()
|
| 40 |
|
|
self.SetStatusText("Ready.")
|
| 41 |
|
|
|
| 42 |
|
|
self.okButton.Disable()
|
| 43 |
|
|
|
| 44 |
|
|
def CreateControls(self):
|
| 45 |
nino.borges |
896 |
self.controlsSizer = wx.BoxSizer(wx.HORIZONTAL)
|
| 46 |
nino.borges |
894 |
|
| 47 |
|
|
self.serviceProviderLabel = wx.StaticText(self.panel, label="Service Provider")
|
| 48 |
|
|
self.serviceProviderChoice = wx.Choice(self.panel, choices=self.serviceProviders)
|
| 49 |
|
|
self.serviceProviderChoice.Bind(wx.EVT_CHOICE, self.OnServiceProviderSelected)
|
| 50 |
|
|
|
| 51 |
|
|
self.workspaceLabel = wx.StaticText(self.panel, label="Workspace")
|
| 52 |
|
|
self.workspaceChoice = wx.Choice(self.panel, choices=[])
|
| 53 |
|
|
self.workspaceChoice.Bind(wx.EVT_CHOICE, self.OnAnySelectionChanged)
|
| 54 |
|
|
|
| 55 |
nino.borges |
897 |
self.controlsSizer.Add(self.serviceProviderLabel, 0, wx.ALIGN_CENTER_VERTICAL | wx.RIGHT, 5)
|
| 56 |
|
|
self.controlsSizer.Add(self.serviceProviderChoice, 0, wx.RIGHT, 20)
|
| 57 |
|
|
self.controlsSizer.Add(self.workspaceLabel, 0, wx.ALIGN_CENTER_VERTICAL | wx.RIGHT, 5)
|
| 58 |
|
|
self.controlsSizer.Add(self.workspaceChoice, 0)
|
| 59 |
nino.borges |
896 |
|
| 60 |
nino.borges |
894 |
self.filePicker = wx.FilePickerCtrl(self.panel, message="Select a CSV file", wildcard="CSV files (*.csv)|*.csv")
|
| 61 |
|
|
self.filePicker.Bind(wx.EVT_FILEPICKER_CHANGED, self.OnAnySelectionChanged)
|
| 62 |
|
|
|
| 63 |
|
|
def CreateButtons(self):
|
| 64 |
|
|
self.okButton = wx.Button(self.panel, -1, "Ok")
|
| 65 |
|
|
self.cancelButton = wx.Button(self.panel, -1, "Cancel")
|
| 66 |
|
|
|
| 67 |
|
|
self.okButton.Bind(wx.EVT_BUTTON, self.OnProcess)
|
| 68 |
|
|
self.cancelButton.Bind(wx.EVT_BUTTON, self.CloseWindow)
|
| 69 |
|
|
|
| 70 |
|
|
self.buttonSizer = wx.BoxSizer(wx.HORIZONTAL)
|
| 71 |
|
|
self.buttonSizer.Add(self.okButton, 0, wx.ALL, 10)
|
| 72 |
|
|
self.buttonSizer.Add(self.cancelButton, 0, wx.ALL, 10)
|
| 73 |
|
|
|
| 74 |
|
|
def OnServiceProviderSelected(self, event):
|
| 75 |
|
|
selected_provider = self.serviceProviderChoice.GetStringSelection()
|
| 76 |
|
|
self.workspaceChoice.Set(self.workspaceOptions.get(selected_provider, []))
|
| 77 |
|
|
self.workspaceChoice.SetSelection(wx.NOT_FOUND)
|
| 78 |
|
|
self.OnAnySelectionChanged(None)
|
| 79 |
|
|
|
| 80 |
|
|
def OnAnySelectionChanged(self, event):
|
| 81 |
|
|
service_selected = self.serviceProviderChoice.GetSelection() != wx.NOT_FOUND
|
| 82 |
|
|
workspace_selected = self.workspaceChoice.GetSelection() != wx.NOT_FOUND
|
| 83 |
|
|
file_selected = bool(self.filePicker.GetPath())
|
| 84 |
|
|
if service_selected and workspace_selected and file_selected:
|
| 85 |
|
|
self.okButton.Enable()
|
| 86 |
|
|
else:
|
| 87 |
|
|
self.okButton.Disable()
|
| 88 |
|
|
|
| 89 |
|
|
def OnProcess(self, event):
|
| 90 |
|
|
print(f"Service Provider: {self.serviceProviderChoice.GetStringSelection()}")
|
| 91 |
|
|
print(f"Workspace: {self.workspaceChoice.GetStringSelection()}")
|
| 92 |
|
|
print(f"CSV File: {self.filePicker.GetPath()}")
|
| 93 |
|
|
|
| 94 |
|
|
def CloseWindow(self, event):
|
| 95 |
|
|
self.Close(True)
|
| 96 |
|
|
|
| 97 |
|
|
|
| 98 |
|
|
class MyApp(wx.App):
|
| 99 |
|
|
def OnInit(self):
|
| 100 |
|
|
self.frame = MyFrame(None, -1, "Excel Report Generator")
|
| 101 |
|
|
self.frame.Show(True)
|
| 102 |
|
|
self.SetTopWindow(self.frame)
|
| 103 |
|
|
return True
|
| 104 |
|
|
|
| 105 |
|
|
|
| 106 |
|
|
if __name__ == '__main__':
|
| 107 |
|
|
app = MyApp(0)
|
| 108 |
|
|
app.MainLoop()
|
| 109 |
nino.borges |
896 |
|
| 110 |
nino.borges |
897 |
|