コード例 #1
0
ファイル: Entry.py プロジェクト: ra2003/xindex
 def addToNormalGroup(self):
     self.state.maybeSave()
     eid = self.state.viewAllPanel.view.selectedEid
     groups = set(self.state.model.normalGroups())
     inGroups = set(self.state.model.groupsForEid(eid))
     groups = sorted(groups - inGroups, key=lambda g: g[1].casefold())
     names = [g[1] for g in groups]
     if not names:  # Could happen if already in all the groups
         message = ("There are no other groups for this entry "
                    "to be added to.")
         QMessageBox.information(
             self.window,
             "Can't Link — {}".format(QApplication.applicationName()),
             message)
         return
     name, ok = QInputDialog.getItem(
         self.window,
         "Add to Normal Group — {}".format(QApplication.applicationName()),
         "Normal Group", names, 0, False)
     if ok:
         for gid, gname in groups:
             if gname == name:
                 self.state.model.addToGroup(eid, gid)
                 self.state.viewAllPanel.view.gotoEid(eid)
                 break
コード例 #2
0
ファイル: Entry.py プロジェクト: ra2003/xindex
 def addToLinkedGroup(self):
     self.state.maybeSave()
     eid = self.state.viewAllPanel.view.selectedEid
     groups = set(self.state.model.linkedGroups())
     inGroups = set(self.state.model.groupsForEid(eid))
     groups = sorted(groups - inGroups, key=lambda g: g[1].casefold())
     names = [
         g[1] for g in groups
         if self.state.model.safeToAddToGroup(eid, g[0])
     ]
     if not names:
         if self.state.model.linkedGroup(eid) is not None:
             message = "This entry is already in a linked group."
         else:
             message = ("There are no linked groups for this entry "
                        "to be added to.")
         QMessageBox.information(
             self.window,
             "Can't Link — {}".format(QApplication.applicationName()),
             message)
     else:
         name, ok = QInputDialog.getItem(
             self.window, "Add to Linked Group — {}".format(
                 QApplication.applicationName()), "Linked Group", names, 0,
             False)
         if ok:
             for gid, gname in groups:
                 if gname == name:
                     self.state.model.addToGroup(eid, gid)
                     self.state.viewAllPanel.view.gotoEid(eid)
                     break
コード例 #3
0
ファイル: score.py プロジェクト: thomasez/WalkInThePark
 def show_course_picker(self):
     course_list = self.db.get_course_list()
     coursename, ok = QInputDialog.getItem(self, 'Course name', 
         'Which course?', course_list, editable = False)
     if ok:
         print "Got name:" + coursename
         self.course = self.db.get_course(coursename)
         self.redraw()
コード例 #4
0
 def __add_fact(self):
     labels = self.__model.get_labels()
     rule_conclusion, entered = QInputDialog.getItem(self.__ui, self.tr("Enter rule conclusion label"),
                                                     self.tr("Conclusion"),
                                                     labels)
     if entered and rule_conclusion:
         self.__model.add_fact(rule_conclusion)
         self.__fill_facts()
コード例 #5
0
 def __add_condition_to_current_rule(self):
     if self.__current_model_position.rule_index is not None:
         labels = self.__model.get_labels()
         premise, valid = QInputDialog.getItem(self.__ui, self.tr("Enter premise"), self.tr("Premise"),
                                               labels)
         if valid:
             self.__model.add_condition_to_rule(premise, self.__current_model_position)
             self.__load_premises_for_current_rule()
         self.__update_helpers()
コード例 #6
0
 def __rename_item(self, item):
     labels = self.__model.get_labels()
     current_index = self.__get_index_of_item(item, labels)
     new_name, is_entered = QInputDialog.getItem(self.__ui, self.tr("Rename label"),
                                                 self.tr("New label name for '%s'") % item.text(),
                                                 labels, current_index)
     if is_entered:
         self.__model.rename(item.text(), new_name)
         self.__current_model_position.reset()
         self.__fill_facts()
コード例 #7
0
 def on_addRepositoryFromProjectButton_clicked(self):
     """Called when user clicks on 'import repository from OBS project'"""
     projects = self.manager.getLocalProjectList()
     selectedProject, accepted = QInputDialog.getItem(self.mainWindow,
                                                      "Select project",
                                                      "Project to import repository from:",
                                                      projects,
                                                      editable=False)
     if not accepted:
         return
     repoUrl = self.callWithInfiniteProgress(self.manager.getProjectRepository,
                                             "Retrieving repository URL...",
                                             selectedProject)
     self._currentProjectObj.addRepository(selectedProject, repoUrl)
