Beispiel #1
0
 def btnFinish_click(self, *args):
     selectedOption = self.readPanel()
     if selectedOption == 0:
         skip = commonsdialog.confirmDialog("Do you want to skip?", "Skip", commonsdialog.YES_NO, commonsdialog.QUESTION)
     else:
         skip = 0
     if skip == 0:
         finish = commonsdialog.confirmDialog("Do you want to finish?", "Finish", commonsdialog.YES_NO, commonsdialog.QUESTION)
         if finish == 0:
             self.performCorrection(self.getIndex())
             self.getReport().setQuestions(self.getQuestions())
             self.getReport().createReport()
             self.hide()
Beispiel #2
0
 def btnSave_click(self, *args):
     if self.txtName.isEnabled():
         name = self.txtName.getText()
     else:
         name = None
     if self.txtDescription.isEnabled():
         description = self.txtDescription.getText()
     else:
         description = None
     if name == None and description == None:
         commonsdialog.msgbox("Selection required.\nTry again!", "Update", commonsdialog.FORBIDEN)
     else:
         if name != None and name == "":
             commonsdialog.msgbox("Name required.\nTry again!", "Update", commonsdialog.FORBIDEN)
         elif name != None and len(name) > 50:
             commonsdialog.msgbox("Name's maximum lenght is 50.\nTry again!", "Update", commonsdialog.FORBIDEN)
         elif description != None and description == "":
             commonsdialog.msgbox("Description required.\nTry again!", "Update", commonsdialog.FORBIDEN)
         elif description != None and len(description) > 100:
             commonsdialog.msgbox("Description's maximum length is 100.\nTry again!", "Update", commonsdialog.FORBIDEN)
         else:
             save = commonsdialog.confirmDialog("Do you want to save changes?", "Save", commonsdialog.YES_NO, commonsdialog.QUESTION)
             if save == 0:
                 self.saveInfo(name, description)
                 self.txtName.setText("")
                 self.txtName.setEnabled(0)
                 self.chkName.setSelected(0)
                 self.txtDescription.setText("")
                 self.txtDescription.setEnabled(0)
                 self.chkDescription.setSelected(0)
                 self.updateInfo(name, description)
Beispiel #3
0
 def btnUpdate_click(self, *args):
     number = self.txtNumber.getText()
     kind = self.cmbKind.getSelectedItem()
     statement = self.txtStatement.getText()
     option1 = self.txtOption1.getText()
     option2 = self.txtOption2.getText()
     if self.txtOption3.isEnabled():
         option3 = self.txtOption3.getText()
     else:
         option3 = None
     answer = self.cmbAnswer.getSelectedItem()
     points = self.txtPoints.getText()
     xmin = self.txtXMin.getText()
     ymin = self.txtYMin.getText()
     xmax = self.txtXMax.getText()
     ymax = self.txtYMax.getText()
     if number == "":
         commonsdialog.msgbox("Number required.\nTry again!", "Create", commonsdialog.FORBIDEN)
     elif len(number) > 2:
         commonsdialog.msgbox("Number's maximum length is 2.\nTry again!", "Create", commonsdialog.FORBIDEN)
     elif not self.validNumber(number):
         commonsdialog.msgbox("Number contains invalid characters.\nTry again!", "Create", commonsdialog.FORBIDEN)
     elif self.existingNumber(number) == 1:
         commonsdialog.msgbox("Number already exists.\nTry again!", "Create", commonsdialog.FORBIDEN)
     elif statement == "":
         commonsdialog.msgbox("Statement required.\nTry again!", "Create", commonsdialog.FORBIDEN)
     elif len(statement) > 80:
         commonsdialog.msgbox("Statement's maximum length is 80.\nTry again!", "Create", commonsdialog.FORBIDEN)
     elif not self.validStatement(statement):
         commonsdialog.msgbox("Statement contains invalid characters.\nTry again!", "Create", commonsdialog.FORBIDEN)
     elif option1 == "":
         commonsdialog.msgbox("Option 1 required.\nTry again!", "Create", commonsdialog.FORBIDEN)
     elif len(option1) > 20:
         commonsdialog.msgbox("Option 1's maximum length is 20.\nTry again!", "Create", commonsdialog.FORBIDEN)
     elif not self.validOption(option1):
         commonsdialog.msgbox("Option 1 contains invalid characters.\nTry again!", "Create", commonsdialog.FORBIDEN)
     elif option2 == "":
         commonsdialog.msgbox("Option 2 required.\nTry again!", "Create", commonsdialog.FORBIDEN)
     elif len(option2) > 20:
         commonsdialog.msgbox("Option 2's maximum length is 20.\nTry again!", "Create", commonsdialog.FORBIDEN)
     elif not self.validOption(option2):
         commonsdialog.msgbox("Option 2 contains invalid characters.\nTry again!", "Create", commonsdialog.FORBIDEN)
     elif option3 != None and option3 == "":
         commonsdialog.msgbox("Option 3 required.\nTry again!", "Create", commonsdialog.FORBIDEN)
     elif option3 != None and len(option3) > 20:
         commonsdialog.msgbox("Option 3's maximum length is 20.\nTry again!", "Create", commonsdialog.FORBIDEN)
     elif option3 != None and not self.validOption(option3):
         commonsdialog.msgbox("Option 3 contains invalid characters.\nTry again!", "Create", commonsdialog.FORBIDEN)
     elif xmin == "":
         commonsdialog.msgbox("Envelope required.\nTry again!", "Create", commonsdialog.FORBIDEN)
     else:
         save = commonsdialog.confirmDialog("Do you want to save changes?", "Create", commonsdialog.YES_NO, commonsdialog.QUESTION)
         if save == 0:
             self.createStage(number, kind, statement, option1, option2, option3, answer, points, xmin, ymin, xmax, ymax)
             self.txtStatement.setText("")
             self.txtOption1.setText("")
             self.txtOption2.setText("")
             self.txtOption3.setText("")
             self.txtOption3.setEnabled(0)
             self.updateStages()
