To answer this specific question:
How do I take object-based inputs and turn them into passable variables?
You access the controls and call the appropriate methods:
self.resize_txt.GetValue()
self.file_input.GetPath()
self.outfile_input.GetPath()
To pass them to your resize, function, just pass those values to your resize_file function.
resize_file(self.file_input.GetPath(),
self.outfile_input.GetPath())
You're asking too many questions here TBH. You should start with one, and create others as you progress.
What the heck, I have time to kill before lunch! I'll give you a few pointers.
Let's look at this function:
def resize_file(filename, filename2 = None)
Looking at this function, I really have no idea what the inputs are to the function. It says filename and an optional filename2. Which of these is being resized? How do I know what each parameter does? You did not document this function, which made me dig off into your code to try to determine what it does.
So, I dug off into your code... And it appears that this particular function resizes and possibly appends pdfs. Notice how in your code, you execute the same code twice?
fIn1 = file(os.path.join(inputDir,filename), 'rb')
inp1 = PdfFileReader(fIn1)
p1 = inp1.getPage(0)
p1.scale(.5,.5)
output.addPage(p1)
if filename2 is not None:
fIn2 = file(os.path.join(inputDir,filename2), 'rb')
inp2 = PdfFileReader(fIn2)
p2 = inp2.getPage(0)
p2.scale(.50,.50)
output.addPage(p2)
Don't do this. Use the DRY principle. You should have a loop, as the algorithm is basically the same. (Can't illustrate the loop atm, running out of time before lunch, maybe when I get back :P)
You could even get fancy and have your function take an indefinite amount of PDF files. Check this snippet out:
def resize_file(*args):
output = PdfFileWriter()
for filename in args:
fIn1 = file(os.path.join(inputDir, filename), 'rb')
inp1 = PdfFileReader(fIn1)
p1 = inp1.getPage(0)
p1.scale(.5,.5)
output.addPage(p1)
outputStream = file(os.path.join(validateDir,str(fileout) + '.pdf'),"wb")
output.write(outputStream)
outputStream.close()
Ok, I lied, I tried to squeeze this in before lunch. The code above may not work out of the box, but it should point you in the general direction. You should add error catching to check for when no arguments are passed (among other things).
Hope it helps!