Exemplo n.º 1
0
    def saveAsFileDialog(self):
        indexFile = self.mainW.ui.tabWidgetEditors.currentIndex()
        filename = saveFileName(self.mainW, "*.gbs")
        if filename == "":
            return False
        if indexFile == 0:
            filename = assure_extension(filename, "gbs")
            (filep, filen) = os.path.split(str(filename))
            if filen == "Biblioteca.gbs" or filen == "Biblioteca":
                QMessageBox.question(
                    self.mainW,
                    i18n("Error saving the file"),
                    i18n("The file name dont be equals to library") + "\n" + i18n(""),
                    QMessageBox.Ok,
                )
                return False
            else:
                self.moduleFile = filename
                myFile = open(filename, "w")
                myFile.write(self.mainW.ui.textEditFile.toPlainText().toUtf8())
                self.setCurrentPathDirectory(os.path.dirname(filename))
                myFile.close()
                self.mainW.ui.textEditFile.document().setModified(False)
                self.setTabsNamesAndLabelButtonNameAndSetCurrentPathDirectory(filename)
                self.loadLibrary()

        if indexFile == 1:
            filename = assure_extension(filename, "gbs")
            (filep, filen) = os.path.split(str(filename))
            if not filen.startswith("Biblioteca"):
                QMessageBox.question(
                    self.mainW,
                    i18n("Error saving the file"),
                    i18n('The file must be named "Library"') + "\n" + i18n(""),
                    QMessageBox.Ok,
                )
                return False
            elif not os.path.exists("Biblioteca.gbs"):
                self.libraryFile = filename
                fileLibrary = open(filename, "w")
                fileLibrary.write(self.mainW.ui.textEditLibrary.toPlainText().toUtf8())
                self.setCurrentPathDirectory(os.path.dirname(filename))
                fileLibrary.close()
                self.mainW.ui.textEditLibrary.document().setModified(False)
                self.mainW.ui.tabWidgetEditors.setTabText(1, filen)
            else:
                self.saveLibrary()

        self.createInitialsFoldersAndFiles()
        self.updateClothingOptions()

        return True
Exemplo n.º 2
0
    def saveAsFileDialog(self):
        indexFile = self.mainW.ui.tabWidgetEditors.currentIndex()
        filename = saveFileName(self.mainW, '*.gbs')
        if filename == "":
            return False
        if indexFile == 0:
            filename = assure_extension(filename, 'gbs')
            (filep, filen) = os.path.split(str(filename))
            if filen == "Biblioteca.gbs" or filen == "Biblioteca":
                QMessageBox.question(
                    self.mainW, i18n('Error saving the file'),
                    i18n('The file name dont be equals to library') + '\n' +
                    i18n(''), QMessageBox.Ok)
                return False
            else:
                self.moduleFile = filename
                myFile = open(filename, 'w')
                myFile.write(self.mainW.ui.textEditFile.toPlainText().toUtf8())
                self.setCurrentPathDirectory(os.path.dirname(filename))
                myFile.close()
                self.mainW.ui.textEditFile.document().setModified(False)
                self.setTabsNamesAndLabelButtonNameAndSetCurrentPathDirectory(
                    filename)
                self.loadLibrary()

        if indexFile == 1:
            filename = assure_extension(filename, 'gbs')
            (filep, filen) = os.path.split(str(filename))
            if not filen.startswith('Biblioteca'):
                QMessageBox.question(
                    self.mainW, i18n('Error saving the file'),
                    i18n('The file must be named "Library"') + '\n' + i18n(''),
                    QMessageBox.Ok)
                return False
            elif not os.path.exists('Biblioteca.gbs'):
                self.libraryFile = filename
                fileLibrary = open(filename, 'w')
                fileLibrary.write(
                    self.mainW.ui.textEditLibrary.toPlainText().toUtf8())
                self.setCurrentPathDirectory(os.path.dirname(filename))
                fileLibrary.close()
                self.mainW.ui.textEditLibrary.document().setModified(False)
                self.mainW.ui.tabWidgetEditors.setTabText(1, filen)
            else:
                self.saveLibrary()

        self.createInitialsFoldersAndFiles()
        self.updateClothingOptions()

        return True
Exemplo n.º 3
0
 def saveBoard(self):
     filename = saveFileName(self, '*.gbb')
     if not filename == QtCore.QString(''):
         filename = assure_extension(filename, 'gbb')
         (filep, filen) = os.path.split(str(filename))
         myFile = open(filename, 'w')
         myFile.write(boardToString(self.finalBoard))
         myFile.close()
     else:
         pass
Exemplo n.º 4
0
 def saveBoard(self):
     filename = saveFileName(self, '*.gbb')
     if not filename == QtCore.QString(''):
         filename = assure_extension(filename, 'gbb')
         (filep, filen) = os.path.split(str(filename))
         myFile = open(filename, 'w')
         myFile.write(boardToString(self.finalBoard))
         myFile.close()
     else:
         pass