Beispiel #4
0
 def btnCreate_click(self, *args):
     id = self.txtId.getText()
     password = self.txtPassword.getText()
     name = self.txtName.getText()
     if id == "":
         commonsdialog.msgbox("Id required.\nTry again!", "Update", commonsdialog.FORBIDEN)
     elif len(id) > 25:
         commonsdialog.msgbox("Id's maximum length is 25.\nTry again!", "Update", commonsdialog.FORBIDEN)
     elif not self.validId(id):
         commonsdialog.msgbox("Id contains invalid characters.\nTry again!", "Update", commonsdialog.FORBIDEN)
     elif self.existingId(id) == 1:
         commonsdialog.msgbox("Id already exists.\nTry again!", "Update", commonsdialog.FORBIDEN)
     elif password == "":
         commonsdialog.msgbox("Password required.\nTry again!", "Update", commonsdialog.FORBIDEN)
     elif len(password) < 8:
         commonsdialog.msgbox("Password's minimum length is 8.\nTry again!", "Update", commonsdialog.FORBIDEN)
     elif len(password) > 25:
         commonsdialog.msgbox("Password's maximum length is 25.\nTry again!", "Update", commonsdialog.FORBIDEN)
     elif not self.validPassword(password):
          commonsdialog.msgbox("Password contains invalid characters.\nTry again!", "Update", commonsdialog.FORBIDEN)
     elif name == "":
         commonsdialog.msgbox("Name required.\nTry again!", "Update", commonsdialog.FORBIDEN)
     elif len(name) > 25:
         commonsdialog.msgbox("Name's maximum lenght is 25.\nTry again!", "Update", commonsdialog.FORBIDEN)
     elif not self.validName(name):
          commonsdialog.msgbox("Name contains invalid characters.\nTry again!", "Update", commonsdialog.FORBIDEN)
     else:
         save = commonsdialog.confirmDialog("Do you want to save changes?", "Save", commonsdialog.YES_NO, commonsdialog.QUESTION)
         if save == 0:
             self.createStudent(id, password, name)
             self.txtId.setText("")
             self.txtPassword.setText("")
             self.txtName.setText("")
             self.updateStudents()
