Ejemplo n.º 1
0
 def interpreter_log_default_exception(self, exception):
     if not self.wasStoped:
         self.mainW.ui.statusbar.showMessage(QtCore.QString
             (i18n('Was occurred an error')))
         self.showInLog(i18n('Was occurred an error'))            
         self.log(exception.msg)
         self.mainW.resetButtonsRunAndStop()
Ejemplo n.º 2
0
 def success(self, board_string, result):
     if not self.interactiveRunning:
         if not self.wasStoped:
             self.mainW.ui.statusbar.showMessage(QtCore.QString
             (i18n('Execution completed')))
             self.results = Results(self.mainW)
             board = self.prepareString(board_string)
             self.results.setInitialBoard(BoardViewer(self,
             self.mainW.initialBoardGenerator.board, self.mainW.getClothing()))
             self.results.setFinalBoard(BoardViewer(self,
             parseABoardString(board), self.mainW.getClothing()))
             self.results.setRetVars(result)
             self.setCodeInResults()
             self.results.ui.tabWidgetResults.setCurrentIndex(2)
             self.results.show()
             self.mainW.resetButtonsRunAndStop()
             self.showInLog(i18n('Execution completed'))
             self.log('----------------'+
             str(datetime.datetime.now())[:19] +
             '-----------------\n')
     else:
         self.mainW.ui.statusbar.showMessage(QtCore.QString
             (i18n('Execution completed')))
         self.showInLog(i18n('Execution completed'))
         self.log('----------------'+
             str(datetime.datetime.now())[:19] +
             '-----------------\n')
         self.interactiveW.setStatusMessage('    ' + i18n('Execution completed'))
         self.mainW.resetButtonsRunAndStop()
         self.wasStoped = False
         self.isOpenInteractiveW = False
         self.interactiveRunning = False
Ejemplo n.º 3
0
    def __init__(self, parent):
        super(SearchWidget, self).__init__(parent)
        self.setWindowTitle(i18n('Search'))
        self.resize(QtCore.QSize(300, 80))
        self.setModal(False)
        self.textEditor = self.setEditor()
        labelSearch = QtGui.QLabel(i18n('Search'))
        self.text = QtGui.QLineEdit()
        self.text.textChanged.connect(self.search)
        prevButton = QtGui.QPushButton()
        prevButton.setIcon(QtGui.QIcon(':/prev.png'))
        nextButton = QtGui.QPushButton()
        nextButton.setIcon(QtGui.QIcon(':/next.png'))
        layout = QtGui.QHBoxLayout()
        layout.addWidget(labelSearch)
        layout.addWidget(self.text)
        layout.addWidget(prevButton)
        layout.addWidget(nextButton)
        self.setLayout(layout)
        nextButton.clicked.connect(self.next)
        prevButton.clicked.connect(self.prev)

        self.setStyleSheet(
            "QDialog {background-color:'white'; border:2px solid #4682b4; border-color:'#4682b4';}"
        )
Ejemplo n.º 4
0
    def openSelectBoardSizeWindow(self, function, title):

        self.widgetSize = QtGui.QDialog(self)
        self.widgetSize.setWindowTitle(i18n(title))
        self.widgetSize.setGeometry(500, 300, 180, 180)
        self.widgetSize.setMaximumSize(280, 200)
        self.setStyleSheet("background-color:'white'")

        widthL = QtGui.QLabel(self.widgetSize)
        widthL.setText(i18n('input') + ' x')
        widthL.move(20, 20)
        self.widthLE = QtGui.QLineEdit(self.widgetSize)
        self.widthLE.setGeometry(20, 45, 80, 30)

        heightL = QtGui.QLabel(self.widgetSize)
        heightL.setText(i18n('input') + ' y')
        heightL.move(20, 70)
        self.heightLE = QtGui.QLineEdit(self.widgetSize)
        self.heightLE.setGeometry(20, 95, 80, 30)

        hLayout = QtGui.QHBoxLayout()
        hLayout.addStretch(1)
        acceptButton = QtGui.QPushButton(i18n('Accept'))
        acceptButton.clicked.connect(function)
        hLayout.addWidget(acceptButton)

        vLayout = QtGui.QVBoxLayout()
        vLayout.addStretch(1)
        vLayout.addLayout(hLayout)

        self.widgetSize.setLayout(vLayout)

        self.widgetSize.exec_()
Ejemplo n.º 5
0
    def openSelectBoardSizeWindow(self, function, title):

        self.widgetSize = QtGui.QDialog(self)
        self.widgetSize.setWindowTitle(i18n(title))
        self.widgetSize.setGeometry(500, 300, 180, 180)
        self.widgetSize.setMaximumSize(280, 200)
        self.setStyleSheet("background-color:'white'")

        widthL = QtGui.QLabel(self.widgetSize)
        widthL.setText(i18n('input') + ' x')
        widthL.move(20, 20)
        self.widthLE = QtGui.QLineEdit(self.widgetSize)
        self.widthLE.setGeometry(20, 45, 80, 30)
        
        heightL = QtGui.QLabel(self.widgetSize)
        heightL.setText(i18n('input')+ ' y')
        heightL.move(20, 70)
        self.heightLE = QtGui.QLineEdit(self.widgetSize)
        self.heightLE.setGeometry(20, 95, 80, 30)

        hLayout = QtGui.QHBoxLayout()
        hLayout.addStretch(1)
        acceptButton = QtGui.QPushButton(i18n('Accept'))
        acceptButton.clicked.connect(function)
        hLayout.addWidget(acceptButton)

        vLayout = QtGui.QVBoxLayout()
        vLayout.addStretch(1)
        vLayout.addLayout(hLayout)

        self.widgetSize.setLayout(vLayout)

        self.widgetSize.exec_()
