Esempio n. 1
0
 def launchFile(self):
     ## Prompts a file dialog with only 2 available file types
     ## Once file is selected, dialog returns the file's path (filename)
     filename = tkFileDialog.askopenfilename(
         filetypes=[('word files', '.docx'), ('text files', '.txt')])
     ## Splits file's path into a tuple of directory string and extension string
     filepath, file_ext = os.path.splitext(filename)
     if filename:
         if file_ext == ".txt":
             ## Executable file for notepad program
             filepath = "C:/Windows/notepad.exe"
         elif file_ext == ".docx":
             ## Executable file for Microsoft Word program
             filepath = "C:/Program Files (x86)/Microsoft Office/root/Office16/WINWORD.EXE"
         try:
             ## Create sub process
             proc = subprocess.Popen([filepath, filename])
             proc.wait()
         except (OSError, subprocess.CalledProcessError):
             return "Failed, file is damaged or program has crashed!"
         ## Prompts dialog for user to input revision message
         message = tkSimpleDialog.askstring("Commit message",
                                            "What are the changes?")
         rcsFile = File(filename, Database())
         rcsFile.add(message)
     ## Update file list with the new changes
     self.updatefileList()
Esempio n. 2
0
 def addFile(self):
     ## Prompts a file dialog with only 2 available file types
     filename = tkFileDialog.askopenfilename(
         filetypes=[('text files', '.txt'), ('word files', '.docx')])
     ## Prompts dialog for user to input revision message
     message = tkSimpleDialog.askstring("First commit",
                                        "What are the details?")
     rcsFile = File(filename, Database())
     rcsFile.add(message)
     ## Update file list with the new changes
     self.updatefileList()