| 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 |
|
|
import wx
|
| 15 |
|
|
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 |
|
|
def MenuData(self):
|
| 39 |
|
|
return(("&Help",
|
| 40 |
|
|
("&About", "Displays the About Window.", self.OnAbout)),)
|
| 41 |
|
|
|
| 42 |
|
|
def CreateMenuBar(self):
|
| 43 |
|
|
menuBar = wx.MenuBar()
|
| 44 |
|
|
for eachMenuData in self.MenuData():
|
| 45 |
|
|
menuLabel = eachMenuData[0]
|
| 46 |
|
|
menuItems = eachMenuData[1:]
|
| 47 |
|
|
menuBar.Append(self.CreateMenu(menuItems), menuLabel)
|
| 48 |
|
|
self.SetMenuBar(menuBar)
|
| 49 |
|
|
|
| 50 |
|
|
def CreateMenu(self, menuData):
|
| 51 |
|
|
menu = wx.Menu()
|
| 52 |
|
|
for eachLabel, eachStatus, eachHandler in menuData:
|
| 53 |
|
|
if not eachLabel:
|
| 54 |
|
|
menu.AppendSeparator()
|
| 55 |
|
|
continue
|
| 56 |
|
|
menuItem = menu.Append(-1, eachLabel, eachStatus)
|
| 57 |
|
|
self.Bind(wx.EVT_MENU, eachHandler, menuItem)
|
| 58 |
|
|
return menu
|
| 59 |
|
|
|
| 60 |
|
|
def CreateIntroText(self):
|
| 61 |
|
|
font = wx.Font(12, wx.SWISS, wx.NORMAL, wx.NORMAL)
|
| 62 |
|
|
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.""")
|
| 63 |
|
|
self.introText.SetFont(font)
|
| 64 |
|
|
|
| 65 |
|
|
|
| 66 |
|
|
def CreateBatesSection(self):
|
| 67 |
|
|
batesPrefixLabel = wx.StaticText(self.panel, -1, "Bates Prefix:")
|
| 68 |
|
|
self.batesPrefixTextBox = wx.TextCtrl(self.panel, -1, size=(90,-1))
|
| 69 |
|
|
#self.batesPrefixTextBox.Enable(False)
|
| 70 |
|
|
startingNumberLabel = wx.StaticText(self.panel, -1, "Starting Bates Number:")
|
| 71 |
|
|
self.startingNumberTextBox = wx.TextCtrl(self.panel, -1, size=(90,-1))
|
| 72 |
|
|
self.startingNumberTextBox.SetValue("1")
|
| 73 |
|
|
#self.startingNumberTextBox.Enable(False)
|
| 74 |
|
|
intBaseLabel = wx.StaticText(self.panel, -1, "Number Offset:")
|
| 75 |
|
|
self.intBaseTextBox = wx.TextCtrl(self.panel, -1, size=(45,-1))
|
| 76 |
|
|
self.intBaseTextBox.SetValue("1")
|
| 77 |
|
|
#self.intBaseTextBox.Enable(False)
|
| 78 |
|
|
#self.preserveOrRefactorRadio = wx.RadioBox(self, -1,"",choices = ['Preserve Directory Structure','Refactor Directory Structure'])
|
| 79 |
|
|
#self.preserveOrRefactorRadio.Enable(False)
|
| 80 |
|
|
|
| 81 |
|
|
batesOptionsSizer = wx.GridSizer(rows=3, cols=2, hgap=5, vgap=7)
|
| 82 |
|
|
batesOptionsSizer.Add(batesPrefixLabel)
|
| 83 |
|
|
batesOptionsSizer.Add(self.batesPrefixTextBox)
|
| 84 |
|
|
batesOptionsSizer.Add(startingNumberLabel)
|
| 85 |
|
|
batesOptionsSizer.Add(self.startingNumberTextBox)
|
| 86 |
|
|
batesOptionsSizer.Add(intBaseLabel)
|
| 87 |
|
|
batesOptionsSizer.Add(self.intBaseTextBox)
|
| 88 |
|
|
|
| 89 |
|
|
batesSectionStaticBox = wx.StaticBox(self.panel, -1, 'Bates Options')
|
| 90 |
|
|
self.batesSectionSizer = wx.StaticBoxSizer(batesSectionStaticBox, wx.VERTICAL)
|
| 91 |
|
|
self.batesSectionSizer.Add(batesOptionsSizer, 0, wx.ALL, 10)
|
| 92 |
|
|
#self.batesSectionSizer.Add(self.preserveOrRefactorRadio, 0, wx.ALL, 10)
|
| 93 |
|
|
|
| 94 |
|
|
def CreateBrowseSection(self):
|
| 95 |
|
|
self.startPath = filebrowse.DirBrowseButton(self.panel, -1, size=(420, -1))
|
| 96 |
|
|
self.startPath.SetLabel("Starting Dir:")
|
| 97 |
|
|
#self.outputPath = filebrowse.DirBrowseButton(self.panel, -1, size=(450, -1))
|
| 98 |
|
|
#self.outputPath.SetLabel("Output Dir")
|
| 99 |
|
|
self.browseSectionSizer = wx.BoxSizer(wx.VERTICAL)
|
| 100 |
|
|
self.browseSectionSizer.Add(self.startPath, 0, wx.ALIGN_RIGHT|wx.ALL, 5)
|
| 101 |
|
|
#self.browseSectionSizer.Add(self.outputPath, 0, wx.ALIGN_LEFT|wx.ALL, 5)
|
| 102 |
|
|
|
| 103 |
|
|
def CreateBoxesSection(self):
|
| 104 |
|
|
self.oKButton = wx.Button(self.panel, -1, "Ok", (10, 10))
|
| 105 |
|
|
self.oKButton.SetDefault()
|
| 106 |
|
|
self.oKButton.SetSize(self.oKButton.GetBestSize())
|
| 107 |
|
|
self.cancelButton = wx.Button(self.panel, -1, "Cancel", (10, 10))
|
| 108 |
|
|
self.cancelButton.SetSize(self.cancelButton.GetBestSize())
|
| 109 |
|
|
self.buttonSizer = wx.BoxSizer(wx.HORIZONTAL)
|
| 110 |
|
|
self.buttonSizer.Add(self.oKButton,0,wx.ALL,10)
|
| 111 |
|
|
self.buttonSizer.Add(self.cancelButton,0,wx.ALL,10)
|
| 112 |
|
|
|
| 113 |
|
|
def CloseWindow(self, event):
|
| 114 |
|
|
self.Close(True)
|
| 115 |
|
|
|
| 116 |
|
|
|
| 117 |
|
|
def Process(self, event):
|
| 118 |
|
|
pass
|
| 119 |
|
|
|
| 120 |
|
|
|
| 121 |
|
|
def OnAbout(self, event):
|
| 122 |
|
|
"""
|
| 123 |
|
|
OnAbout(self,event) Displays an about dialog with developer and bug reporting info
|
| 124 |
|
|
"""
|
| 125 |
|
|
dlg = wx.MessageDialog(self, "This program is used to create Native Productions\n"
|
| 126 |
|
|
"by allowing you to point to a top level native file folder,\n"
|
| 127 |
|
|
"select formatting options, and it will rename the files\n"
|
| 128 |
|
|
"contained with the formatting options you selected.\n\n"
|
| 129 |
|
|
"For questions or comments about this program\n"
|
| 130 |
|
|
"or to report a bug, please email the program\n"
|
| 131 |
|
|
"creator at Nino.Borges@gmail.com\n\n"
|
| 132 |
|
|
"NativeProduction is\n"
|
| 133 |
|
|
"Copyright(c) 2007 Emanuel Borges.\n"
|
| 134 |
|
|
"(Nino.Borges@gmail.com)\n",
|
| 135 |
|
|
"About NativeProduction", wx.OK | wx.ICON_INFORMATION)
|
| 136 |
|
|
dlg.ShowModal()
|
| 137 |
|
|
dlg.Destroy()
|
| 138 |
|
|
|
| 139 |
|
|
class MyApp(wx.App):
|
| 140 |
|
|
def OnInit(self):
|
| 141 |
|
|
self.frame = MyFrame(None, -1, "PDF Export to Data Load")
|
| 142 |
|
|
self.frame.Show(True)
|
| 143 |
|
|
self.SetTopWindow(self.frame)
|
| 144 |
|
|
return True
|
| 145 |
|
|
|
| 146 |
|
|
|
| 147 |
|
|
if __name__ == '__main__':
|
| 148 |
|
|
app = MyApp(0)
|
| 149 |
|
|
app.MainLoop() |