def sigpac2csv():
    i18n = ToolsLocator.getI18nManager()
    initPath = ToolsUtilLocator.getFileDialogChooserManager().getLastPath(
        "OPEN_LAYER_FILE_CHOOSER_ID", None)
    f = openFileDialog(i18n.getTranslation("_Select_the_SIGPAC_XML_file"),
                       initialPath=initPath.getAbsolutePath())
    if f == None or len(f) == 0 or f[0] == None:
        return
    xmlf = f[0]
    #layername = os.path.splitext(os.path.basename(xmlf))[0]

    with open(getResource(__file__, xmlf), 'r') as f:
        xml = f.read()
    data = xmltodic.parse(xml)

    if hasOnlyPoligons(data):
        output = "shp"
    else:
        output = "csv"

    outf = os.path.splitext(xmlf)[0] + "." + output
    if os.path.exists(outf):
        if confirmDialog(
                i18n.getTranslation(
                    "_The_file_%s_already_existsXnlXDo_you_want_to_overwrite_itXquestionX"
                ) % os.path.basename(outf)) == NO:
            return

    if output == "csv":
        convert2cvs(data, outf)
    else:
        convert2shp(data, outf)

    view = currentView()
    if view == None:
        return

    if confirmDialog(
            i18n.getTranslation(
                "_File_%s_creaded_XnlXDo_you_want_to_load_it_in_the_current_viewXquestionX"
            ) % os.path.basename(outf)) == NO:
        return

    listfiles = (File(outf), )
    actions = PluginsLocator.getActionInfoManager()
    addlayer = actions.getAction("view-layer-add")
    addlayer.execute((listfiles, ))
Beispiel #6
0
 def btnDelete_click(self, *args):
     id = self.cmbId.getSelectedItem()
     save = commonsdialog.confirmDialog("Do you want to save changes?", "Save", commonsdialog.YES_NO, commonsdialog.QUESTION)
     if save == 0:
         self.deleteStudent(id)
         self.updateStudents()
         self.cmbId.removeAllItems()
         self.loadIds()
Beispiel #7
0
 def btnDelete_click(self, *args):
     number = self.cmbNumber.getSelectedItem()
     save = commonsdialog.confirmDialog("Do you want to save changes?", "Save", commonsdialog.YES_NO, commonsdialog.QUESTION)
     if save == 0:
         self.deleteStage(number)
         self.updateStages()
         self.cmbNumber.removeAllItems()
         self.loadNumbers()
Beispiel #8
0
 def btnUpdate_click(self, *args):
     rowCount = self.tableStudents.getRowCount()
     if rowCount != 0:
         update = commonsdialog.confirmDialog("Do you want to update students?", "Update", commonsdialog.YES_NO, commonsdialog.QUESTION)
         if update == 0:
             studentsUpdaterPanel = StudentsUpdaterPanel()
             studentsUpdaterPanel.showWindow("Update")
     else:
         commonsdialog.msgbox("Zero students!", "Update", commonsdialog.IDEA)
Beispiel #9
0
 def btnFileNew_click(self, *args):
     i18n = ToolsLocator.getI18nManager()
     if confirmDialog(i18n.getTranslation(
             "_Are_you_sure_you_want_to_abandon_the_changes"),
                      getTitle(),
                      optionType=YES_NO,
                      messageType=QUESTION) != YES:
         return
     self.newSections()
Beispiel #10
0
 def btnDelete_click(self, *args):
     rowCount = self.tableStages.getRowCount()
     if rowCount != 0:
         delete = commonsdialog.confirmDialog("Do you want to delete stages?", "Delete", commonsdialog.YES_NO, commonsdialog.QUESTION)
         if delete == 0:
             stagesDeleterPanel = StagesDeleterPanel()
             stagesDeleterPanel.showWindow("Delete")
     else:
         commonsdialog.msgbox("Zero stages!", "Delete", commonsdialog.IDEA)
