ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/ns_dev/Python/NinoCode/Active_prgs/MCP/Retired/MCP_CopyUp_Request_UI.py
Revision: 8
Committed: Sat May 5 04:21:19 2012 UTC (13 years, 10 months ago) by ninoborges
Content type: text/x-python
File size: 7661 byte(s)
Log Message:
Initial Import

File Contents

# User Rev Content
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     wx.Frame.__init__(self, parent, ID, title, pos, size =(585,380))
19     self.panel = wx.Panel(self,-1)
20     #self.panel.SetBackgroundColour("yellow green")
21     casesListStaticText = wx.StaticText(self.panel, -1, "Select Case: ",wx.DefaultPosition)
22     casesList,casesDir = MCP_Lib.GetCaseList()
23     self.casesListChoice = wx.Choice(self.panel, -1, wx.DefaultPosition, choices=casesList)
24     workDirStaticText = wx.StaticText(self.panel, -1, "Select Work Dir:",wx.DefaultPosition)
25     self.workDirControl = wx.TextCtrl(self.panel,-1,os.path.join(os.environ.get("USERPROFILE"),"Desktop\\Working"), size=(296,-1))
26     workDirBrowseButton = wx.Button(self.panel, -1, "Browse", (10, 10))
27    
28    
29     self.radio1 = wx.RadioButton(self.panel, -1, 'Individual File',style=wx.RB_GROUP)
30     self.fileBowserControl = wx.TextCtrl(self.panel, -1,size=(296,-1))
31     self.fileBowserButton = wx.Button(self.panel, -1, "Browse", (10, 10))
32    
33     self.radio2 = wx.RadioButton(self.panel, -1, 'Entire folder of Files')
34     self.dirBowserControl = wx.TextCtrl(self.panel, -1, size=(296,-1))
35     self.dirBowserButton = wx.Button(self.panel, -1, "Browse", (10, 10))
36     self.dirBowserControl.Enable(False)
37     self.dirBowserButton.Enable(False)
38    
39    
40     self.CreateBoxesSection()
41     copyUpTypeStaticBox = wx.StaticBox(self.panel, -1, 'Copy Up:')
42     copyUpTypeStaticBoxSizer = wx.StaticBoxSizer(copyUpTypeStaticBox, wx.VERTICAL)
43    
44     radio1Sizer = wx.FlexGridSizer(1,3,10,10)
45     radio1Sizer.Add(self.radio1, 0, 0)
46     radio1Sizer.Add(self.fileBowserControl, 0)
47     radio1Sizer.Add(self.fileBowserButton, 0)
48     copyUpTypeStaticBoxSizer.Add(radio1Sizer, 0, wx.ALL|wx.ALIGN_LEFT,20)
49     radio2Sizer = wx.FlexGridSizer(1,3,10,10)
50     radio2Sizer.Add(self.radio2, 0)
51     radio2Sizer.Add(self.dirBowserControl, 0)
52     radio2Sizer.Add(self.dirBowserButton, 0)
53     copyUpTypeStaticBoxSizer.Add(radio2Sizer, 0, wx.ALL|wx.ALIGN_LEFT,20)
54    
55     casesSizer = wx.BoxSizer(wx.HORIZONTAL)
56     casesSizer.Add(casesListStaticText,0,wx.ALL,5)
57     casesSizer.Add(self.casesListChoice,0,wx.ALL,5)
58     workDirSizer = wx.BoxSizer(wx.HORIZONTAL)
59     workDirSizer.Add(workDirStaticText,0,wx.ALL,5)
60     workDirSizer.Add(self.workDirControl,0,wx.ALL,5)
61     workDirSizer.Add(workDirBrowseButton,0,wx.ALL,5)
62     mainSizer = wx.BoxSizer(wx.VERTICAL)
63     mainSizer.Add(casesSizer,0,wx.ALL, 20)
64     mainSizer.Add(workDirSizer,0,wx.ALL, 10)
65     mainSizer.Add(copyUpTypeStaticBoxSizer, 0, wx.ALL, 10)
66     mainSizer.Add(self.buttonSizer,0, wx.ALL|wx.ALIGN_BOTTOM|wx.ALIGN_CENTER, 10)
67    
68     self.panel.SetSizer(mainSizer)
69     self.Bind(wx.EVT_RADIOBUTTON, self.OnRadio, self.radio1)
70     self.Bind(wx.EVT_RADIOBUTTON, self.OnRadio, self.radio2)
71     self.Bind(wx.EVT_BUTTON, self.OnBrowseClick, workDirBrowseButton)
72     self.Bind(wx.EVT_BUTTON, self.OnBrowseClick, self.fileBowserButton)
73     self.Bind(wx.EVT_BUTTON, self.OnBrowseClick, self.dirBowserButton)
74     self.Bind(wx.EVT_BUTTON, self.OnProcess, self.oKButton)
75     self.Bind(wx.EVT_BUTTON, self.CloseWindow, self.cancelButton)
76    
77     def OnRadio(self,event):
78     radioObj = event.GetEventObject()
79     selection = radioObj.GetLabel()
80     if selection == "Individual File":
81     self.fileBowserControl.Enable(True)
82     self.fileBowserButton.Enable(True)
83    
84     self.dirBowserControl.Enable(False)
85     self.dirBowserButton.Enable(False)
86     self.dirBowserControl.SetValue("")
87     else:
88     self.fileBowserControl.Enable(False)
89     self.fileBowserButton.Enable(False)
90     self.fileBowserControl.SetValue("")
91    
92     self.dirBowserControl.Enable(True)
93     self.dirBowserButton.Enable(True)
94    
95     #if self.selectedText:
96     # self.selectedText.Enable(False)
97     #radioSelected = event.GetEventObject()
98     #text = self.texts[radioSelected.GetLabel()]
99     #text.Enable(True)
100     #self.selectedText = text
101    
102     def OnBrowseClick(self,event):
103     eventCode = event.GetId()
104     if eventCode == -207:
105     dlg = wx.DirDialog(self, message = "Working Directory Path: ", defaultPath = os.path.join(os.environ.get("USERPROFILE"),"Desktop\\Working"))
106     if dlg.ShowModal() == wx.ID_OK:
107     dirPath = dlg.GetPath()
108     dlg.Destroy()
109     self.workDirControl.SetValue(dirPath)
110     elif eventCode == -210:
111     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)
112     #dlg = wx.FileDialog(self, message = "Select directory to copy up: ", defaultPath = os.path.join(os.environ.get("USERPROFILE"),"Desktop\\Working"))
113     if dlg.ShowModal() == wx.ID_OK:
114     filePath = dlg.GetPath()
115     dlg.Destroy()
116     self.fileBowserControl.SetValue(filePath)
117     elif eventCode == -213:
118     dlg = wx.DirDialog(self, message = "Select directory to copy up:", defaultPath = os.path.join(os.environ.get("USERPROFILE"),"Desktop\\Working"))
119     if dlg.ShowModal() == wx.ID_OK:
120     dirPath = dlg.GetPath()
121     dlg.Destroy()
122     self.dirBowserControl.SetValue(dirPath)
123    
124     def CreateBoxesSection(self):
125     self.oKButton = wx.Button(self.panel, wx.ID_OK)
126     self.oKButton.SetDefault()
127     self.oKButton.SetSize(self.oKButton.GetBestSize())
128     self.cancelButton = wx.Button(self.panel, wx.ID_CANCEL)
129     self.cancelButton.SetSize(self.cancelButton.GetBestSize())
130     self.buttonSizer = wx.BoxSizer(wx.HORIZONTAL)
131     self.buttonSizer.Add(self.oKButton,0,wx.ALL,10)
132     self.buttonSizer.Add(self.cancelButton,0,wx.ALL,10)
133    
134     def CloseWindow(self, event):
135     self.Close(True)
136    
137     def OnProcess(self, event):
138     caseName = self.casesListChoice.GetStringSelection()
139     workDir = self.workDirControl.GetValue()
140     #workDir = r"E:"
141     if self.radio1.GetValue():
142     startSelection = self.fileBowserControl.GetValue()
143     else:
144     startSelection = self.dirBowserControl.GetValue()
145     #startSelection = r"C:\Documents and Settings\eborges\Desktop\Working\Misc_Documents.zip"
146     self.Show(False)
147     #print "workdir is %s"%workDir
148     MCP_CopyUp_Request.Process(caseName, workDir, startSelection)
149    
150     #diag = wx.MessageDialog(self,"All Items processed and copied!!", "Complete",wx.OK | wx.ICON_INFORMATION)
151     #diag.ShowModal()
152     #diag.Destroy()
153     self.Destroy()
154    
155    
156    
157    
158    
159     class MyApp(wx.App):
160     def OnInit(self):
161     prgVersion = MCP_Lib.GetMCPVersion()
162     self.frame = MyFrame(None, -1, "MCP Copy Up Request %s"%prgVersion)
163     self.frame.Show(True)
164     self.SetTopWindow(self.frame)
165     return True
166    
167    
168     if __name__ == '__main__':
169     app = MyApp(0)
170     app.MainLoop()