Ejemplo n.º 6
0
 def init_combo_box_options(self):
     self.connect(self.ui.combo_box_options,
                  QtCore.SIGNAL('activated(QString)'),
                  self.combo_box_options_chosen)
     self.ui.combo_box_options.addItem(i18n('Options'))
     self.ui.combo_box_options.addItem(i18n('Options Board'))
     self.ui.combo_box_options.addItem(i18n('User Options'))
Ejemplo n.º 7
0
 def success(self, board_string, result):
     if not self.interactiveRunning:
         if not self.wasStoped:
             self.mainW.ui.statusbar.showMessage(QtCore.QString
             (i18n('Execution completed')))
             self.results = Results(self.mainW)
             board = self.prepareString(board_string)
             self.results.setInitialBoard(BoardViewer(self,
             self.mainW.initialBoardGenerator.board, self.mainW.getClothing()))
             self.results.setFinalBoard(BoardViewer(self,
             parseABoardString(board), self.mainW.getClothing()))
             self.results.setRetVars(result)
             self.setCodeInResults()
             self.results.ui.tabWidgetResults.setCurrentIndex(2)
             self.results.show()
             self.mainW.resetButtonsRunAndStop()
             self.showInLog(i18n('Execution completed'))
             self.log('----------------'+
             str(datetime.datetime.now())[:19] +
             '-----------------\n')
     else:
         self.mainW.ui.statusbar.showMessage(QtCore.QString
             (i18n('Execution completed')))
         self.showInLog(i18n('Execution completed'))
         self.log('----------------'+
             str(datetime.datetime.now())[:19] +
             '-----------------\n')
         self.interactiveW.setStatusMessage('    ' + i18n('Execution completed'))
         self.mainW.resetButtonsRunAndStop()
         self.wasStoped = False
         self.isOpenInteractiveW = False
         self.interactiveRunning = False
Ejemplo n.º 8
0
 def success(self, board_string, result):
     self.mainW.ui.statusbar.showMessage(QtCore.QString(i18n('Check completed')))
     self.showInLog(i18n('Check completed, program is OK'))
     self.log('----------------' +
              str(datetime.datetime.now())[:19] +
              '-----------------\n')
     self.mainW.resetButtonsRunAndStop()
Ejemplo n.º 9
0
 def success(self, board_string, result):
     self.mainW.ui.statusbar.showMessage(QtCore.QString(i18n('Check completed')))
     self.showInLog(i18n('Check completed, program is OK'))
     self.log('----------------' +
              str(datetime.datetime.now())[:19] +
              '-----------------\n')
     self.mainW.resetButtonsRunAndStop()
Ejemplo n.º 10
0
 def fail_handler(exception):
     self.mainW.ui.statusbar.showMessage(QtCore.QString(i18n('Check failed')))
     self.showInLog(i18n('Check failed:'))
     self.showRowAndColError(exception)
     self.log(exception.msg)
     self.log('----------------' +
              str(datetime.datetime.now())[:19] +
              '-----------------\n')
Ejemplo n.º 11
0
 def interpreter_log_failure(self, exception):
     if not self.wasStoped:
         self.mainW.ui.statusbar.showMessage(QtCore.QString
             (i18n('Was occurred an error')))
         self.showInLog(i18n('Was occurred an error'))
         self.showRowAndColError(exception)
         self.log(exception.msg)
         self.mainW.resetButtonsRunAndStop()
Ejemplo n.º 12
0
 def fail_handler(exception):
     self.mainW.ui.statusbar.showMessage(QtCore.QString(i18n('Check failed')))
     self.showInLog(i18n('Check failed:'))
     self.showRowAndColError(exception)
     self.log(exception.msg)
     self.log('----------------' +
              str(datetime.datetime.now())[:19] +
              '-----------------\n')
Ejemplo n.º 13
0
 def init_combo_box_persist(self):
     self.connect(self.ui.combo_box_persist,
                  QtCore.SIGNAL('activated(QString)'),
                  self.combo_box_persist_chosen)
     self.ui.combo_box_persist.addItem(i18n('Persist board'))
     self.ui.combo_box_persist.addItem(i18n('Set as initial board'))
     self.ui.combo_box_persist.addItem(i18n('Save board to disk'))
     self.ui.combo_box_persist.addItem(i18n('Save board to image'))
Ejemplo n.º 14
0
    def closeApp(self, event):

        if self.mainW.ui.textEditFile.document().isModified() or self.mainW.ui.textEditLibrary.document().isModified():
                val = QMessageBox.question(self.mainW, i18n('Save changes?')
                    , i18n('There are unsaved files, you want to close the application?'),
                    QMessageBox.Yes, QMessageBox.No)
                if val == QMessageBox.Yes:
                    event.accept()
                else:
                    event.ignore()
Ejemplo n.º 15
0
 def stop(self):
     self.guiInterpreterHandler.initialStatus()
     self.runButton.stopInterpreter()
     self.resetButtonsRunAndStop()
     self.ui.statusbar.showMessage(QtCore.QString
         (i18n('Execution interrupted by the user')))
     self.guiInterpreterHandler.showInLog(i18n(
                             'Execution interrupted by the user'))
     self.guiInterpreterHandler.log('----------------' +
            str(datetime.datetime.now())[:19] +
           '-----------------')