Beispiel #11
0
 def btnEnter_click(self, *args):
     info = 1
     stages = 1
     students = 1
     if self.rdbInfo.isSelected():
         info = commonsdialog.confirmDialog("Do you want to edit info?", "Enter", commonsdialog.YES_NO, commonsdialog.QUESTION)
     elif self.rdbStages.isSelected():
         stages = commonsdialog.confirmDialog("Do you want to edit stages?", "Enter", commonsdialog.YES_NO, commonsdialog.QUESTION)
     elif self.rdbStudents.isSelected():
         students = commonsdialog.confirmDialog("Do you want to edit students?", "Enter", commonsdialog.YES_NO, commonsdialog.QUESTION)
     if info == 0:
         infoEditorPanel = InfoEditorPanel()
         infoEditorPanel.showWindow("Info")
     elif stages == 0:
         stagesEditorPanel = StagesEditorPanel()
         stagesEditorPanel.showWindow("Stages")
     elif students == 0:
         studentsEditorPanel = StudentsEditorPanel()
         studentsEditorPanel.showWindow("Students")
 def btnDelete_click(self, *args):
     model = self.lstValues.getModel()
     index = self.lstValues.getSelectedIndex()
     if index < 0:
         return
     if confirmDialog(
             u"¿ Seguro que desea eliminar el elemento seleccionado ?",
             getTitle(),
             optionType=YES_NO,
             messageType=QUESTION) != YES:
         return
     model.removeElementAt(index)
     self.lstValues.setSelectedIndex(index)
Beispiel #13
0
 def btnFormDelete_click(self, *args):
     i18n = ToolsLocator.getI18nManager()
     index = self.cboForms.getSelectedIndex()
     if index < 0:
         return
     if confirmDialog(i18n.getTranslation(
             "_Are_you_sure_you_want_to_delete_the_selected_form_%s") %
                      self.__currentSection[index],
                      getTitle(),
                      optionType=YES_NO,
                      messageType=QUESTION) != YES:
         return
     del self.__currentSection[index]
     self.updateSectionFromUI()
Beispiel #14
0
 def btnDeleteSelectedPoint_click(self, event):
     if not self.__tablemodel.isPointStorageAvailable():
         return
     i18n = ToolsLocator.getI18nManager()
     if confirmDialog(
             i18n.getTranslation("_Are_you_sure_you_want_to_delete_point"),
             getTitle(),
             optionType=YES_NO,
             messageType=QUESTION) != YES:
         return
     row = self.tblPoints.getSelectedRow()
     if row < 0:
         return
     self.__tablemodel.removeRow(row)
Beispiel #15
0
 def btnNext_click(self, *args):
     selectedOption  = self.readPanel()
     if selectedOption == 0:
         skip = commonsdialog.confirmDialog("Do you want to skip?", "Skip", commonsdialog.YES_NO, commonsdialog.QUESTION)
     else:
         skip = 0
     if skip == 0:
         self.performCorrection(self.getIndex())
         self.setIndex(self.getIndex() + 1)
         self.pgbGame.setValue(self.getIndex() + 1)
         self.pgbGame.setString(str(self.getIndex() + 1) + "/" + str(len(self.getQuestions())))
         self.fillPanel(self.getQuestions()[self.getIndex()])
         self.updateView(self.getViews()[self.getIndex()])
     if self.getIndex() == len(self.getQuestions()) - 1:
         self.btnNext.setEnabled(0)
Beispiel #16
0
 def btnFormItemDelete_click(self, *args):
     i18n = ToolsLocator.getI18nManager()
     index = self.lstFormItems.getSelectedIndex()
     if index < 0:
         return
     if confirmDialog(i18n.getTranslation(
             "_Are_you_sure_you_want_to_delete_the_selected_item"),
                      getTitle(),
                      optionType=YES_NO,
                      messageType=QUESTION) != YES:
         return
     form = self.__currentForm
     items = form.items()
     del items[index]
     self.updateListOfFormItems(form)
     self.lstFormItems.setSelectedIndex(index)
