2

I am trying to write a program that will control document naming and file system placement of assets into our server. I have been writing it in Python and have had much luck thanks to everyone on here and the wealth of information on stackoverflow.

That being said, I can't find anything on the next step I am trying to take. I optimally want my program to run instead of the Windows/Linux Common File Dialog method. For example, when someone presses the "Save" button or "Open" button in a program, I would like my program to open up and be the way people find and save files. I would be okay with it acting as an intermediate system (runs on save or open call, but then returns its info to the native dialog) but would like it to take over. I was thinking I need to write a deamon program to listen for the appropriate call and intercept but am not sure. Any help would be great. Thanks in advance!

-Louis

4
  • It sounds like you want to override the file dialog in all applications. Is that correct? May 1, 2013 at 20:04
  • That's how I understand it. He wants to replace the default open-file dialog on windows/linux.
    – tessi
    May 1, 2013 at 20:20
  • Exactly, I want to override the file dialog for all applications in both windows and linux. Or at least have my program run when Open/Save/Save-As are called by any application. My program is designed to provided a standard naming protocol and help guide the user to a desired location for the document they are creating or trying to find. May 1, 2013 at 20:30
  • Did you ever figure out how to do this? Or if it can be done at all? Nov 22, 2013 at 5:11

1 Answer 1

0

Link the 'save as' and 'open' buttons to these; it worked perfectly for me:

def onOpen(self):
    ftypes = [('Python files', '*.py'), ('All files', '*')]
    dlg = Tkinter.FileDialog.Open(self, filetypes = ftypes)
    fl = dlg.show()

    if fl != '':
        text = self.readFile(fl)
        self.txt.insert(END, text)

def onSave_as(self):
     savefile = Tkinter.FileDialog.asksaveasfile(mode = 'w', defaultextension=".txte")
     self.parent.title("myTxtEditor")
     if savefile is None:
         return
     text2save = str(self.txt.get(1.0, END))
     savefile.write(text2save)
     savefile.close()

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.