Ejemplo n.º 16
0
 def stop(self):
     self.guiInterpreterHandler.initialStatus()
     self.runButton.stopInterpreter()
     self.resetButtonsRunAndStop()
     self.ui.statusbar.showMessage(QtCore.QString
         (i18n('Execution interrupted by the user')))
     self.guiInterpreterHandler.showInLog(i18n(
                             'Execution interrupted by the user'))
     self.guiInterpreterHandler.log('----------------' +
            str(datetime.datetime.now())[:19] +
           '-----------------')
Ejemplo n.º 17
0
 def check(self):
     self.ui.actionStop.setEnabled(True)
     self.ui.actionCheck.setEnabled(False)
     self.ui.actionRun.setEnabled(False)
     self.guiInterpreterHandler.showInLog(i18n(
                     'Start check || Languaje: ') + self.lang)
     self.guiInterpreterHandler.log('----------------' +
            str(datetime.datetime.now())[:19] +
           '-----------------')
     self.ui.statusbar.showMessage(QtCore.QString(i18n('Checking...')))
     self.checkButton = CheckButton(self)
     self.checkButton.start()
Ejemplo n.º 18
0
 def check(self):
     self.ui.actionStop.setEnabled(True)
     self.ui.actionCheck.setEnabled(False)
     self.ui.actionRun.setEnabled(False)
     self.guiInterpreterHandler.showInLog(i18n(
                     'Start check || Languaje: ') + self.lang)
     self.guiInterpreterHandler.log('----------------' +
            str(datetime.datetime.now())[:19] +
           '-----------------')
     self.ui.statusbar.showMessage(QtCore.QString(i18n('Checking...')))
     self.checkButton = CheckButton(self)
     self.checkButton.start()
Ejemplo n.º 19
0
    def retranslateUi(self, results):
        results.setWindowTitle(QtGui.QApplication.translate("results", i18n('Mode Results'), None, QtGui.QApplication.UnicodeUTF8))
        self.pushButtonSaveResults.setToolTip(QtGui.QApplication.translate("results", i18n('Save in file the final board'), None, QtGui.QApplication.UnicodeUTF8))
        self.pushButtonSaveResults.setText(QtGui.QApplication.translate("results", i18n('Save Final Board'), None, QtGui.QApplication.UnicodeUTF8))
        self.pushButtonSwitchViews.setToolTip(QtGui.QApplication.translate("switchViews", i18n('Switch between Gobstones Standard view and selected custom view'), None, QtGui.QApplication.UnicodeUTF8))
        self.pushButtonSwitchViews.setText(QtGui.QApplication.translate("switchViews", i18n('Switch Views'), None, QtGui.QApplication.UnicodeUTF8))
        #self.tabWidgetResults.setTabText(self.tabWidgetResults.indexOf(self.tabInitialBoard), QtGui.QApplication.translate("results", i18n('Initial Board'), None, QtGui.QApplication.UnicodeUTF8))
        #self.tabWidgetResults.setTabText(self.tabWidgetResults.indexOf(self.tabFinalBoard), QtGui.QApplication.translate("results", i18n('Final Board'), None, QtGui.QApplication.UnicodeUTF8))

        self.tabWidgetResults.setTabText(self.tabWidgetResults.indexOf(self.splitter), QtGui.QApplication.translate("results", i18n('Source Code'), None, QtGui.QApplication.UnicodeUTF8))

        self.labelResults.setText(QtGui.QApplication.translate("results", i18n('Results'), None, QtGui.QApplication.UnicodeUTF8))
        self.labelViews.setText(QtGui.QApplication.translate("results", i18n('Select View'), None, QtGui.QApplication.UnicodeUTF8))
Ejemplo n.º 20
0
    def closeApp(self, event):

        if self.mainW.ui.textEditFile.document().isModified(
        ) or self.mainW.ui.textEditLibrary.document().isModified():
            val = QMessageBox.question(
                self.mainW, i18n('Save changes?'),
                i18n(
                    'There are unsaved files, you want to close the application?'
                ), QMessageBox.Yes, QMessageBox.No)
            if val == QMessageBox.Yes:
                event.accept()
            else:
                event.ignore()
Ejemplo n.º 21
0
    def retranslateUi(self, results):
        results.setWindowTitle(
            QtGui.QApplication.translate("results", i18n('Mode Results'), None,
                                         QtGui.QApplication.UnicodeUTF8))
        self.pushButtonSaveResults.setToolTip(
            QtGui.QApplication.translate("results",
                                         i18n('Save in file the final board'),
                                         None, QtGui.QApplication.UnicodeUTF8))
        self.pushButtonSaveResults.setText(
            QtGui.QApplication.translate("results", i18n('Save Final Board'),
                                         None, QtGui.QApplication.UnicodeUTF8))
        self.pushButtonSwitchViews.setToolTip(
            QtGui.QApplication.translate(
                "switchViews",
                i18n(
                    'Switch between Gobstones Standard view and selected custom view'
                ), None, QtGui.QApplication.UnicodeUTF8))
        self.pushButtonSwitchViews.setText(
            QtGui.QApplication.translate("switchViews", i18n('Switch Views'),
                                         None, QtGui.QApplication.UnicodeUTF8))
        #self.tabWidgetResults.setTabText(self.tabWidgetResults.indexOf(self.tabInitialBoard), QtGui.QApplication.translate("results", i18n('Initial Board'), None, QtGui.QApplication.UnicodeUTF8))
        #self.tabWidgetResults.setTabText(self.tabWidgetResults.indexOf(self.tabFinalBoard), QtGui.QApplication.translate("results", i18n('Final Board'), None, QtGui.QApplication.UnicodeUTF8))

        self.tabWidgetResults.setTabText(
            self.tabWidgetResults.indexOf(self.splitter),
            QtGui.QApplication.translate("results", i18n('Source Code'), None,
                                         QtGui.QApplication.UnicodeUTF8))

        self.labelResults.setText(
            QtGui.QApplication.translate("results", i18n('Results'), None,
                                         QtGui.QApplication.UnicodeUTF8))
        self.labelViews.setText(
            QtGui.QApplication.translate("results", i18n('Select View'), None,
                                         QtGui.QApplication.UnicodeUTF8))