コード例 #8
0
def queryAttributeChoice(parentDialog):
  objName = str(pm.ls(sl=1)[0]) # getting the first selected object

  if QApplication.keyboardModifiers() == Qt.ControlModifier:
    attrs = pm.listAttr(objName, w=1) # Ctrl pressed => showing all writeable channels
  elif QApplication.keyboardModifiers() == Qt.AltModifier:
    attrs = pm.listAttr(objName, ud=1) # Alt pressed => showing only user defined channels
  else:
    attrs = pm.listAttr(objName, k=1) # otherwise showing only keyable channels

  choice = QInputDialog.getItem(parentDialog, "Attributes", "Choose an attribute to be driven", attrs)
  if choice[1]:
    return "{obj}.{attr}".format(obj=objName, attr=choice[0]) # formatting the full attribute name
  else: # if no choice has been made (window closed etc)
    return None
コード例 #9
0
 def modifyRepo(self):
     """
     Run this method to modify the URL or alias of a repository.
     """
     repos = self.manager.getChRootRepositories(self.__projectAlias)
     if repos is None or len(repos) < 1:
         return
     selectedAlias, accepted = QInputDialog.getItem(
         self.mainWindow,
         "Select repository",
         "Project repository to modify:",
         repos.keys(),
         editable=False)
     if not accepted:
         return
     self.importFromUrl()
     self.__configDialog.repoAliasLineEdit.setText(selectedAlias)
     self.__configDialog.repoUrlLineEdit.setText(repos[selectedAlias])
     self.__oldRepoAlias = selectedAlias
コード例 #10
0
 def importFromProject(self):
     """
     Run this method in order to add the repository of another OBS project.
     """
     projects = self.manager.getLocalProjectList()
     selectedProject, accepted = QInputDialog.getItem(
         self.mainWindow,
         "Select project",
         "Project to import repository from:",
         projects,
         editable=False)
     if not accepted:
         return
     progress = self.gui.getInfiniteProgressDialog()
     runnable = ProgressRunnable2()
     runnable.setProgressDialog(progress)
     runnable.setDialogMessage("Importing repository...")
     runnable.setRunMethod(self.manager.addRepo,
                           self.__projectAlias,
                           fromProject=selectedProject)
     runnable.caughtException.connect(self.gui.popupErrorCallback)
     QThreadPool.globalInstance().start(runnable)
コード例 #11
0
 def deleteRepo(self):
     """
     Run this method to remove a repository from the project file system.
     """
     repos = self.manager.getChRootRepositories(self.__projectAlias)
     if repos is None or len(repos) < 1:
         return
     selectedAlias, accepted = QInputDialog.getItem(
         self.mainWindow,
         "Select repository",
         "Project repository to delete:",
         repos.keys(),
         editable=False)
     if not accepted:
         return
     progress = self.gui.getInfiniteProgressDialog()
     runnable = ProgressRunnable2()
     runnable.setProgressDialog(progress)
     runnable.setDialogMessage("Deleting repository...")
     runnable.setRunMethod(self.manager.deleteRepo, self.__projectAlias,
                           selectedAlias)
     runnable.caughtException.connect(self.gui.popupErrorCallback)
     QThreadPool.globalInstance().start(runnable)
