def windowTrig(action): action = action.text() if action == "فتح جدول .ate": loadATE(openFile(('ate', 'aft', 'act'), TableEditorWindow), Table, True) elif action == "فتح جدول .csv": loadCSV(openFile(['csv'], TableEditorWindow), Table, True) elif action == "فتح جدول .tbl": loadTBL(openFile(['tbl'], TableEditorWindow), Table, True) elif action == "حفظ الجدول كـ .ate": saveATE(saveFile(('ate', 'aft', 'act'), TableEditorWindow), Table) elif action == "حفظ الجدول كـ .csv": saveCSV(saveFile(['csv'], TableEditorWindow), Table) elif action == "حفظ الجدول كـ .tbl": saveTBL(saveFile(['tbl'], TableEditorWindow), Table) elif action == "إضافة صف": add_row(Table) elif action == "حذف صف": remove_row(Table) elif action == "إضافة عمود": add_col(Table) elif action == "حذف عمود": remove_col(Table) elif action == "مسح محتوى الجدول": eraseTable(Table)
def openFont(): global FontPath, ImgPath _fontPath = openFile(('aft', 'fnt', 'ttf', 'aff'), FontTesterWindow, 'الخط') if _fontPath: FontPath = _fontPath if FontPath.endswith('.ttf') or FontPath.endswith('.aff'): return _imgPath = openFile(('jpg', 'png'), FontTesterWindow, 'صورة الخط') if _imgPath: ImgPath = _imgPath
def runCustomScript(): try: scriptPath = filePath = openFile(['py'], text = 'ملف') scriptPath = scriptPath.replace(path.abspath('').replace('\\', '/')+'/', '', 1) exec(f"from {ToModulePath(scriptPath)} import Script", globals()) Script() except Exception as e: print(e)
def loadFile(): FilePath = openFile(['*'], FontTesterWindow, 'ملف') if not FilePath: return fileContent = open(FilePath, 'r', encoding='utf8', errors='replace').read() if FilePath.endswith('.msyt'): fileContent = loadMsyt(fileContent) FontTesterWindow.enteredTextBox.setPlainText(fileContent)
def openTextDataBase(): global database filePath = openFile(('xlsx', 'csv'), FilesEditorWindow, 'جدول نصوص') if not filePath: return dataBaseDirectory = filePath if filePath.endswith('.xlsx'): database = openpyxl.load_workbook(filePath) elif filePath.endswith('.csv'): database = CSVtoList(filePath)
def convertTable(): From = TablesConverterWindow.fromComboBox.currentText() To = TablesConverterWindow.toComboBox.currentText() openDirectory = openFile([From], TablesConverterWindow) if not openDirectory: return saveDirectory = saveFile([To], TablesConverterWindow) if not saveDirectory: return table = charmapToTable(TakeFromTable(openDirectory), To) if not table: return with open(saveDirectory, 'w', encoding='utf-8') as f: f.write(table)
def windowTrig(action): def check(text): return action.text() == text if check("فتح جدول حروف .tbl"): loadTBLHex(openFile(['tbl'], CharsTablesCreatorWindow), CharsTablesCreatorWindow.Table) elif check("فتح جدول حروف .act"): loadACT(openFile(['act'], CharsTablesCreatorWindow), CharsTablesCreatorWindow.Table) elif check("فتح جدول حروف .csv"): loadACT(openFile(['csv'], CharsTablesCreatorWindow), CharsTablesCreatorWindow.Table) elif check("حفظ جدول الحروف كـ .tbl"): saveTBLHex(saveFile(['tbl'], CharsTablesCreatorWindow), CharsTablesCreatorWindow.Table) elif check("حفظ جدول الحروف كـ .act"): saveACT(saveFile(['act'], CharsTablesCreatorWindow), CharsTablesCreatorWindow.Table) elif check("حفظ جدول الحروف كـ .csv"): saveCSVHex(saveFile(['csv'], CharsTablesCreatorWindow), CharsTablesCreatorWindow.Table) elif check("مسح محتوى الجدول"): eraseTable(CharsTablesCreatorWindow.Table)
def openFont(): Path = openFile(['ttf', 'aff'], FontsConverterWindow, 'ملف خط ttf') if not Path: return openFont.fontPath = Path
def getFilePath(): index = FilesEditorWindow.fileTypeComboBox.currentIndex() filePath = openFile([fileType(index)], FilesEditorWindow, 'ملف') return filePath
def loadFile(): FilePath = openFile(['*'], TextAnalyzerWindow, 'ملف نص') if not FilePath: return TextAnalyzerWindow.enteredBox.setPlainText(open(FilePath, 'r', encoding='utf8').read())