Example #1
0
    def __remove_db(self, obj):
        """
        Callback associated with the Remove button. Get the selected
        row and data, then call the verification dialog.
        """
        store, node = self.selection.get_selected()
        path = store.get_path(node)
        self.data_to_delete = store[path]

        if len(path) == 1:
            QuestionDialog(
                _("Remove the '%s' family tree?") % self.data_to_delete[0],
                _("Removing this family tree will permanently destroy the data."
                  ), _("Remove family tree"), self.__really_delete_db)
        else:
            rev = self.data_to_delete[0]
            parent = store[(path[0], )][0]
            QuestionDialog(
                _("Remove the '%(revision)s' version of '%(database)s'") % {
                    'revision': rev,
                    'database': parent
                },
                _("Removing this version will prevent you from "
                  "extracting it in the future."), _("Remove version"),
                self.__really_delete_version)
Example #2
0
    def openQuestion(self, btn):
        rcv = self.socketGUI.send("q_" + btn.objectName())  # ex. cat1.100

        dialog = QuestionDialog(rcv)
        ret_status = dialog.exec_()

        if ret_status == QtWidgets.QDialog.Accepted:
            print("Answered = ", dialog.getAnswer())
            #check answer
            answ = json.dumps({
                "question": "cat1.100",
                "answer": dialog.getAnswer()
            })
            print("Data back to server", answ)
            print(type(answ))
            rcv = self.socketGUI.send(answ)
            print("Received back (is correct): ", rcv.get("a"))
            btn.setEnabled(False)
Example #3
0
 def __restore_clicked(self, menu):
     """
     Called when restore defaults is clicked from the context menu.
     """
     QuestionDialog(_("Restore to defaults?"),
         _("The Grampsbar will be restored to contain its default "
           "gramplets.  This action cannot be undone."),
         _("OK"),
         self.restore)
Example #4
0
    def ask_questions(self, team, total_questions, level):
        total_correct = 0
        questions_filename = 'Math_' + str(level) + '.txt'
        # This opens up the file with our questions
        with open(questions_filename) as questionsFile:
            reader = csv.reader(questionsFile, delimiter="\t")
            lines = list(reader)
            tqs = []
            for line in lines:
                if len(line) != 5:
                    continue
                tqs.append(test_question.TestQuestion(line))
        question_dialog = QuestionDialog()
        random.shuffle(tqs)
        for x in range(total_questions):
            question_dialog.ask_question(tqs[x])
            question_dialog.exec_()
            total_correct += question_dialog.result
        print("Your " + team + " team score: " + str(total_correct))
        with open('scores.txt') as scoresFile:
            reader = csv.reader(scoresFile, delimiter="\t", quotechar='^')
            lines = list(reader)

        # python 3 - with open('scores.txt', 'w', newline='') as csvfile:
        with open('scores.txt', 'w') as csvfile:
            writer = csv.writer(csvfile, delimiter='\t',
                                quotechar='^', quoting=csv.QUOTE_MINIMAL)
            for line in lines:
                writer.writerow(line)
            writer.writerow([team, total_correct, total_questions])
        return total_correct
Example #5
0
    def __ask_to_break_lock(self, store, node):
        """
        Prompts the user for permission to break the lock file that another
        process has set on the file.
        """
        path = store.get_path(node)
        self.lock_file = store[path][PATH_COL]

        QuestionDialog(
            _("Break the lock on the '%s' database?") % store[path][0],
            _("Gramps believes that someone else is actively editing "
              "this database. You cannot edit this database while it "
              "is locked. If no one is editing the database you may "
              "safely break the lock. However, if someone else is editing "
              "the database and you break the lock, you may corrupt the "
              "database."), _("Break lock"), self.__really_break_lock)
Example #6
0
    def remove(self, obj):
        """
        Remove a person from the database.
        """
        for sel in self.selected_handles():
            person = self.dbstate.db.get_person_from_handle(sel)
            self.active_person = person
            name = name_displayer.display(person) 

            msg = _('Deleting the person will remove the person '
                             'from the database.')
            msg = "%s %s" % (msg, Utils.data_recover_msg)
            QuestionDialog(_('Delete %s?') % name, 
                                          msg, 
                                          _('_Delete Person'), 
                                          self.delete_person_response)
Example #7
0
 def delete_filter(self, obj):
     store, node = self.clist.get_selected()
     if node:
         gfilter = self.clist.get_object(node)
         name = gfilter.get_name()
         if self.check_recursive_filters(self.namespace, name):
             QuestionDialog( _('Delete Filter?'),
                             _('This filter is currently being used '
                               'as the base for other filters. Deleting'
                               'this filter will result in removing all '
                               'other filters that depend on it.'),
                             _('Delete Filter'),
                             self._do_delete_selected_filter,
                             self.window)
         else:
             self._do_delete_selected_filter()
Example #8
0
    def remove_selected_objects(self):
        """
        Function to remove selected objects
        """
        prompt = True
        if len(self.selected_handles()) > 1:
            q = QuestionDialog2(
                _("Confirm every deletion?"),
                _("More than one item has been selected for deletion. "
                  "Ask before deleting each one?"), _("No"), _("Yes"))
            prompt = not q.run()

        if not prompt:
            self.uistate.set_busy_cursor(1)

        for handle in self.selected_handles():
            (query, is_used, object) = self.remove_object_from_handle(handle)
            if prompt:
                if is_used:
                    msg = _('This item is currently being used. '
                            'Deleting it will remove it from the database and '
                            'from all other items that reference it.')
                else:
                    msg = _('Deleting item will remove it from the database.')

                msg += ' ' + Utils.data_recover_msg
                #descr = object.get_description()
                #if descr == "":
                descr = object.get_gramps_id()
                self.uistate.set_busy_cursor(1)
                QuestionDialog(
                    _('Delete %s?') % descr, msg, _('_Delete Item'),
                    query.query_response)
                self.uistate.set_busy_cursor(0)
            else:
                query.query_response()

        if not prompt:
            self.uistate.set_busy_cursor(0)
Example #9
0
 def _clear_clicked(self, obj=None):
     QuestionDialog(_("Delete confirmation"),
                    _("Are you sure you want to clear the Undo history?"),
                    _("Clear"), self.clear, self.window)