Ejemplo n.º 22
0
    def newFile(self):

        if self.mainW.ui.textEditFile.document().isModified():
            val = QMessageBox.question(self.mainW, i18n('Save changes?'),
             i18n('The file %s was changed, Do you save changes?') % (self.mainW.ui.tabWidgetEditors.tabText(0)[3:]),
            QMessageBox.Yes, QMessageBox.No, QMessageBox.Cancel)
            if val == QMessageBox.Yes:
                self.saveFile()
            elif val == QMessageBox.Cancel:
                return
        self.moduleFile = None
        self.clearCurrentModule()
        if clothing_dir_for_file(str(self.moduleFile)):
            self.updateClothingOptions()
            self.mainW.setClothing('Gobstones.xml')
Ejemplo n.º 23
0
    def loadGoogleDriveFiles(self):

        l = []
        file_list = self.DRIVE.ListFile({
            'q':
            "title contains '.gbs' and trashed=false"
        }).GetList()
        for f in file_list:
            t = (f['title'], f['id'], f.GetContentString())
            l.append(t)

        model = ListGoogleDriveModel(l)
        list_view = QtGui.QListView()
        list_view.setWindowTitle('Google Drive')
        list_view.setModel(model)

        dialog = QtGui.QDialog(self.mainW)
        dialog.setWindowTitle('Open File')
        layout_list = QtGui.QVBoxLayout()
        layout_list.addWidget(list_view)
        dialog.setLayout(layout_list)
        button_list = QPushButton(QtCore.QString(i18n('Open File')))

        layout_list.addWidget(button_list)
        if dialog.exec_() == QtGui.QDialog.Accepted:
            pass
Ejemplo n.º 24
0
 def checkWasChangesInFiles(self):
     if self.mainW.ui.textEditFile.document().isModified():
         val = QMessageBox.question(self.mainW, i18n('Save changes?'),
          i18n('The file %s was changed, Do you save changes?') % (self.mainW.ui.tabWidgetEditors.tabText(0)[3:]),
         QMessageBox.Yes, QMessageBox.No, QMessageBox.Cancel)
         if val == QMessageBox.Yes:
             if not self.saveFile():
                 return QMessageBox.Cancel          
     if self.mainW.ui.textEditLibrary.document().isModified():
         val = QMessageBox.question(self.mainW, i18n('Save changes?'),
          i18n('The file %s was changed, Do you save changes?') % (self.mainW.ui.tabWidgetEditors.tabText(1)[3:]),
         QMessageBox.Yes, QMessageBox.No, QMessageBox.Cancel)
         if val == QMessageBox.Yes:
             if not self.saveFile():
                 return QMessageBox.Cancel                
     return val
Ejemplo n.º 25
0
 def setFinalBoard(self, boardV):
     boardV.setParent(self.ui.tabWidgetResults)
     self.ui.tabWidgetResults.insertTab(2, boardV, i18n('Final Board'))
     if not boardV.is_board_error():
         self.finalBoard = boardV.getBoard()
     else:
         self.ui.pushButtonSaveResults.setVisible(False)
Ejemplo n.º 26
0
 def setFinalBoard(self, boardV):
     boardV.setParent(self.ui.tabWidgetResults)
     self.ui.tabWidgetResults.insertTab(2,boardV,i18n('Final Board'))
     if not boardV.is_board_error():
         self.finalBoard = boardV.getBoard()
     else:
         self.ui.pushButtonSaveResults.setVisible(False)
Ejemplo n.º 27
0
 def initializeRetVarsInspector(self, results):
     # RetVars table
     self.retVarsTable = QtGui.QTableWidget(results)
     self.retVarsTable.setHorizontalHeaderLabels(
         [_fromUtf8('Varname'), _fromUtf8('Value')])
     self.retVarsTable.horizontalHeader().hide()
     self.retVarsTable.verticalHeader().hide()
     self.retVarsTable.setEditTriggers(QtGui.QTableWidget.NoEditTriggers)
     self.retVarsTable.horizontalHeader().setStretchLastSection(True)
     self.retVarsTable.setSelectionBehavior(
         QtGui.QAbstractItemView.SelectRows)
     # RetVars Inspector
     self.retVarsInspector = QtGui.QTextEdit()
     #  RetVars Splitter
     self.retVarsSplitter = QtGui.QSplitter(QtCore.Qt.Vertical, results)
     self.retVarsSplitter.setObjectName(_fromUtf8("tabRetVars"))
     self.retVarsSplitter.addWidget(self.retVarsTable)
     self.retVarsSplitter.addWidget(self.retVarsInspector)
     # Add Splitter
     self.tabWidgetResults.addTab(self.retVarsSplitter,
                                  _fromUtf8("labelRetVars"))
     self.tabWidgetResults.setTabText(
         self.tabWidgetResults.indexOf(self.retVarsSplitter),
         QtGui.QApplication.translate("results", i18n('Return Values'),
                                      None, QtGui.QApplication.UnicodeUTF8))
