def main(): """Run warning if run directly""" warning_message = "This script contains the code that builds the " \ + "Doc page of the FCA (File Converter App)." \ + "\n\nThis script should NOT be run DIRECTLY." \ + "\n\nPlease, import it in another script." cGUIf.show_warning("Import warning", warning_message)
def check_conversion(self): """Makes sure there is no errors for the conversion""" #Check that all is alright #Make a tuple of all input entry widgets all_inputEntryWidgets = (self.inputFileEntry, self.fileNameEntry, self.fileLocationEntry, self.fileFormatEntry) #Check that the user entered an input image file before clicking the conversion button if len(self.inputFileEntry.get()) == 0: cGUIf.show_warning("Upload Audio File Warning", "You have to upload an audio file first" \ + " to convert it to another format") self.__no_errors = False #Check that the input file entered by the user exists by conversion time if not os.path.exists(self.inputFileEntry.get()) and len(self.inputFileEntry.get()) > 0: cGUIf.show_error("File Not Found Error", f"The file {self.inputFileEntry.get()} was not found " \ + "in your file system.\n\nIt might have been deleted" \ + " or moved to another location.") #Clear all input related entry widgets for entry_widget in all_inputEntryWidgets: entry_widget.configure(state = "default") entry_widget.delete(0, END) entry_widget.configure(state = "readonly") self.__no_errors = False #If a location is entered for the output folder, check that it exists # at the time the user clicked the conversion button if not os.path.exists(self.outputFileLocationEntry.get()) and len(self.outputFileLocationEntry.get()) > 0: cGUIf.show_error("Folder Not Found Error", f"The folder {self.outputFileLocationEntry.get()} was not found in your file system" \ + "\n\nIt might have been deleted or moved to another location.") #Clear the entry output widget self.outputFileLocationEntry.configure(state = "default") self.outputFileLocationEntry.delete(0, END) self.outputFileLocationEntry.configure(state = "readonly") self.__no_errors = False #Check that the file formats of the input and the output file are different if self.fileFormatEntry.get() == self.chosenFormat.get(): cGUIf.show_error("Same Format Error", f"Can't convert a {self.file_format} file to a {self.chosenFormat.get()} file" \ + " because their file format is the same.") self.__no_errors = False
cGUIf.show_error("TypeError", f'"is_resizable" must be of bool type, not of type {type(is_resizable)}.') sys.exit(1) #Check if it is possible to apply an Image (Do some error handling) if isinstance(icon_path,str): if len(icon_path) > 0: try: self.iconphoto(False, PhotoImage(file = icon_path)) except TclError as tkerror: cGUIf.show_error("Fatal Error", tkerror) sys.exit(1) #Cancel all operations #Set window size if possible (Do some Error handling) if width != "" and height != "": try: self.geometry(f"{width}x{height}") except TclError as tkerror: cGUIf.show_error("Fatal Error", tkerror) sys.exit(1) #Tell the user the program is not meant to be run directly if __name__ == "__main__": cGUIf.show_warning("Import Warning", "This script containts a modified version " \ + "of Tk()\n(The Tkinter Window Object) for simple and fast GUI projects" \ + "\n\nThe script is NOT MEANT TO BE RUN DIRECTLY.\nPlease, IMPORT IT IN ANOTHER SCRIPT.")