Beispiel #17
0
 def btnEnter_click(self, *args):
     attempts = self.getGameInfo().getAttempts()
     if int(attempts) == 0:
         commonsdialog.msgbox("This is your first attempt.\nGo ahead!", "Enter", commonsdialog.IDEA)
         confirmation = 0
     else:
         confirmation = commonsdialog.confirmDialog("This isn't your first attempt.\nDo you want to enter?", "Enter", commonsdialog.YES_NO, commonsdialog.WARNING)
     if confirmation == 0:
         self.getGameInfo().registerAttempt()
         if (currentProject().getFile() == None) or (currentProject().getFile().getName()[:-8] != self.getGameInfo().getProject()):
             load_project(os.path.join(os.path.dirname(__file__), "map", self.getGameInfo().getProject() + ".gvsproj"))
         userId = self.getGameInfo().getUserId()
         userRole = self.getGameInfo().getUserRole()
         gamePlayer = GamePlayer(userRole, userId)
         gamePlayerPanel = GamePlayerPanel(gamePlayer)
         gamePlayerPanel.showTool(self.getGameInfo().getName())
         self.hide()
Beispiel #18
0
 def btnUpdate_click(self, *args):
     id = self.cmbId.getSelectedItem()
     if self.txtPassword.isEnabled():
         password = self.txtPassword.getText()
     else:
         password = None
     if self.txtName.isEnabled():
         name = self.txtName.getText()
     else:
         name = None
     if password == None and name == None:
         commonsdialog.msgbox("Selection required.\nTry again!", "Update", commonsdialog.FORBIDEN)
     else:
         if password != None and password == "":
             commonsdialog.msgbox("Password required.\nTry again!", "Update", commonsdialog.FORBIDEN)
         elif password != None and len(password) < 8:
             commonsdialog.msgbox("Password's minimum length is 8.\nTry again!", "Update", commonsdialog.FORBIDEN)
         elif password != None and len(password) > 25:
             commonsdialog.msgbox("Password's maximum length is 25.\nTry again!", "Update", commonsdialog.FORBIDEN)
         elif password != None and not self.validPassword(password):
              commonsdialog.msgbox("Password contains invalid characters.\nTry again!", "Update", commonsdialog.FORBIDEN)
         elif name != None and name == "":
             commonsdialog.msgbox("Name required.\nTry again!", "Update", commonsdialog.FORBIDEN)
         elif name != None and len(name) > 25:
             commonsdialog.msgbox("Name's maximum lenght is 25.\nTry again!", "Update", commonsdialog.FORBIDEN)
         elif name != None and not self.validName(name):
              commonsdialog.msgbox("Name contains invalid characters.\nTry again!", "Update", commonsdialog.FORBIDEN)
         else:
             save = commonsdialog.confirmDialog("Do you want to save changes?", "Save", commonsdialog.YES_NO, commonsdialog.QUESTION)
             if save == 0:
                 self.updateStudent(id, password, name)
                 self.txtPassword.setText("")
                 self.txtPassword.setEnabled(0)
                 self.chkPassword.setSelected(0)
                 self.txtName.setText("")
                 self.txtName.setEnabled(0)
                 self.chkName.setSelected(0)
                 self.updateStudents()
Beispiel #19
0
 def btnExit_click(self, *args):
     exit = commonsdialog.confirmDialog("Do you want to exit?", "Exit", commonsdialog.YES_NO, commonsdialog.QUESTION)
     if exit == 0:
         self.hide()