Ejemplo n.º 28
0
     def __init__(self):
        super(CommandHelpWidget, self).__init__()
        self.setModal(True)
        self.setWindowTitle(i18n('User guide editor board'))
        tabs = QtGui.QTabWidget(self)
        tabs.tabBar().setStyleSheet("background-color:'white'; color:'#4682b4'; border:2px solid #4682b4; font-size:15px")
        tabs.tabBar().setAttribute(QtCore.Qt.WA_TranslucentBackground)

        command = self.openAndReturnHelpFile(os.path.join(utils.root_path(), 'about_files','command_editor.html'))

        tabs.addTab(command, _fromUtf8(""))

        tabs.setTabText(0, i18n("commands enables"))

        vLayout = QtGui.QVBoxLayout()
        vLayout.addWidget(tabs)
        self.setLayout(vLayout)
Ejemplo n.º 29
0
 def saveBoardToImage(self):
     filename = QtGui.QFileDialog.getSaveFileName(self,
                                                  i18n('Save as ...'), 
                                                  root_path(), 
                                                  '*.png')
     if not filename == QtCore.QString(''):
         self.ui.boardEditor.save_to_image(filename)
     self.reset_combo_persist()
Ejemplo n.º 30
0
 def run(self):
     self.ui.logger.clear()
     if MainWindow.getPreference('logger') == False:
         self.setPreference('logger', True)
         self.initLoggerSize()
     self.guiInterpreterHandler.wasStoped = False
     self.guiInterpreterHandler.showInLog(i18n(
                             'Start execution || Languaje: ') + self.lang)
     self.guiInterpreterHandler.log('----------------' +
            str(datetime.datetime.now())[:19] +
           '-----------------')
     self.ui.logger.show()
     self.ui.actionStop.setEnabled(True)
     self.ui.actionCheck.setEnabled(False)
     self.ui.statusbar.showMessage(QtCore.QString(i18n('Processing...')))
     self.programRun.handler = self.guiInterpreterHandler
     self.runButton.start(self.programRun)
Ejemplo n.º 31
0
    def newFile(self):

        if self.mainW.ui.textEditFile.document().isModified():
            val = QMessageBox.question(
                self.mainW, i18n('Save changes?'),
                i18n('The file %s was changed, Do you save changes?') %
                (self.mainW.ui.tabWidgetEditors.tabText(0)[3:]),
                QMessageBox.Yes, QMessageBox.No, QMessageBox.Cancel)
            if val == QMessageBox.Yes:
                self.saveFile()
            elif val == QMessageBox.Cancel:
                return
        self.moduleFile = None
        self.clearCurrentModule()
        if clothing_dir_for_file(str(self.moduleFile)):
            self.updateClothingOptions()
            self.mainW.setClothing('Gobstones.xml')
Ejemplo n.º 32
0
 def retranslateUi(self, Form):
     Form.setWindowTitle(
         QtGui.QApplication.translate("Form", i18n("Interactive Mode"),
                                      None, QtGui.QApplication.UnicodeUTF8))
     self.label.setText(
         QtGui.QApplication.translate(
             "Form", '   ' + i18n("Press a key to Continue"), None,
             QtGui.QApplication.UnicodeUTF8))
     self.pushButton.setText(
         QtGui.QApplication.translate("Form", i18n('Switch Views'), None,
                                      QtGui.QApplication.UnicodeUTF8))
     self.labelViews.setText(
         QtGui.QApplication.translate("results", i18n('Select View'), None,
                                      QtGui.QApplication.UnicodeUTF8))
     self.labelResults.setText(
         QtGui.QApplication.translate("results", i18n('Interactive'), None,
                                      QtGui.QApplication.UnicodeUTF8))
Ejemplo n.º 33
0
 def makeRelationshipBetweenHeadAndSize(self, s):
     if(s == 'enter coordinate' or s == 'current conservation coordinate'):
         self.ui.comboBox_2.clear()
         self.ui.comboBox_2.addItem(i18n('current conservation dimensions'))
     if(s == 'head random'):
         self.ui.comboBox_2.clear()
         self.initCombo2SizeDimensions()
     self.ui.comboBox_2.update()
Ejemplo n.º 34
0
 def makeRelationshipBetweenSizeAndHead(self, s):
     if (s == 'dimensions random'):
         self.ui.comboBox_3.clear()
         self.ui.comboBox_3.addItem(i18n('head random'))
     if (s == 'enter dimensions' or s == 'current conservation dimensions'):
         self.ui.comboBox_3.clear()
         self.initCombo3HeadPosition()
     self.ui.comboBox_3.update()
Ejemplo n.º 35
0
 def acceptBoardSize(self):
     y = self.heightLE.text()
     x = self.widthLE.text()
     if (self.isValidInt(x, 1) and self.isValidInt(y, 1)):
         self.setBoardSize(int(self.widthLE.text()), int(self.heightLE.text()))
         self.widgetSize.close()
     else:
         ErrorWindow(i18n("You must enter integers greater than zero!"))
