def _notebook_new_name(self, title, exclude=''): names = map(lambda nb: Notebook.from_tuple(nb).name, self.app.provider.list_notebooks()) try: names.remove(exclude) except ValueError: pass name, status = QInputDialog.getText(self, title, self.tr('Enter notebook name:'), text=exclude) while name in names and status: message = self.tr('Notebook with this name already exist. Enter notebook name') name, status = QInputDialog.getText(self, title, message) return name, status
def testQDialog(self): dlg = QInputDialog() dlg.setInputMode(QInputDialog.TextInput) lst = dlg.children() self.assert_(len(lst)) obj = lst[0] self._called = False obj.destroyed[QObject].connect(self.cb) obj = None del dlg self.assert_(self._called)
def item_clicked(self, row, col): ''' action to perform when one item is clicked :param row: item row :param col: item col :return: ''' item = self.stuff_table.item(row, col) if item is None: # if Item is none ignore return bg = item.background() if bg == QColor(255, 128, 128): # if item is colorful ask the user to add cals name = self.stuff_table.item(row, 2).text() text, ok = QInputDialog.getText( self, 'Calorie Input Dialog', 'Enter the calories per 100g for %s:' % name) reg = re.compile('([0-9,.]+)') cif = reg.match(text) if cif is None or len(cif.group(1)) == 0: return # if cal is added reprint the item self.recipe_reader.get_hive_connection().set_calorie_for_name( name, int(cif.group(1))) self.stuff_table.item(row, 0).setBackground(QColor(0, 0, 0)) self.stuff_table.item(row, 1).setBackground(QColor(0, 0, 0)) self.stuff_table.item(row, 2).setBackground(QColor(0, 0, 0))
def _insert_link(self): url, ok = QInputDialog.getText( self.parent, self.app.tr("Everpad / Insert link"), self.app.tr("Press link address") ) if ok and url: self.page.mainFrame().evaluateJavaScript("insertLink(%s);" % json.dumps(url)) self.page_changed()
def _change_link(self, url): url, ok = QInputDialog.getText( self.parent, self.app.tr("Everpad / Change link"), self.app.tr("Press new link address"), text=url ) if ok and url: self.page.mainFrame().evaluateJavaScript("changeLink(%s);" % json.dumps(url)) self.page_changed()
def onSearchByWord(self): text, ok = QInputDialog.getText(self, 'Search the base by word(s)', 'Enter your keyword/phrase to search for:') if ok: words = [t.strip() for t in nltk.tokenize.regexp_tokenize(text.lower(), r'\w+')] self.table_view.model().emit(SIGNAL("modelAboutToBeReset()")) self.table_view.model().criteria = {'Description' : words} self.table_view.model().emit(SIGNAL("modelReset()"))
def addNewOverlay(self): """ Add a new overlay file. Asks user for source and destination. """ extensions = (".tar", ".tar.gz", ".tar.bz2", ".tgz", ".tbz", ".tz2", ".tar.xz") filters = "Tar archives (%s);;" % " *".join(extensions) filters += "All files (*)" srcPath, _filter = QFileDialog.getOpenFileName(self.mainWindow, "Select source file", filter=filters) if len(srcPath) < 1: return srcPath = str(srcPath.encode("utf-8")) defaultDstPath = "/%s" % os.path.basename(srcPath) for ext in extensions: if srcPath.endswith(ext): defaultDstPath = "/" dstPath, accepted = QInputDialog.getText( self.mainWindow, "Select destination", "Select destination file or directory where " + "archive will be extracted", text=defaultDstPath) if not accepted: return self.callWithInfiniteProgress( self.overlayModel.newOverlayFile, "Copying overlay file in project directory...", source=srcPath, destination=dstPath) self.refresh()
def Activated(self): doc = FreeCAD.ActiveDocument (text, ok) = QInputDialog.getText(None, Title_MessageBoxes, "Name for optical system?", QLineEdit.Normal) osobs = None if text and ok: osobs = OpticalSystemObserver(doc, text) if existsStandardMaterials(doc): result = QMessageBox.question( None, Title_MessageBoxes, "No Standard Materials Catalogue defined. Create one?", QMessageBox.Yes | QMessageBox.No) if result == QMessageBox.Yes: stdmatcatalogue = MaterialCatalogueObject( doc, Group_StandardMaterials_Label) stdmatcatalogue.addMaterial("ConstantIndexGlass", "PMMA", index=1.5) stdmatcatalogue.addMaterial("ConstantIndexGlass", "Vacuum") stdmatcatalogue.addMaterial("ModelGlass", "mydefaultmodelglass") if osobs != None: osobs.initFromGivenOpticalSystem(osobs.initDemoSystem())
def sip_input(self): self.lebutton.setEnabled(False) self.s_bar.setStyleSheet(self.s_norm) self.s_bar.showMessage('> Checking out the IP ..') msg = "<center>Enter suspected IP to check : <br><i><u>Usually it is " msg += "on 192.168.what_have_you.188</i></center>" text, okPressed = QInputDialog.getText(self, "Scan IP", msg) if okPressed and text != '': self.setCursor(Qt.BusyCursor) ch = is_ccast(text) if ch: self.il_add([text]) self.unsetCursor() self.lebutton.setEnabled(True) return True else: self.s_bar.setStyleSheet(self.s_error) self.s_bar.showMessage( '! Error: inserted IP is not chrome cast device') self.unsetCursor() self.lebutton.setEnabled(True) return True self.s_bar.clearMessage() self.lebutton.setEnabled(True) return True
def trigger_configuration(self): label, a = QInputDialog.getText(self.widget, "Set label text", "Enter label text for button", QLineEdit.Normal, self.label) if a: self.label = label self.widget.set_label(self.label)
def askGoToLine(self): line, ok = QInputDialog.getInt( self, self.trUtf8(b'Goto line'), self.trUtf8(b'Line number:'), self.editor.textCursor().blockNumber(), 1, self.editor.document().blockCount()) if ok: self.goToLine(line)
def showContextMenu(self, pos): """ Shows a context menu to add a node in the graph widget """ gpos = self.graphicsView.mapToGlobal(pos) menu = QMenu() actionAddNode = menu.addAction("Add Node") QAction = menu.exec_(gpos) if (actionAddNode == QAction): (text, ok) = QInputDialog.getText(self.graphicsView, "Insert Node Name", "Please insert a name for the node") if ok: if text not in self.nodesToQNodes: #User clicked on ok. Otherwise do nothing self.gv.add_node(text) node = self.gv.get_node(text) qnode = self.createQtNode(node, 0, 0, QColor(204, 255, 255)) self.graphicsView.scene().addItem(qnode) qnode.setPos(self.graphicsView.mapToScene(gpos)) qnode.setPos(qnode.x(), qnode.y() - 200) self.nodesToQNodes[node] = qnode else: msg = QMessageBox() msg.setText("The node already exists.") msg.exec_() self.searchNode(text)
def save_course(self): coursename, ok = QInputDialog.getText(self, 'Course name', 'Which course?') if ok and coursename: print "Got name:" + coursename self.db.save_score_as_course(self.walk, coursename) self.redraw()
def _notebook_new_name(self, title, exclude=''): names = map(lambda nb: Notebook.from_tuple(nb).name, self.app.provider.list_notebooks()) try: names.remove(exclude) except ValueError: pass name, status = QInputDialog.getText(self, title, self.tr('Enter notebook name:'), text=exclude) while name in names and status: message = self.tr( 'Notebook with this name already exist. Enter notebook name') name, status = QInputDialog.getText(self, title, message) return name, status
def getNewName(self, item): """Shows a dialog, and sets item name to user input.""" # ret = tuple string, bool ret = QInputDialog.getText(self, self.str_setName, self.str_name) if ret[1] and item.data.setName(ret[0]): # Not canceled. item.update() self.parent().optionsDock.widget().updateOptions()
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
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
def getPass(self): passwd, re = QInputDialog.getText(self, "Password", "Enter password :", QLineEdit.Password) if not re: return False if len(passwd) <= 0: return None return passwd
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()
def Activated(self): doc = FreeCAD.ActiveDocument (text, ok) = QInputDialog.getText(None, Title_MessageBoxes, "Name for material catalogue?", QLineEdit.Normal) if text and ok: MaterialCatalogueObject(doc, text)
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()
def setServer(self): ''' open dialog to set server address e.g. localhost, 192.168.1.5 ''' text, ok = QInputDialog.getText(self, "Set server", 'Enter server adress') if ok: self.server.host = text
def on_addPackageGroupButton_clicked(self): """Called when user clicks on 'add package group'""" selectedPackageGroup, accepted = QInputDialog.getText(self.mainWindow, "Select package group", "Enter a package group name:") if not accepted or len(selectedPackageGroup) < 1: return self._currentProjectObj.addPackageGroup(selectedPackageGroup)
def Activated(self): selection = [s for s in FreeCADGui.Selection.getSelection() if s.Document == FreeCAD.ActiveDocument ] (name_of_child, accepted) = QInputDialog.getText(None, "Pyrate", "Name of Child Local Coordinates System", QLineEdit.Normal, "") if len(selection) == 1 and accepted: obj = selection[0] if isLocalCoordinatesObserver(obj): obj.lcobserver.addChild(name = name_of_child)
def getPass2(self): passwd, re = QInputDialog.getText(self, u"비밀번호", u"입력하신 비밀번호 :", QLineEdit.Password) if not re: return False if len(passwd) <= 0: return None return passwd
def _addcategory(self): """Adds a category under the selected parent.""" cat, ok = QInputDialog.getText(self, "New Category", "Enter new category name") if ok and not cat is None and len(cat) > 0: parent = -1 if self._currentcategory is None\ else self._currentcategory[0] self._backend.addcategory(parent, cat) self.refresh()
def setServer(self): ''' dialog is opened to enter server address: e.g. localhost, 192.168.1.5 ''' text, ok = QInputDialog.getText(self, 'Input Dialog', 'Enter your server-address:') if ok: self.server.host = text
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()
def save_tc_history_callback(self): mt = MakoTranslate() d = Database(self.HISTORY_DB) d.create_history_table() widget_gui = QInputDialog() save_name, ok = QInputDialog.getText(widget_gui, "Save TC", "Name of TC to be saved:") if not ok: return pck_sec_header, src_data = self.view.get_tc_text() pck_sec_header = json.loads(mt.replace(pck_sec_header)) src_data = json.loads(mt.replace(src_data)) self.command["data"]["pck_sec_head"] = pck_sec_header self.command["data"]["user_data"]["src_data"] = src_data d.insert_db("INSERT INTO history VALUES(?, ?)", [[save_name, json.dumps(self.command)]]) self.show_history()
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()
def edit_title(self): newTitle, result = QInputDialog.getText(None, 'new title', 'enter a new title') if not result: return item = self.get_item(self.tree.currentItem()) item.label = newTitle save(item, newTitle) self.tree.currentItem().setText(0, item.label)
def addString(self, *args): dlg = QInputDialog() dlg.setInputMode(QInputDialog.TextInput) txt, ok = dlg.getText(self, self.addCaption, self.addLabel) # , txt = txt.rstrip('\\') txt = txt.rstrip('/') txt = txt.rstrip(';') txt = txt.rstrip() # QLineEdit.Normal, self.listBox.currentItem().text()) if ok and (txt is not None): # if (not self.duplicatesOk and self.listBox.findItem(txt, CaseSensitive | ExactMatch)): # return self.listBox.addItem(txt) self.listBox.setCurrentRow(self.listBox.count() - 1) self.listBox.clearSelection() self.refreshList()
def _insert_link(self): url, ok = QInputDialog.getText( self.parent, self.tr('Everpad / Insert link'), self.tr('Press link address'), ) if ok and url: self.page.mainFrame().evaluateJavaScript( 'insertLink(%s);' % json.dumps(url), ) self.page_changed()
def _insert_link(self): url, ok = QInputDialog.getText(self.parent, self.tr('Everpad / Insert link'), self.tr('Press link address'), ) if ok and url: self.page.mainFrame().evaluateJavaScript( 'insertLink(%s);' % json.dumps(url), ) self.page_changed()
def getPass(self): passwd, re = QInputDialog.getText(self, u"비밀번호", u"입력하신 비밀번호 :", QLineEdit.Password) if len(passwd) > 0 : passwd2, re = QInputDialog.getText(self, u"비밀번호", u"다시한번 입력하세요 :", QLineEdit.Password) if passwd != passwd2: self.errorMsg(u"비밀번호가 맞지 않습니다") return False else: if not re: return False if len(passwd) <= 0: return None return passwd else: if not re: return False else: return None
def _change_link(self, url): url, ok = QInputDialog.getText( self.parent, self.tr('Everpad / Change link'), self.tr('Press new link address'), text=url, ) if ok and url: self.page.mainFrame().evaluateJavaScript( 'changeLink(%s);' % json.dumps(url), ) self.page_changed()
def addDept(self): text, ok = QInputDialog.getText(self.dialog, u"Нормы обеспеченности", u"Введите название кафедры:", QtGui.QLineEdit.Normal, None, QtCore.Qt.WindowSystemMenuHint) if ok and text: self.depts.append((self.nextId, text)) self.nextId += 1 self.comboBox.clear() self.comboBox.addItems([dept[1] for dept in self.depts]) self.setDeptsTable()
def _change_link(self, url): url, ok = QInputDialog.getText(self.parent, self.tr('Everpad / Change link'), self.tr('Press new link address'), text=url, ) if ok and url: self.page.mainFrame().evaluateJavaScript( 'changeLink(%s);' % json.dumps(url), ) self.page_changed()
def addSelection(self,doc,obj,sub,pnt): Obj=FreeCAD.getDocument(doc).getObject(obj) if self.beam==None and Obj.TypeId=='Part::FeaturePython' and hasattr(Obj,'Height'): self.beam=Obj FreeCAD.Console.PrintMessage('Beam type selected.\n') from PySide.QtGui import QInputDialog as qid dist=float(qid.getText(None,"stretch a beam","old length = "+str(self.beam.Height)+"\nnew length?")[0]) frameCmd.stretchTheBeam(self.beam,dist) FreeCAD.activeDocument().recompute() self.av.removeEventCallback("SoKeyboardEvent",self.stop) FreeCADGui.Selection.removeObserver(self) FreeCAD.Console.PrintMessage("I quit.")
def Activated(self): if hasattr(FreeCAD,'DraftWorkingPlane') and hasattr(FreeCADGui,'Snapper'): import polarUtilsCmd s=FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Draft").GetInt("gridSize") sc=[float(x*s) for x in [1,1,.2]] arrow =polarUtilsCmd.arrow(FreeCAD.DraftWorkingPlane.getPlacement(),scale=sc,offset=s) from PySide.QtGui import QInputDialog as qid offset=qid.getInteger(None,'Offset Work Plane','Offset: ') if offset[1]: polarUtilsCmd.offsetWP(offset[0]) #FreeCADGui.ActiveDocument.ActiveView.getSceneGraph().removeChild(arrow.node) arrow.closeArrow()
def onChange(self): if self.value.text() != "": defaultFloat = float(self.value.text()) num, ok = QInputDialog.getDouble(self, "Input", "Enter new value:", defaultFloat, min=0, max=2147483647, decimals=3) if ok: self.value.setText(str(num))
def on_newMicProjectButton_clicked(self): """Called when user clicks on 'new project'""" name, accepted = QInputDialog.getText(self.mainWindow, "New MIC project", "Select a name for the new project:") if not accepted or len(name) < 1: return name = name.replace(" ", "_") name = name.replace(":", "_") self.callWithInfiniteProgress(self.manager.addMicProject, "Creating MIC project", name) self.refresh()
def Activated(self): selection = [ s for s in FreeCADGui.Selection.getSelection() if s.Document == FreeCAD.ActiveDocument ] (name_of_child, accepted) = QInputDialog.getText( None, "Pyrate", "Name of Child Local Coordinates System", QLineEdit.Normal, "") if len(selection) == 1 and accepted: obj = selection[0] if isLocalCoordinatesObserver(obj): obj.lcobserver.addChild(name=name_of_child)
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)
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
def addSelection(self, doc, obj, sub, pnt): Obj = FreeCAD.getDocument(doc).getObject(obj) if self.beam == None and Obj.TypeId == 'Part::FeaturePython' and hasattr( Obj, 'Height'): self.beam = Obj FreeCAD.Console.PrintMessage('Beam type selected.\n') from PySide.QtGui import QInputDialog as qid dist = float( qid.getText( None, "stretch a beam", "old length = " + str(self.beam.Height) + "\nnew length?")[0]) frameCmd.stretchTheBeam(self.beam, dist) FreeCAD.activeDocument().recompute() self.av.removeEventCallback("SoKeyboardEvent", self.stop) FreeCADGui.Selection.removeObserver(self) FreeCAD.Console.PrintMessage("I quit.")
def batchRename(self): """Experimental function to rename multiple items at once.""" sel = self.scene().selectedItems() if ( not all([isinstance(i, sel[0].__class__) for i in sel]) or (isinstance(sel[0].data, Plug) and not all([ i.data.isInput == sel[0].data.isInput for i in sel]))): print("Error") return ret = QInputDialog.getText(self, "Set prefix", "Prefix :") if ret[1] and len(ret[0]): for i in self.scene().selectedItems(): i.data.generate_name(None, ret[0]) i.setupPaint() self.parent().optionsDock.widget().updateOptions()
def Activated(self): doc = FreeCAD.ActiveDocument (text, ok) = QInputDialog.getText(None, Title_MessageBoxes, "Name for optical system?", QLineEdit.Normal) osobs = None if text and ok: osobs = OpticalSystemObserver(doc, text) if not existsStandardMaterialsCatalogue(doc): # No question for adding the standard material catalogue anymore # result = QMessageBox.question(None, Title_MessageBoxes, # "No Standard Materials Catalogue defined. Create one?", # QMessageBox.Yes | QMessageBox.No) # if result == QMessageBox.Yes: # create standard materials catalogue stdmatcatalogue = MaterialCatalogueObject( doc, Group_StandardMaterials_Label) else: # get standard materials catalogue stdmatcatalogue = getStandardMaterialsCatalogueObject(doc) if stdmatcatalogue is not None: # TODO: put initialization procedure elsewhere # check whether the materials are already in the catalogue # if yes, do nothing stdmatcatalogue_group = getStandardMaterialsCatalogue(doc) all_materials_in_stdmatcatalogue =\ getAllMaterialsFromMaterialCatalogue(stdmatcatalogue_group) if not any([ material.Name in ("PMMA", "Vacuum", "mydefaultmodelglass") for material in all_materials_in_stdmatcatalogue ]): # checked for .Name since .Label may change afterwards, Name # not stdmatcatalogue.addMaterial("ConstantIndexGlass", "PMMA", index=1.5) stdmatcatalogue.addMaterial("ConstantIndexGlass", "Vacuum") stdmatcatalogue.addMaterial("ModelGlass", "mydefaultmodelglass") if osobs != None: osobs.initFromGivenOpticalSystem(osobs.initDemoSystem())
def yv_input(self): text, okPressed = QInputDialog.getText( self, "Stream youtube", "Enter youtube video link to be streamed :") if okPressed and text != '': ntext = text.split('?') if len(ntext) <= 1: self.s_bar.setStyleSheet(self.s_error) self.s_bar.showMessage('! Error: Invalid youtube linkd ') return False ntext = ntext[1] if ntext != '' and len(ntext) > 1 and "youtube" in text: self.y_act(ntext) return True else: self.s_bar.setStyleSheet(self.s_error) self.s_bar.showMessage('! Error: Invalid youtube linkd ') return False
def Activated(self): doc = FreeCAD.ActiveDocument (text, ok) = QInputDialog.getText(None, Title_MessageBoxes, "Name for optical system?", QLineEdit.Normal) osobs = None if text and ok: osobs = OpticalSystemObserver(doc, text) if existsStandardMaterials(doc): result = QMessageBox.question(None, Title_MessageBoxes, "No Standard Materials Catalogue defined. Create one?", QMessageBox.Yes | QMessageBox.No) if result == QMessageBox.Yes: stdmatcatalogue = MaterialCatalogueObject(doc, Group_StandardMaterials_Label) stdmatcatalogue.addMaterial("ConstantIndexGlass", "PMMA", index=1.5) stdmatcatalogue.addMaterial("ConstantIndexGlass", "Vacuum") stdmatcatalogue.addMaterial("ModelGlass", "mydefaultmodelglass") if osobs != None: osobs.initFromGivenOpticalSystem(osobs.initDemoSystem())
def __envoyer(self): """Envoie l'email""" index = self._ui.cbAbsence.currentIndex() dest = self.__absences[index]["adresse"] sujet = self._ui.leSujet.text() corps = self._ui.teCorps.toPlainText() try: password = self.__password except AttributeError: result = QInputDialog.getText(self, "Mot de passe", "Veuillez saisir le mot de passe<br /> " + "de votre compte de messagerie", QLineEdit.Password) self.__password = str(result[0]) password = self.__password if not result[1]: return self.__activerUi(False) self.notification.emit("Email en cours d'envoi", MailUI.DUREE_MESSAGE) self.__ms.envoiMail(dest, sujet, corps, password)
def _stack_new_name(self, title, value=''): name, status = QInputDialog.getText(self, title, self.tr('Enter stack name:'), text=value) return name, status
def show_name_input_dialog(self): text, ok = QInputDialog.getText(self, 'Player name', 'Enter your name:') if ok: print "Got name:" + text
def importShiftData(parent): pyrite_file_name, filt = QFileDialog.getOpenFileName(parent, "Select Pyrite Project", filter="Pyrite Projects (*.pyrite)") if not pyrite_file_name: return pyrite_project = Project.fromFile(pyrite_file_name) design_package = pyrite_project.design.package design_die = design_package.dies[0] excel_file_name, filt = QFileDialog.getOpenFileName(parent, "Select Shifts Excel File", filter="Excel Files (*.xlsx *.xlsm)") if not excel_file_name: return panel_id = "" match = re.search("(?:D[0-9]+_[A-Z]_)([0-9]+)(?:.*\.xls.*)|(?:MP.+\.)" "([0-9]+)(?:\..*\.xls.*)", excel_file_name) if match: panel_id += [g for g in match.groups() if g is not None][0] panel_id, good = QInputDialog.getText(parent, "Panel ID", "Enter the panel ID", text=panel_id) if not panel_id: return excel_wb = openpyxl.reader.excel.load_workbook(excel_file_name) sheet_names = excel_wb.get_sheet_names() preselect_sheets = [s for s in sheet_names if "calculated values" in s.lower()] global_offset_txt = "" if preselect_sheets: sheet = excel_wb.get_sheet_by_name(preselect_sheets[0]) if sheet.cell("A1").value == "Global X Shift:" and\ sheet.cell("A2").value == "Global Y Shift:": global_offset_txt = "{0}, {1}".format(sheet.cell("C1").value, sheet.cell("C2").value) while True: global_offset_txt, good = QInputDialog.getText(parent, "Global Offset", "Enter the panel's global offset (x, y) (e.g. 533.33, 434.3)", text=global_offset_txt) if not global_offset_txt: return try: tokens = [t.strip() for t in global_offset_txt.split(',')] global_x = float(tokens[0]) global_y = float(tokens[1]) break except: QMessageBox.warning(parent, "Global Offset", "{0} is not a valid global offset".format(global_offset_txt)) data_selector = ExcelShiftDataSelector(parent, sheet_names) data_selector.setWindowTitle("Select Die Shifts") preselect_sheets = [s for s in sheet_names if "calculated values" in s.lower()] if preselect_sheets: data_selector.cmboSheet.setCurrentIndex( sheet_names.index(preselect_sheets[0])) sheet = excel_wb.get_sheet_by_name(preselect_sheets[0]) if sheet.cell("B4").value == "Package Nominal": if sheet.cell("B5").value == "X (um)": data_selector.txtNomX.setText("B6") if sheet.cell("C5").value == "Y (um)": data_selector.txtNomY.setText("C6") if sheet.cell("D4").value == "Die Shift (Deviation)": if sheet.cell("D5").value == "X (um)": data_selector.txtXShift.setText("D6") if sheet.cell("E5").value == "Y (um)": data_selector.txtYShift.setText("E6") if sheet.cell("F5").value == "Theta (deg)": data_selector.txtTheta.setText("F6") if sheet.cell("D1").value == "Package Count:": data_selector.txtCount.setText(str(sheet.cell("F1").value)) data_selector.exec_() if data_selector.result() == QDialog.Rejected: return die_shifts = [] worksheet = excel_wb.get_sheet_by_name(data_selector.sheetName) for i in range(data_selector.count): nomx = float(worksheet.cell(row=data_selector.nomXRow + i, column=data_selector.nomXCol).value) nomy = float(worksheet.cell(row=data_selector.nomYRow + i, column=data_selector.nomYCol).value) shiftx = float(worksheet.cell(row=data_selector.shiftXRow + i, column=data_selector.shiftXCol).value) shifty = float(worksheet.cell(row=data_selector.shiftYRow + i, column=data_selector.shiftYCol).value) theta = float(worksheet.cell(row=data_selector.thetaRow + i, column=data_selector.thetaCol).value) die_shifts.append((nomx, nomy, shiftx, shifty, theta)) data_selector = ExcelShiftDataSelector(parent, sheet_names) data_selector.setWindowTitle("Select Fiducial Die Shifts") data_selector.txtDieName.setText("FIDUCIAL") preselect_sheets = [s for s in sheet_names if "fiducial" in s.lower()] if preselect_sheets: data_selector.cmboSheet.setCurrentIndex( sheet_names.index(preselect_sheets[0])) data_selector.exec_() if data_selector.result() == QDialog.Rejected: return fiducial_shifts = [] worksheet = excel_wb.get_sheet_by_name(data_selector.sheetName) for i in range(data_selector.count): nomx = float(worksheet.cell(row=data_selector.nomXRow + i, column=data_selector.nomXCol).value) nomy = float(worksheet.cell(row=data_selector.nomYRow + i, column=data_selector.nomYCol).value) shiftx = float(worksheet.cell(row=data_selector.shiftXRow + i, column=data_selector.shiftXCol).value) shifty = float(worksheet.cell(row=data_selector.shiftYRow + i, column=data_selector.shiftYCol).value) theta = float(worksheet.cell(row=data_selector.thetaRow + i, column=data_selector.thetaCol).value) fiducial_shifts.append((nomx, nomy, shiftx, shifty, theta)) shifts = zinc_pb2.Shifts() shifts.designNumber = design_package.designNumber shifts.designRevision = design_package.designRevision shifts.panelID = panel_id shifts.globalOffset.x = global_x shifts.globalOffset.y = global_y constraints = design_die.shiftConstraints for die_unit in die_shifts: zunit = shifts.units.add() zunit.number = die_shifts.index(die_unit) zunit.center.x = die_unit[0] zunit.center.y = die_unit[1] zdieshift = zunit.die.add() zdieshift.name = design_die.name zdieshift.nominalXY.x = die_unit[0] + design_die.center.x zdieshift.nominalXY.y = die_unit[1] + design_die.center.y zdieshift.shift.x = die_unit[2] zdieshift.shift.y = die_unit[3] zdieshift.theta = math.radians(die_unit[4]) zunit.inSpec = check_in_spec(zdieshift, constraints) for fiducial_unit in fiducial_shifts: zunit = shifts.referenceUnits.add() zunit.number = fiducial_shifts.index(fiducial_unit) zunit.center.x = die_unit[0] zunit.center.y = die_unit[1] zdieshift = zunit.die.add() zdieshift.name = "FIDUCIAL" zdieshift.nominalXY.x = fiducial_unit[0] zdieshift.nominalXY.y = fiducial_unit[1] zdieshift.shift.x = fiducial_unit[2] zdieshift.shift.y = fiducial_unit[3] zdieshift.theta = math.radians(fiducial_unit[4]) zunit.inSpec = True filename, filt = QFileDialog.getSaveFileName(parent, "Save Shifts File", filter="Onyx Shift Files (*.onyxshifts)") if not filename: return file = open(filename, "wb") file.write(text_format.MessageToString(shifts)) file.close()