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 _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 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 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 _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 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 _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 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 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 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 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 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 material catalogue?", QLineEdit.Normal) if text and ok: MaterialCatalogueObject(doc, text)
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 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 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 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 _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 _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 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 _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 _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 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 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 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 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 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): 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 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 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 editString(self, *args): currentItem = self.listBox.currentItem() if not currentItem: self.addString() return original = currentItem.text() if original is not None: txt, ok = QInputDialog.getText(self, self.editCaption, self.editLabel, QLineEdit.Normal, original) if ok and (txt is not None): # if (not self.duplicatesOk and self.listBox.findItem(txt, CaseSensitive | ExactMatch)): # return self.listBox.currentItem().setText(txt) self.refreshList() self.updateButtons()
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 add(self): # No need to restore focus widget self.save() with Lib.DisableUI(self, forModalDialog=True): extension, ok = QInputDialog.getText( self, "Add Custom Markup -— {}".format( QApplication.applicationName()), "Extension") if ok and extension and extension.strip(): extension = extension.strip() if not extension.startswith("."): extension = "." + extension index = self.extensionComboBox.findText(extension, Qt.MatchExactly) if index != -1: self.extensionComboBox.setCurrentIndex(index) else: self.extension = extension self.markup = Output.Markup.user_markup() self.state.model.updateMarkup(self.extension, self.markup) self.extensionComboBox.addItem(extension) self.extensionComboBox.setCurrentIndex( self.extensionComboBox.count() - 1)
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 __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 savePacketSet(self, packetSet): """ Save a PacketSet to the database. If there's a name collision, the user will be prompted for a new and unique name. :param packetSet: The PacketSet to save """ currentName = packetSet.name while True: try: cursor = self.connection.cursor() cursor.execute( DatabaseStatements.getInsertPacketSetStatement( packetSet.projectID, packetSet.name, packetSet.date)) self.connection.commit() # Return the ID of the created object return cursor.lastrowid # Uh oh, PacketSet with same name already present for the project except sqlite3.IntegrityError: # Get the name from the tuple returned by the dialog newPacketSetName = QInputDialog.getText( Globals.ui.tabWidgetManagerTabs, Strings. managerTabDBIntegrityNewPacketSetNameMessageBoxTitle, Strings.managerTabDBIntegrityNewPacketSetNameMessageBoxText + currentName, )[0] if len(newPacketSetName) == 0: self.logger.error(Strings.managerTabInvalidPacketSetName) return else: # Try it again packetSet.name = newPacketSetName continue break
def write_cdsl_file(self): component_dir = str(self._dir_line_edit.text()) text = self._cdsl_doc.generate_doc() if not self._name_line_edit.text(): component_name, ok = QInputDialog.getText(self, 'No component name set', 'Enter component name:') if ok: self.update_component_name(component_name) self._name_line_edit.setText(component_name) else: return False if not os.path.exists(component_dir): if QMessageBox.Yes == QMessageBox.question( self, "Directory doesn't exist.", "Do you want create the directory %s?" % component_dir, QMessageBox.Yes | QMessageBox.No): os.makedirs(component_dir) else: QMessageBox.question( self, "Directory not exist", "Can't create a component witout a valid directory") return False file_path = os.path.join(component_dir, str(self._name_line_edit.text()) + ".cdsl") if os.path.exists(file_path): if QMessageBox.No == QMessageBox.question( self, "File already exists", "Do you want to overwrite?", QMessageBox.Yes | QMessageBox.No): return False with open(file_path, 'w') as the_file: the_file.write(text) self.execute_robocomp_cdsl() return True
def backup_clicked(): filename, ok = QInputDialog.getText(main_window, 'Input Dialog', 'Enter save name:') if ok: create_backup(filename)
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()
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