Ejemplo n.º 36
0
 def loadBoard(self):
     filename = QtGui.QFileDialog.getOpenFileName(self.parent, i18n('Open File'),
     root_path(), '*.gbb')
     if not filename == PyQt4.QtCore.QString(''):
         fname = open(filename)
         data = fname.read()
         self.parent.setInitialBoard(data)
         fname.close()
Ejemplo n.º 37
0
 def run(self):
     self.ui.logger.clear()
     if MainWindow.getPreference('logger') == False:
         self.setPreference('logger', True)
         self.initLoggerSize()
     self.guiInterpreterHandler.wasStoped = False
     self.guiInterpreterHandler.showInLog(i18n(
                             'Start execution || Languaje: ') + self.lang)
     self.guiInterpreterHandler.log('----------------' +
            str(datetime.datetime.now())[:19] +
           '-----------------')
     self.ui.logger.show()
     self.ui.actionStop.setEnabled(True)
     self.ui.actionCheck.setEnabled(False)
     self.ui.statusbar.showMessage(QtCore.QString(i18n('Processing...')))
     self.programRun.handler = self.guiInterpreterHandler
     self.runButton.start(self.programRun)
Ejemplo n.º 38
0
 def makeRelationshipBetweenHeadAndSize(self, s):
     if (s == 'enter coordinate' or s == 'current conservation coordinate'):
         self.ui.comboBox_2.clear()
         self.ui.comboBox_2.addItem(i18n('current conservation dimensions'))
     if (s == 'head random'):
         self.ui.comboBox_2.clear()
         self.initCombo2SizeDimensions()
     self.ui.comboBox_2.update()
Ejemplo n.º 39
0
 def makeRelationshipBetweenSizeAndHead(self, s):
     if(s == 'dimensions random'):
         self.ui.comboBox_3.clear()
         self.ui.comboBox_3.addItem(i18n('head random'))
     if(s == 'enter dimensions' or s == 'current conservation dimensions'):
         self.ui.comboBox_3.clear()
         self.initCombo3HeadPosition()
     self.ui.comboBox_3.update()
Ejemplo n.º 40
0
    def __init__(self):
        super(AboutWidget, self).__init__()
        self.version = QtCore.QString(utils.read_file(os.path.join(utils.root_path(), 'version')))
        self.setModal(True)
        icon = QtGui.QIcon(':/logoGobstones.png')
        self.setWindowIcon(icon)
        self.setWindowTitle(i18n("About"))
        logoHtml = ""
        logoHtml += (       "<div align = 'center'>"
                            '<img src=":/logoHelp.png">'
                            "</div>"
                             )
        versionHtml = ""
        versionHtml += (        '<div align = "center">'
                                "<h3>PyGobstones</h3>"
                                "<p>Versi&oacute;n " + self.version + "</p>".decode('utf8') +
                                "<p>" + i18n("Developed with Python and PyQt") + "</p>"
                                "</div>"
                             )
        logo = QtGui.QLabel(logoHtml)
        version = QtGui.QLabel(versionHtml)
        hLayout = QtGui.QHBoxLayout()
        hLayout.addWidget(logo)
        hLayout.addWidget(version)

        tabs = QtGui.QTabWidget(self)
        tabs.tabBar().setStyleSheet("background-color:'white'; color:'#4682b4'; border:2px solid #4682b4; font-size:15px")
        tabs.tabBar().setAttribute(QtCore.Qt.WA_TranslucentBackground)

        about = self.openAndReturnHelpFile(os.path.join(utils.root_path(), 'about_files','about.html'))
        authors = self.openAndReturnHelpFile(os.path.join(utils.root_path(), 'about_files','authors.html'))
        history = self.openAndReturnHelpFile(os.path.join(utils.root_path(), 'about_files','history.html'))

        tabs.addTab(about, _fromUtf8(""))
        tabs.addTab(authors, _fromUtf8(""))
        tabs.addTab(history, _fromUtf8(""))

        tabs.setTabText(0, i18n("About"))
        tabs.setTabText(1, i18n("Authors"))
        tabs.setTabText(2, i18n("History"))

        vLayout = QtGui.QVBoxLayout()
        vLayout.addLayout(hLayout)
        vLayout.addWidget(tabs)
        self.setLayout(vLayout)
Ejemplo n.º 41
0
 def loadBoard(self):
     filename = QtGui.QFileDialog.getOpenFileName(self.parent,
                                                  i18n('Open File'),
                                                  root_path(), '*.gbb')
     if not filename == PyQt4.QtCore.QString(''):
         fname = open(filename)
         data = fname.read()
         self.parent.setInitialBoard(data)
         fname.close()
Ejemplo n.º 42
0
 def acceptBoardSize(self):
     y = self.heightLE.text()
     x = self.widthLE.text()
     if (self.isValidInt(x, 1) and self.isValidInt(y, 1)):
         self.setBoardSize(int(self.widthLE.text()),
                           int(self.heightLE.text()))
         self.widgetSize.close()
     else:
         ErrorWindow(i18n("You must enter integers greater than zero!"))
Ejemplo n.º 43
0
 def acceptHeadPosition(self):
     y = self.heightLE.text()
     x = self.widthLE.text()
     if (self.isValidIntAndPosition(x,y)):
         self.initialBoardGenerator.setHead(int(self.widthLE.text()), int(self.heightLE.text()))
         self.widgetSize.close()
     else:
         ErrorWindow(i18n("You must enter integers less or equal than ({0},{1})").
         format(self.initialBoardGenerator.board.getX()-1,self.initialBoardGenerator.board.getY()-1))
