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 saveFont():
    chars = FontsConverterWindow.charsCell.getValue()
    fontPath = openFont.fontPath
    if not chars or not fontPath: return

    Width = FontsConverterWindow.WidthCell.getValue()
    Height = FontsConverterWindow.HeightCell.getValue()
    fontSize = FontsConverterWindow.TtfSizeCell.getValue()
    if not Width or not Height or not fontSize: return

    fromRight = FontsConverterWindow.fromRightCheck.isChecked()
    isSmooth = (not FontsConverterWindow.smoothCheck.isChecked()) * 1
    monoSized = FontsConverterWindow.monoSizedCheck.isChecked()
    beforeFirstCol = FontsConverterWindow.beforeFirstColCell.getValue()
    beforeFirstRow = FontsConverterWindow.beforeFirstRowCell.getValue()
    BetweenCharsX = FontsConverterWindow.BetweenCharsXCell.getValue()
    BetweenCharsY = FontsConverterWindow.BetweenCharsYCell.getValue()
    charsPerRow = FontsConverterWindow.charsPerRowCell.getValue()
    if not charsPerRow: charsPerRow = 1

    tableContent = CreateAftFontTable(beforeFirstCol, beforeFirstRow,
                                      BetweenCharsX, BetweenCharsY, Width,
                                      Height, charsPerRow, chars, fontPath,
                                      fontSize, monoSized, fromRight)

    fontFileSavePath = saveFile(['aft'], FontsConverterWindow, 'ملف الخط')
    if not fontFileSavePath: return
    with open(fontFileSavePath, 'w', encoding="utf-8") as f:
        f.write(tableContent)

    if not fontPath: return
    imgFileSavePath = saveFile(['png'], FontsConverterWindow, 'صورة الخط')
    if not path.exists(fontPath) or not imgFileSavePath: return

    charsPerCol = (len(chars) // charsPerRow) + ((
        (len(chars) % charsPerRow) > 0) * 1)
    rowLength = ((charsPerRow * (charsPerCol > 1)) + (len(chars) *
                                                      (charsPerCol == 1)))
    imgSize = (beforeFirstCol + BetweenCharsX * (rowLength - 1) +
               (Width * rowLength), beforeFirstRow + BetweenCharsY *
               (charsPerCol - 1) + Height * charsPerCol)

    drawFontTable(fontFileSavePath, chars, Width, Height, imgSize, fontPath,
                  fontSize, isSmooth, fromRight, monoSized, imgFileSavePath)
Exemple #3
0
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 getFileSavePath():
    index = FilesEditorWindow.fileTypeComboBox.currentIndex()
    filePath = saveFile([fileType(index)], FilesEditorWindow, 'ملف')
    return filePath
def saveLog():
    FilePath = saveFile(['txt'], TextAnalyzerWindow, 'ملف الإحصاءات')
    if not FilePath: return
    open(FilePath, 'w', encoding='utf8').write(TextAnalyzerWindow.logBox.toPlainText())