| 1 |
nino.borges |
437 |
"""
|
| 2 |
|
|
|
| 3 |
|
|
SingleTiffToLFP_UI
|
| 4 |
|
|
|
| 5 |
|
|
Created by
|
| 6 |
|
|
Emanuel Borges
|
| 7 |
|
|
08.23.2013
|
| 8 |
|
|
|
| 9 |
|
|
This will be the UI to the program that lets you make a Dat and LFP load from a PDF
|
| 10 |
|
|
tiff export.
|
| 11 |
|
|
|
| 12 |
|
|
"""
|
| 13 |
|
|
|
| 14 |
nino.borges |
444 |
import wx,SingleTiffToLFP,time,EulaExcepted
|
| 15 |
nino.borges |
437 |
import wx.lib.filebrowsebutton as filebrowse
|
| 16 |
|
|
|
| 17 |
|
|
class MyFrame(wx.Frame):
|
| 18 |
|
|
def __init__(self, parent, ID, title, pos=wx.DefaultPosition):
|
| 19 |
|
|
wx.Frame.__init__(self, parent, ID, title, pos, size =(450,390))
|
| 20 |
|
|
self.panel = wx.Panel(self,-1)
|
| 21 |
|
|
self.CreateIntroText()
|
| 22 |
|
|
self.CreateMenuBar()
|
| 23 |
|
|
self.CreateBatesSection()
|
| 24 |
|
|
self.CreateBrowseSection()
|
| 25 |
|
|
self.CreateBoxesSection()
|
| 26 |
|
|
|
| 27 |
|
|
mainSizer = wx.BoxSizer(wx.VERTICAL)
|
| 28 |
|
|
mainSizer.Add(self.introText, 0, wx.ALL, 10)
|
| 29 |
|
|
mainSizer.Add(self.browseSectionSizer, 0, wx.TOP, 15)
|
| 30 |
|
|
mainSizer.Add(self.batesSectionSizer, 0, wx.ALL, 15)
|
| 31 |
|
|
|
| 32 |
|
|
mainSizer.Add(self.buttonSizer,0, wx.ALIGN_CENTER|wx.ALL, 25)
|
| 33 |
|
|
self.SetSizer(mainSizer)
|
| 34 |
|
|
|
| 35 |
|
|
self.Bind(wx.EVT_BUTTON, self.Process, self.oKButton)
|
| 36 |
|
|
self.Bind(wx.EVT_BUTTON, self.CloseWindow, self.cancelButton)
|
| 37 |
|
|
|
| 38 |
nino.borges |
444 |
|
| 39 |
nino.borges |
437 |
def MenuData(self):
|
| 40 |
|
|
return(("&Help",
|
| 41 |
|
|
("&About", "Displays the About Window.", self.OnAbout)),)
|
| 42 |
|
|
|
| 43 |
|
|
def CreateMenuBar(self):
|
| 44 |
|
|
menuBar = wx.MenuBar()
|
| 45 |
|
|
for eachMenuData in self.MenuData():
|
| 46 |
|
|
menuLabel = eachMenuData[0]
|
| 47 |
|
|
menuItems = eachMenuData[1:]
|
| 48 |
|
|
menuBar.Append(self.CreateMenu(menuItems), menuLabel)
|
| 49 |
|
|
self.SetMenuBar(menuBar)
|
| 50 |
|
|
|
| 51 |
|
|
def CreateMenu(self, menuData):
|
| 52 |
|
|
menu = wx.Menu()
|
| 53 |
|
|
for eachLabel, eachStatus, eachHandler in menuData:
|
| 54 |
|
|
if not eachLabel:
|
| 55 |
|
|
menu.AppendSeparator()
|
| 56 |
|
|
continue
|
| 57 |
|
|
menuItem = menu.Append(-1, eachLabel, eachStatus)
|
| 58 |
|
|
self.Bind(wx.EVT_MENU, eachHandler, menuItem)
|
| 59 |
|
|
return menu
|
| 60 |
|
|
|
| 61 |
|
|
def CreateIntroText(self):
|
| 62 |
nino.borges |
443 |
font = wx.Font(11, wx.SWISS, wx.NORMAL, wx.NORMAL)
|
| 63 |
nino.borges |
437 |
self.introText = wx.StaticText(self.panel, -1, """Please select the directory of the tiffs, exported from PDFs,\nand the control numbers from the options below.""")
|
| 64 |
|
|
self.introText.SetFont(font)
|
| 65 |
|
|
|
| 66 |
|
|
|
| 67 |
|
|
def CreateBatesSection(self):
|
| 68 |
|
|
batesPrefixLabel = wx.StaticText(self.panel, -1, "Bates Prefix:")
|
| 69 |
|
|
self.batesPrefixTextBox = wx.TextCtrl(self.panel, -1, size=(90,-1))
|
| 70 |
|
|
#self.batesPrefixTextBox.Enable(False)
|
| 71 |
|
|
startingNumberLabel = wx.StaticText(self.panel, -1, "Starting Bates Number:")
|
| 72 |
|
|
self.startingNumberTextBox = wx.TextCtrl(self.panel, -1, size=(90,-1))
|
| 73 |
|
|
self.startingNumberTextBox.SetValue("1")
|
| 74 |
|
|
#self.startingNumberTextBox.Enable(False)
|
| 75 |
|
|
intBaseLabel = wx.StaticText(self.panel, -1, "Number Offset:")
|
| 76 |
|
|
self.intBaseTextBox = wx.TextCtrl(self.panel, -1, size=(45,-1))
|
| 77 |
|
|
self.intBaseTextBox.SetValue("1")
|
| 78 |
|
|
#self.intBaseTextBox.Enable(False)
|
| 79 |
|
|
#self.preserveOrRefactorRadio = wx.RadioBox(self, -1,"",choices = ['Preserve Directory Structure','Refactor Directory Structure'])
|
| 80 |
|
|
#self.preserveOrRefactorRadio.Enable(False)
|
| 81 |
|
|
|
| 82 |
|
|
batesOptionsSizer = wx.GridSizer(rows=3, cols=2, hgap=5, vgap=7)
|
| 83 |
|
|
batesOptionsSizer.Add(batesPrefixLabel)
|
| 84 |
|
|
batesOptionsSizer.Add(self.batesPrefixTextBox)
|
| 85 |
|
|
batesOptionsSizer.Add(startingNumberLabel)
|
| 86 |
|
|
batesOptionsSizer.Add(self.startingNumberTextBox)
|
| 87 |
|
|
batesOptionsSizer.Add(intBaseLabel)
|
| 88 |
|
|
batesOptionsSizer.Add(self.intBaseTextBox)
|
| 89 |
|
|
|
| 90 |
|
|
batesSectionStaticBox = wx.StaticBox(self.panel, -1, 'Bates Options')
|
| 91 |
|
|
self.batesSectionSizer = wx.StaticBoxSizer(batesSectionStaticBox, wx.VERTICAL)
|
| 92 |
|
|
self.batesSectionSizer.Add(batesOptionsSizer, 0, wx.ALL, 10)
|
| 93 |
|
|
#self.batesSectionSizer.Add(self.preserveOrRefactorRadio, 0, wx.ALL, 10)
|
| 94 |
|
|
|
| 95 |
|
|
def CreateBrowseSection(self):
|
| 96 |
|
|
self.startPath = filebrowse.DirBrowseButton(self.panel, -1, size=(420, -1))
|
| 97 |
|
|
self.startPath.SetLabel("Starting Dir:")
|
| 98 |
|
|
#self.outputPath = filebrowse.DirBrowseButton(self.panel, -1, size=(450, -1))
|
| 99 |
|
|
#self.outputPath.SetLabel("Output Dir")
|
| 100 |
|
|
self.browseSectionSizer = wx.BoxSizer(wx.VERTICAL)
|
| 101 |
|
|
self.browseSectionSizer.Add(self.startPath, 0, wx.ALIGN_RIGHT|wx.ALL, 5)
|
| 102 |
|
|
#self.browseSectionSizer.Add(self.outputPath, 0, wx.ALIGN_LEFT|wx.ALL, 5)
|
| 103 |
|
|
|
| 104 |
|
|
def CreateBoxesSection(self):
|
| 105 |
|
|
self.oKButton = wx.Button(self.panel, -1, "Ok", (10, 10))
|
| 106 |
|
|
self.oKButton.SetDefault()
|
| 107 |
|
|
self.oKButton.SetSize(self.oKButton.GetBestSize())
|
| 108 |
|
|
self.cancelButton = wx.Button(self.panel, -1, "Cancel", (10, 10))
|
| 109 |
|
|
self.cancelButton.SetSize(self.cancelButton.GetBestSize())
|
| 110 |
|
|
self.buttonSizer = wx.BoxSizer(wx.HORIZONTAL)
|
| 111 |
|
|
self.buttonSizer.Add(self.oKButton,0,wx.ALL,10)
|
| 112 |
|
|
self.buttonSizer.Add(self.cancelButton,0,wx.ALL,10)
|
| 113 |
|
|
|
| 114 |
|
|
def CloseWindow(self, event):
|
| 115 |
|
|
self.Close(True)
|
| 116 |
|
|
|
| 117 |
|
|
|
| 118 |
|
|
def Process(self, event):
|
| 119 |
nino.borges |
443 |
startDir = self.startPath.GetValue()
|
| 120 |
|
|
prefix = self.batesPrefixTextBox.GetValue()
|
| 121 |
|
|
startNumb = int(self.startingNumberTextBox.GetValue())
|
| 122 |
|
|
counterBase = int(self.intBaseTextBox.GetValue())
|
| 123 |
|
|
SingleTiffToLFP.Process(startDir,prefix,startNumb,counterBase)
|
| 124 |
|
|
finishedDiag = wx.MessageDialog(self,"All files have been processed.","Processing Complete.",wx.OK | wx.ICON_INFORMATION)
|
| 125 |
|
|
finishedDiag.ShowModal()
|
| 126 |
|
|
finishedDiag.Destroy()
|
| 127 |
|
|
self.Close(True)
|
| 128 |
|
|
|
| 129 |
nino.borges |
437 |
|
| 130 |
|
|
|
| 131 |
|
|
def OnAbout(self, event):
|
| 132 |
|
|
"""
|
| 133 |
|
|
OnAbout(self,event) Displays an about dialog with developer and bug reporting info
|
| 134 |
|
|
"""
|
| 135 |
nino.borges |
443 |
dlg = wx.MessageDialog(self, "This program creates importable data load files,\nfrom a directory of tiffs, "
|
| 136 |
|
|
"exported from PDF documents.\n\n"
|
| 137 |
nino.borges |
437 |
"For questions or comments about this program\n"
|
| 138 |
|
|
"or to report a bug, please email the program\n"
|
| 139 |
|
|
"creator at Nino.Borges@gmail.com\n\n"
|
| 140 |
nino.borges |
443 |
"PDF Export to Data Load is\n"
|
| 141 |
|
|
"Copyright(c) 2007 - 2013 Emanuel Borges.\n"
|
| 142 |
nino.borges |
437 |
"(Nino.Borges@gmail.com)\n",
|
| 143 |
nino.borges |
443 |
"About PDF Export to Data Load", wx.OK | wx.ICON_INFORMATION)
|
| 144 |
nino.borges |
437 |
dlg.ShowModal()
|
| 145 |
|
|
dlg.Destroy()
|
| 146 |
|
|
|
| 147 |
|
|
class MyApp(wx.App):
|
| 148 |
|
|
def OnInit(self):
|
| 149 |
nino.borges |
443 |
expireDate = 1393515831 # Just make this 6 months from now until you merge the validator from mCHAI. Always put this on your cal for the mwe version.
|
| 150 |
|
|
if expireDate > time.time():
|
| 151 |
nino.borges |
444 |
eulaExceptedStatus = EulaExcepted.EulaAlreadyAccepted()
|
| 152 |
|
|
if eulaExceptedStatus.eulaStatus:
|
| 153 |
|
|
pass
|
| 154 |
|
|
else:
|
| 155 |
|
|
dlg = EulaExcepted.EulaExceptedDialog(None)
|
| 156 |
|
|
if dlg.ShowModal() == wx.ID_OK:
|
| 157 |
|
|
eulaExceptedStatus.eulaStatus = True
|
| 158 |
|
|
eulaExceptedFile = open('EulaExcepted.txt','w')
|
| 159 |
|
|
eulaExceptedFile.write("True")
|
| 160 |
|
|
eulaExceptedFile.close()
|
| 161 |
|
|
dlg.Destroy()
|
| 162 |
|
|
if eulaExceptedStatus.eulaStatus:
|
| 163 |
|
|
self.frame = MyFrame(None, -1, " PDF Export to Data Load v 1.0.0")
|
| 164 |
|
|
self.frame.Show(True)
|
| 165 |
|
|
#self.frame.CheckFirstRun()
|
| 166 |
|
|
self.SetTopWindow(self.frame)
|
| 167 |
|
|
return True
|
| 168 |
|
|
else:
|
| 169 |
|
|
return False
|
| 170 |
nino.borges |
443 |
else:
|
| 171 |
|
|
deniedDlg = wx.MessageDialog(None, "Sorry but this version is tool old. Please download a new updated copy from http://ninosystems.com", "Version Expired.",wx.OK, wx.DefaultPosition)
|
| 172 |
|
|
deniedDlg.ShowModal()
|
| 173 |
|
|
return False
|
| 174 |
|
|
#self.frame = MyFrame(None, -1, "PDF Export to Data Load")
|
| 175 |
|
|
#self.frame.Show(True)
|
| 176 |
|
|
#self.SetTopWindow(self.frame)
|
| 177 |
|
|
#return True
|
| 178 |
nino.borges |
437 |
|
| 179 |
|
|
|
| 180 |
|
|
if __name__ == '__main__':
|
| 181 |
|
|
app = MyApp(0)
|
| 182 |
|
|
app.MainLoop() |