Beispiel #20
0
 def btnUpdate_click(self, *args):
     number = self.cmbNumber.getSelectedItem()
     if self.cmbKind.isEnabled():
         kind = self.cmbKind.getSelectedItem()
         points = self.txtPoints.getText()
     else:
         kind = None
         points = None
     if self.txtStatement.isEnabled():
         statement = self.txtStatement.getText()
     else:
         statement = None
     if self.txtOption1.isEnabled():
         option1 = self.txtOption1.getText()
     else:
         option1 = None
     if self.txtOption2.isEnabled():
         option2 = self.txtOption2.getText()
     else:
         option2 = None
     if self.txtOption3.isEnabled():
         option3 = self.txtOption3.getText()
     else:
         option3 = None
     if self.cmbAnswer.isEnabled():
         answer = self.cmbAnswer.getSelectedItem()
     else:
         answer = None
     if self.btnCapture.isEnabled():
         xmin = self.txtXMin.getText()
         ymin = self.txtYMin.getText()
         xmax = self.txtXMax.getText()
         ymax = self.txtYMax.getText()
     else:
         xmin = None
         ymin = None
         xmax = None
         ymax = None
     
     if kind == None and statement == None and option1 == None and option2 == None and option3 == None and xmin == None:
         commonsdialog.msgbox("Selection required.\nTry again!", "Update", commonsdialog.FORBIDEN)
     else:
         if statement != None and statement == "":
             commonsdialog.msgbox("Statement required.\nTry again!", "Update", commonsdialog.FORBIDEN)
         elif statement != None and len(statement) > 80:
             commonsdialog.msgbox("Statement's maximum length is 80.\nTry again!", "Update", commonsdialog.FORBIDEN)
         elif statement != None and not self.validStatement(statement):
             commonsdialog.msgbox("Statement contains invalid characters.\nTry again!", "Update", commonsdialog.FORBIDEN)
         elif option1 != None and option1 == "":
             commonsdialog.msgbox("Option 1 required.\nTry again!", "Update", commonsdialog.FORBIDEN)
         elif option1 != None and len(option1) > 20:
             commonsdialog.msgbox("Option 1's maximum length is 20.\nTry again!", "Update", commonsdialog.FORBIDEN)
         elif option1 != None and not self.validOption(option1):
             commonsdialog.msgbox("Option 1 contains invalid characters.\nTry again!", "Update", commonsdialog.FORBIDEN)
         elif option2 != None and option2 == "":
             commonsdialog.msgbox("Option 2 required.\nTry again!", "Update", commonsdialog.FORBIDEN)
         elif option2 != None and len(option2) > 20:
             commonsdialog.msgbox("Option 2's maximum length is 20.\nTry again!", "Update", commonsdialog.FORBIDEN)
         elif option2 != None and not self.validOption(option2):
             commonsdialog.msgbox("Option 2 contains invalid characters.\nTry again!", "Update", commonsdialog.FORBIDEN)
         elif option3 != None and option3 == "":
             commonsdialog.msgbox("Option 3 required.\nTry again!", "Update", commonsdialog.FORBIDEN)
         elif option3 != None and len(option3) > 20:
             commonsdialog.msgbox("Option 3's maximum length is 20.\nTry again!", "Update", commonsdialog.FORBIDEN)
         elif option3 != None and not self.validOption(option3):
             commonsdialog.msgbox("Option 3 contains invalid characters.\nTry again!", "Update", commonsdialog.FORBIDEN)
         elif xmin != None and xmin == "":
             commonsdialog.msgbox("Envelope required.\nTry again!", "Update", commonsdialog.FORBIDEN)
         else:
             save = commonsdialog.confirmDialog("Do you want to save changes?", "Save", commonsdialog.YES_NO, commonsdialog.QUESTION)
             if save == 0:
                 self.updateStage(number, kind, statement, option1, option2, option3, answer, points, xmin, ymin, xmax, ymax)
                 self.cmbKind.setEnabled(0)
                 self.chkKind.setSelected(0)
                 self.txtStatement.setText("")
                 self.txtStatement.setEnabled(0)
                 self.chkStatement.setSelected(0)
                 self.txtOption1.setText("")
                 self.txtOption1.setEnabled(0)
                 self.chkOption1.setSelected(0)
                 self.txtOption2.setText("")
                 self.txtOption2.setEnabled(0)
                 self.chkOption2.setSelected(0)
                 self.txtOption3.setText("")
                 self.txtOption3.setEnabled(0)
                 self.chkOption3.setSelected(0)
                 self.cmbAnswer.setEnabled(0)
                 self.chkAnswer.setSelected(0)
                 self.btnCapture.setEnabled(0)
                 self.chkEnvelope.setSelected(0)
                 self.updateStages()
Beispiel #21
0
 def btnUpdate_click(self, *args):
     update = commonsdialog.confirmDialog("Do you want to update info?", "Update", commonsdialog.YES_NO, commonsdialog.QUESTION)
     if update == 0:
         infoUpdaterPanel = InfoUpdaterPanel()
         infoUpdaterPanel.showWindow("Update")
Beispiel #22
0
 def btnCreate_click(self, *args):
     create = commonsdialog.confirmDialog("Do you want to create stages?", "Create", commonsdialog.YES_NO, commonsdialog.QUESTION)
     if create == 0:
         stagesCreatorPanel = StagesCreatorPanel()
         stagesCreatorPanel.showWindow("Create")