コード例 #12
0
    def create_new_wallet(self):
        wallet_password = None
        wallet_filepath = ""
        try:
            has_password = False
            while True:
                wallet_password, result = self._custom_input_dialog(self.new_wallet_ui, \
                        "Wallet Password", "Set new wallet password:"******"Password must contain at least 1 character [a-zA-Z] or number [0-9]\
                                        <br>or special character like !@#$%^&* and not contain spaces"                                                                                                      )
                        continue

                    confirm_password, result = self._custom_input_dialog(self.new_wallet_ui, \
                        'Wallet Password', \
                        "Confirm wallet password:"******"Confirm password does not match password!\
                                                 <br>Please re-enter password"                                                                              )
                        else:
                            has_password = True
                            break
                    else:
                        break
                else:
                    break

            if has_password:
                mnemonic_seed_language = "English"
                seed_language_list = [sl[1] for sl in seed_languages]
                list_select_index = 1
                lang, ok = QInputDialog.getItem(
                    self.new_wallet_ui, "Mnemonic Seed Language",
                    "Select a language for wallet mnemonic seed:",
                    seed_language_list, list_select_index, False)
                if ok and lang:
                    for sl in seed_languages:
                        if sl[1] == lang:
                            mnemonic_seed_language = sl[0]
                            break
                else:
                    return

                self.on_new_wallet_show_progress_event.emit(
                    "Creating wallet...")
                self.app_process_events(0.1)
                wallet_filename = self.get_new_wallet_file_name()
                wallet_filepath = os.path.join(wallet_dir_path,
                                               wallet_filename)

                while not self.ui.wallet_rpc_manager.is_ready():
                    self.app_process_events(0.1)
                ret = self.ui.wallet_rpc_manager.rpc_request.create_wallet(
                    wallet_filename, wallet_password, mnemonic_seed_language)
                if ret['status'] == "ERROR":
                    error_message = ret['message']
                    QMessageBox.critical(self.new_wallet_ui, \
                            'Error Creating Wallet',\
                            "Error: %s" % error_message)
                    raise Exception("Error creating wallet: %s" %
                                    error_message)

                self.current_block_height = 0  # reset current wallet block height

                self.ui.wallet_info.wallet_filepath = wallet_filepath
                self.ui.wallet_info.wallet_password = hashlib.sha256(
                    wallet_password).hexdigest()
                self.ui.wallet_info.is_loaded = True
                self.ui.wallet_info.save()

                self.show_wallet_info()
        except Exception, err:
            log(str(err), LEVEL_ERROR)
            self.ui.reset_wallet(delete_files=False)
            self.on_new_wallet_ui_reset_event.emit()
            return
コード例 #13
0
ファイル: commands.py プロジェクト: howetuft/FreeCAD-render
    def Activated(self):  # pylint: disable=no-self-use
        """Respond to Activated event (callback).

        This code is executed when the command is run in FreeCAD.
        It sets the Material property of the selected object(s).
        If the Material property does not exist in the object(s), it is
        created.
        """
        # Get selected objects
        selection = Gui.Selection.getSelection()
        if not selection:
            title = translate("Render", "Empty Selection")
            msg = translate(
                "Render",
                "Please select object(s) before applying "
                "material.",
            )
            QMessageBox.warning(None, title, msg)
            return

        # Let user pick the Material
        mats = [
            o for o in App.ActiveDocument.Objects
            if o.isDerivedFrom("App::MaterialObjectPython")
        ]
        if not mats:
            title = translate("Render", "No Material")
            msg = translate(
                "Render",
                "No Material in document. Please create a "
                "Material before applying.",
            )
            QMessageBox.warning(None, title, msg)
            return
        matlabels = [m.Label for m in mats]
        current_mats_labels = [
            o.Material.Label for o in selection if hasattr(o, "Material")
            and hasattr(o.Material, "Label") and o.Material.Label
        ]
        current_mats = [
            count for count, val in enumerate(matlabels)
            if val in current_mats_labels
        ]
        current_mat = current_mats[0] if len(current_mats) == 1 else 0

        userinput, status = QInputDialog.getItem(
            None,
            translate("Render", "Material Applier"),
            translate("Render", "Choose Material to apply to selection:"),
            matlabels,
            current_mat,
            False,
        )
        if not status:
            return

        material = next(m for m in mats if m.Label == userinput)

        # Update selected objects
        App.ActiveDocument.openTransaction("MaterialApplier")
        for obj in selection:
            # Add Material property to the object if it hasn't got one
            if "Material" not in obj.PropertiesList:
                obj.addProperty(
                    "App::PropertyLink",
                    "Material",
                    "",
                    QT_TRANSLATE_NOOP("App::Property",
                                      "The Material for this object"),
                )
            try:
                obj.Material = material
            except TypeError:
                msg = (translate(
                    "Render",
                    "Cannot apply Material to object '%s': "
                    "object's Material property is of wrong "
                    "type",
                ) + "\n")
                App.Console.PrintError(msg % obj.Label)
        App.ActiveDocument.commitTransaction()