| 1 |
## ImgInfoToDII.py
|
| 2 |
## This program will convert an export from Summation's imginfo table into a Dii file for easy import into another Summation
|
| 3 |
## database. The export must be in the format of Imgtag,Defdir,Imgfiles\n . Comma separated and NO column headings.
|
| 4 |
## EBorges
|
| 5 |
## 8.23.04
|
| 6 |
|
| 7 |
import Pmw
|
| 8 |
from tkFileDialog import askopenfilename,asksaveasfilename
|
| 9 |
from tkMessageBox import showinfo
|
| 10 |
|
| 11 |
|
| 12 |
def Main():
|
| 13 |
root = Pmw.initialise()
|
| 14 |
MainNb = Pmw.NoteBook(root)
|
| 15 |
MainNb.pack()
|
| 16 |
AddPage = MainNb.add('Convert')
|
| 17 |
MainNb.tab('Convert').focus_set()
|
| 18 |
HelpPage = MainNb.add('Help')
|
| 19 |
About = MainNb.add('About')
|
| 20 |
copyRightText = copyRightInfo()
|
| 21 |
groupA = Pmw.Group(About, tag_text = 'About ImgInfoToDii')
|
| 22 |
groupA.pack(fill = 'both', expand = 1, padx = 10, pady = 10)
|
| 23 |
copyRight = Pmw.LabeledWidget(groupA.interior(), labelpos = 'w',label_text = copyRightText)
|
| 24 |
copyRight.pack()
|
| 25 |
group = Pmw.Group(AddPage, tag_text = 'Create Dii')
|
| 26 |
group.pack(fill = 'both', expand = 1, padx = 10, pady = 10)
|
| 27 |
groupR = Pmw.Group(HelpPage, tag_text = 'Program Usage')
|
| 28 |
groupR.pack(fill = 'both', expand = 1, padx = 10, pady = 10)
|
| 29 |
buttonBoxBrowse = Pmw.ButtonBox(group.interior(),orient='vertical')
|
| 30 |
buttonBoxBrowse.pack(side = 'right',anchor="nw",padx = 15, pady = 5)
|
| 31 |
ImgInfoA = Pmw.EntryField(group.interior(), labelpos = 'w',label_text = 'ImgInfo Export:')
|
| 32 |
DiiA =Pmw.EntryField(group.interior(), labelpos = 'w',label_text = 'New Dii File: ')
|
| 33 |
ImgInfoA.pack(side='top',padx = 20, pady = 10, anchor="w")
|
| 34 |
DiiA.pack(side='top',padx = 20, pady = 10, anchor="w")
|
| 35 |
buttonBoxBrowse.add('Browse',command = lambda openBox = ImgInfoA:OpenFile(openBox))
|
| 36 |
buttonBoxBrowse.add('Browse2',command = lambda saveBox = DiiA:SaveFile(saveBox))
|
| 37 |
NotesA = Pmw.ScrolledText(group.interior(),labelpos = 'nw',label_text = 'Notes...', usehullsize = 1,hull_width = 214,hull_height = 75)
|
| 38 |
NotesA.pack(padx = 20, pady = 0, anchor="w")
|
| 39 |
NotesR = Pmw.ScrolledText(groupR.interior(), usehullsize = 1,hull_width = 290,hull_height = 160)
|
| 40 |
NotesR.settext(UsageInfo())
|
| 41 |
NotesR.pack(padx = 20, pady = 0, anchor="w")
|
| 42 |
buttonBoxA = Pmw.ButtonBox(group.interior())
|
| 43 |
buttonBoxA.pack()
|
| 44 |
buttonBoxA.add('OK',command = (lambda ImgInfoObj = ImgInfoA, DiiObj = DiiA,NotesObj = NotesA:ConvertToDii(ImgInfoObj,DiiObj,NotesObj)))
|
| 45 |
buttonBoxA.add('Cancel',command = root.destroy)
|
| 46 |
#MainNb.setnaturalsize()
|
| 47 |
root.title('ImgInfo to DII')
|
| 48 |
root.mainloop()
|
| 49 |
|
| 50 |
def ConvertToDii(ImgInfo,Dii,NotesObj):
|
| 51 |
ImgInfoPath = ImgInfo.get()
|
| 52 |
DiiPath = Dii.get()
|
| 53 |
output = open(DiiPath,'w')
|
| 54 |
output.write("; %s\n; This Dii file was created by ImgToDii. A Summation tool written by Emanuel Borges email:Nino.Borges@Gmail.com\n; The newest version of this program can be found at http://64.83.11.5:8080/NinoSystems/imgtodii\n\n\n"%NotesObj.get())
|
| 55 |
imgInfo = open(ImgInfoPath,'r').readlines()
|
| 56 |
for line in imgInfo:
|
| 57 |
line = line.replace('"','')
|
| 58 |
line = line.replace(' ','')
|
| 59 |
begBates,commonDir,tiffDirs = line.split(",")
|
| 60 |
output.write("@T %s\n@D %s\n"% (begBates,commonDir))
|
| 61 |
tiffDirs = tiffDirs.split('\n')[0]
|
| 62 |
tiffDirs = tiffDirs.split(';')
|
| 63 |
for i in tiffDirs:
|
| 64 |
output.write(" " + i +"\n")
|
| 65 |
output.write("\n")
|
| 66 |
output.close()
|
| 67 |
showinfo(title="Conversion Complete!", message="The conversion is now complete and the Dii file has been saved here:\n%s"%DiiPath)
|
| 68 |
|
| 69 |
|
| 70 |
|
| 71 |
def OpenFile(openBox):
|
| 72 |
imageInfoFilePath = askopenfilename(title="Please select the exported ImgInfo file...")
|
| 73 |
openBox.setentry(imageInfoFilePath)
|
| 74 |
def SaveFile(saveBox):
|
| 75 |
diiFilePath = asksaveasfilename(title="Save as...", filetypes=[("Dii files",".Dii"),("All files","*")])
|
| 76 |
saveBox.setentry(diiFilePath)
|
| 77 |
|
| 78 |
def UsageInfo():
|
| 79 |
mainText = """How to use this program:
|
| 80 |
|
| 81 |
*** Note: This program does not come with a
|
| 82 |
warrantee. You use it at your own
|
| 83 |
risk.
|
| 84 |
|
| 85 |
- First create an export file from your ImgInfoTable
|
| 86 |
with only the following fields Imgtag,Defdir,Imgfiles.
|
| 87 |
These should be comma separated and contain no
|
| 88 |
column headings. This can be set in Export Setup
|
| 89 |
in Summation.
|
| 90 |
|
| 91 |
- Next input the exported txt file and the Dii file you
|
| 92 |
wish to create.
|
| 93 |
|
| 94 |
- Check FullTextPage or FullTextDoc only if you
|
| 95 |
would like to have it in the Dii file for import.
|
| 96 |
|
| 97 |
- Lastly click on OK and this should create your DII
|
| 98 |
file.
|
| 99 |
|
| 100 |
All buggs and comments should go to the email
|
| 101 |
address on the about tab."""
|
| 102 |
return mainText
|
| 103 |
def copyRightInfo():
|
| 104 |
mainText = """ImgInfoToDii.exe
|
| 105 |
|
| 106 |
Version 0.1
|
| 107 |
Copyright (C) 2004 Emanuel Borges
|
| 108 |
All Rights Reserved
|
| 109 |
|
| 110 |
This software is released under the terms of the GPL. Which states
|
| 111 |
that you can Copy, Distribute and even modify this code as long as
|
| 112 |
you never redistribute the original or modified code as closed source.
|
| 113 |
|
| 114 |
For information about this program or to report bugs contact:
|
| 115 |
Emanuel Borges
|
| 116 |
email: Nino.Borges@Gmail.com
|
| 117 |
"""
|
| 118 |
return mainText
|
| 119 |
|
| 120 |
|
| 121 |
if __name__ == '__main__':
|
| 122 |
Main() |