Ejemplo n.º 44
0
 def __init__(self):
     super(LicenseWidget, self).__init__()
     self.setModal(True)
     self.browser = QWebView()
     self.browser.load(QtCore.QUrl('http://www.gnu.org/licenses/gpl-3.0.txt'))
     self.setWindowTitle(i18n("License Agreement - Gobstones"))
     layout = QtGui.QHBoxLayout()
     layout.addWidget(self.browser)
     self.setLayout(layout)
Ejemplo n.º 45
0
 def __init__(self, mainW):
     super(PreferencesWindow, self).__init__()
     self.mainW = mainW
     self.setGeometry(300, 300, 300, 150)
     self.setMaximumSize(300,150)
     self.setWindowTitle(i18n('Preferences'))
     self.setStyleSheet("QDialog {background-color:'white'; border:2px solid #4682b4; border-color:'#4682b4';}")
     self.initActions()
     self.exec_()
Ejemplo n.º 46
0
    def saveAsFileDialog(self):
        indexFile = self.mainW.ui.tabWidgetEditors.currentIndex()
        filename = QtGui.QFileDialog.getSaveFileName(self.mainW,
                                                     i18n('Save as ...'),
                                                     gobstones_folder(),
                                                     '*.gbs')
        if filename == PyQt4.QtCore.QString(''):
            return False
        if indexFile == 0:
            (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 do not be equals to library') + '\n' +
                    i18n(''), QMessageBox.Ok)
                return False
            else:
                filename = self.addExtension(filename)
                (filep, filen) = os.path.split(str(filename))
                self.moduleFile = filename
                myFile = open(filename, 'w')
                body = self.mainW.ui.textEditFile.toPlainText().toUtf8()
                myFile.write(body)
                # add to save in Google Drive
                if self.DRIVE is not None:
                    self.saveG(filen, body)

                self.setCurrentPathDirectory(os.path.dirname(filename))
                myFile.close()
                self.mainW.ui.textEditFile.document().setModified(False)
                self.setTabsNamesAndLabelButtonNameAndSetCurrentPathDirectory(
                    filename)
                self.loadLibrary()

        if indexFile == 1:
            (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'):
                filename = self.addExtension(filename)
                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, self.addExtension(filen))
            else:
                self.saveLibrary()
        self.createInitialsFoldersAndFiles()
        self.updateClothingOptions()

        return True
Ejemplo n.º 47
0
 def loadLibrary(self):
     '''Purpose: Load library file of a current directory.
         If not exist the Biblioteca.gbs , then create a new file library
     '''
     if not os.path.exists('Biblioteca.gbs'):
         
         fileLibrary = open('Biblioteca.gbs', 'w')
         fileLibrary.write(i18n('-- New Library'))
         body=i18n('-- New Library')
         if  self.DRIVE is not None:
             self.saveG('Biblioteca.gbs',body)
         fileLibrary.close()
     fileLibrary = open('Biblioteca.gbs')
     self.libraryFile = os.path.abspath(str('Biblioteca.gbs'))
     data = fileLibrary.read()
     string = QtCore.QString()
     data = string.fromUtf8(data)
     self.mainW.ui.textEditLibrary.setPlainText(data)
     fileLibrary.close()
Ejemplo n.º 48
0
    def loadLibrary(self):
        '''Purpose: Load library file of a current directory.
            If not exist the Biblioteca.gbs , then create a new file library
        '''
        if not os.path.exists('Biblioteca.gbs'):

            fileLibrary = open('Biblioteca.gbs', 'w')
            fileLibrary.write(i18n('-- New Library'))
            body = i18n('-- New Library')
            if self.DRIVE is not None:
                self.saveG('Biblioteca.gbs', body)
            fileLibrary.close()
        fileLibrary = open('Biblioteca.gbs')
        self.libraryFile = os.path.abspath(str('Biblioteca.gbs'))
        data = fileLibrary.read()
        string = QtCore.QString()
        data = string.fromUtf8(data)
        self.mainW.ui.textEditLibrary.setPlainText(data)
        fileLibrary.close()
Ejemplo n.º 49
0
 def saveBoardFromDisk(self):
     self.board = boardToString(self.ui.boardEditor.getEditedBoard())
     filename = QtGui.QFileDialog.getSaveFileName(self, i18n('Save as ...'),
                                                  root_path(), '*.gbb')
     if not filename == QtCore.QString(''):
         (filep, filen) = os.path.split(str(filename))
         myFile = open(filename, 'w')
         myFile.write(self.board)
         myFile.close()
     self.reset_combo_persist()
Ejemplo n.º 50
0
 def saveBoardFromDisk(self):
     self.board = boardToString(self.ui.boardEditor.getEditedBoard())
     filename = QtGui.QFileDialog.getSaveFileName(self,
     i18n('Save as ...'), root_path(), '*.gbb')
     if not filename == QtCore.QString(''):
         (filep, filen) = os.path.split(str(filename))
         myFile = open(filename, 'w')
         myFile.write(self.board)
         myFile.close()
     self.reset_combo_persist()
Ejemplo n.º 51
0
 def saveBoard(self):
     filename = QtGui.QFileDialog.getSaveFileName(self,
     i18n('Save as ...'), os.getcwd(), '*.gbb')
     if not filename == QtCore.QString(''):
         filename = filename + '.gbb'
         (filep, filen) = os.path.split(str(filename))
         myFile = open(filename, 'w')
         myFile.write(boardToString(self.finalBoard))
         myFile.close()
     else:
         pass
Ejemplo n.º 52
0
 def saveBoard(self):
     filename = QtGui.QFileDialog.getSaveFileName(self, i18n('Save as ...'),
                                                  os.getcwd(), '*.gbb')
     if not filename == QtCore.QString(''):
         filename = filename + '.gbb'
         (filep, filen) = os.path.split(str(filename))
         myFile = open(filename, 'w')
         myFile.write(boardToString(self.finalBoard))
         myFile.close()
     else:
         pass
Ejemplo n.º 53
0
 def initialStatus(self, partialBoard):
     if (self.load_views is None) or (self.load_views != root_path()):
         self.reset_clothing()
         self.loadViewAlternatives()
         self.load_views = root_path()
     self.boardV = BoardViewer(self, parseABoardString(partialBoard), self.mainW.getClothing())
     self.boardV.setParent(self.ui.boardViewer)
     self.ui.boardViewer.removeTab(0)
     self.ui.boardViewer.insertTab(0, self.boardV, i18n('Board'))
     self.setPressAKeyState()
     self.init_switcher()
Ejemplo n.º 54
0
 def __init__(self, mainW):
     super(PreferencesWindow, self).__init__()
     self.mainW = mainW
     self.setGeometry(300, 300, 300, 150)
     self.setMaximumSize(300, 150)
     self.setWindowTitle(i18n('Preferences'))
     self.setStyleSheet(
         "QDialog {background-color:'white'; border:2px solid #4682b4; border-color:'#4682b4';}"
     )
     self.initActions()
     self.exec_()
Ejemplo n.º 55
0
 def saveAsFileDialog(self):
     indexFile = self.mainW.ui.tabWidgetEditors.currentIndex()
     filename = QtGui.QFileDialog.getSaveFileName(self.mainW,
         i18n('Save as ...'), gobstones_folder(), '*.gbs')
     if filename == PyQt4.QtCore.QString(''):
         return False
     if indexFile == 0:
         (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 do not be equals to library') + '\n'
                     + i18n(''),
                     QMessageBox.Ok)
             return False
         else:
             filename = self.addExtension(filename)
             (filep, filen) = os.path.split(str(filename))
             self.moduleFile = filename
             myFile = open(filename, 'w')
             body=self.mainW.ui.textEditFile.toPlainText().toUtf8()
             myFile.write(body)
             #add to save in Google Drive
             if  self.DRIVE is not None:
                 self.saveG(filen,body)
             
             self.setCurrentPathDirectory(os.path.dirname(filename))
             myFile.close()
             self.mainW.ui.textEditFile.document().setModified(False)
             self.setTabsNamesAndLabelButtonNameAndSetCurrentPathDirectory(filename)
             self.loadLibrary()
         
     if indexFile == 1:
         (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'):
             filename = self.addExtension(filename)
             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, self.addExtension(filen))
         else:
             self.saveLibrary()
     
            
     self.createInitialsFoldersAndFiles()
     self.updateClothingOptions()
     
     return True
Ejemplo n.º 56
0
    def openFiles(self):

        if self.mainW.ui.textEditFile.document().isModified() or self.mainW.ui.textEditLibrary.document().isModified():
            val = QMessageBox.question(self.mainW, i18n('Warning!'),
             i18n('There are unsaved files, to load a new module changes will be lost, continue?'),
            QMessageBox.Yes, QMessageBox.Cancel)
            if val == QMessageBox.Cancel:
                return

        filename = QtGui.QFileDialog.getOpenFileName(self.mainW, i18n('Open File'),
        gobstones_folder(), '*.gbs')
        if not filename == PyQt4.QtCore.QString(''):
            if not self.wantOpenLibrary(filename):
                self.moduleFile = filename
                fname = open(filename)
                data = fname.read()
                string = QtCore.QString()
                data = string.fromUtf8(data)
                self.mainW.ui.textEditFile.setPlainText(data)
                self.setTabsNamesAndLabelButtonNameAndSetCurrentPathDirectory(filename)
                self.loadLibrary()
                fname.close()
            else:
                QMessageBox.question(self.mainW, i18n('Error loading the file'),
                     i18n('Must load a file different to library') + '\n'
                           + i18n('If you want edit the library, use the corresponding tab'),
                            QMessageBox.Ok)
        self.createInitialsFoldersAndFiles()
        self.updateClothingOptions()
Ejemplo n.º 57
0
    def updateClothingOptions(self):
        if clothing_for_file_exists(str(self.moduleFile)):
            path = clothing_dir_for_file(str(self.moduleFile))
            files = os.listdir(path)
        else:
            files = []
        self.mainW.ui.menuSelectResultView.clear()
        self.filesNames = []
        for f in files:
            fileName, fileExtension = os.path.splitext(os.path.join(path,f))
            if fileExtension == '.xml':
                self.filesNames.append(os.path.join(path, fileName))

        self.mapper = QtCore.QSignalMapper(self.mainW)
        self.actions = {}
        for fn in self.filesNames:
            (filepath, filename) = os.path.split(fn)            
            self.addClothing(fn, filename)
        
        self.addClothing('Gobstones', i18n('Gobstones Standard'))        
        self.addClothing('PixelBoard', i18n('Pixel Board'))
        self.mapper.mapped['QString'].connect(self.handleButton)