def adjectives (self): adjList = ["passed on", "is no more", "ceased to be", "expired", "gone to meet his maker", "a stiff", "bereft of life", "rests in peace", "metabolic processes are now history", "off the twig", "kicked the bucket", "shuffled off his mortal coil", "run down his curtain", "joined the bleedin' choir invisible", "THIS IS AN EX-PARROT"] qadjList = QStringList () for adj in adjList: qadjList.append (adj) return qadjList
def __preguntar_conversion(self, variable, objetivo): """Pregunta cual de los metodos disponibles para la conversion desea escoger el usuario""" lista = [] if variable.diccionarioconversion.has_key("Agrupador"): #Conversión a todos los tipos lista += variable.diccionarioconversion["Agrupador"] for tipo in variable.diccionarioconversion.iterkeys(): if tipo == objetivo: lista += variable.diccionarioconversion[tipo] #Elaborar una lista y preguntar al usuario qlista = QStringList() for elemento in lista: qlista.append(elemento) cadena = QInputDialog.getItem("Elige!", u"Elige una función de conversion", qlista, 0, False, self, "Dialogo") #devolver el nombre de la funcion if cadena[1]: return cadena[0].latin1() else: return ""
def activate_test_tab(self): slosl_model = self.slosl_model() statement_names = sorted(s.name for s in slosl_model.statements) combobox = self.test_view_select_combobox old_selection = qstrpy( combobox.currentText() ) combobox.clear() strlist = QStringList() for name in statement_names: strlist.append(name) combobox.insertStringList(strlist) try: current = statement_names.index(old_selection) except ValueError: if statement_names: current = 0 else: current = -1 combobox.setCurrentItem(current)
def __combotableitem(self): """Devuelve un nuevo objeto tipo combotableitem con la lista de tipos""" lista = QStringList() from Driza.listas import SL for tipo in SL.nombrevariables: lista.append(tipo) return QComboTableItem(self.table2, lista)
def py2qstringlist(l): """ convert a list of strings to a QStringList """ r = QStringList() for i in l: r.append(i) return r
def _getTypeCombobox(self, additionalTypes=None): """ Initializes and returns a combination box displaying available property types. """ stringList = QStringList() if not additionalTypes is None: for typeName in additionalTypes: if not typeName in self._propertyTypeNames: stringList.append(typeName) for typeName in self._propertyTypeNames: stringList.append(typeName) typeComboBox = QComboTableItem(self.propertyTable, stringList) typeComboBox.setEditable(True) return typeComboBox
def __resetCombobox(self, combobox, lines): old_selection = qstrpy( combobox.currentText() ) combobox.clear() strlist = QStringList() for line in lines: strlist.append(line) combobox.insertStringList(strlist) try: current = lines.index(old_selection) except ValueError: if lines: current = 0 else: current = -1 combobox.setCurrentItem(current)
def startCommand(self): self.process.setArguments(QStringList.split(" ", self.lineEdit.text())) self.process.closeStdin() self.startButton.setEnabled(False) self.stopButton.setEnabled(True) self.textBrowser.clear() if not self.process.start(): self.textBrowser.setText( QString("*** Failed to run %1 ***").arg(self.lineEdit.text()) ) self.resetButtons() return
def checkObsoletes(self): obsoletes = pisiiface.getObsoletedList() message = i18n( "<qt>Following packages are obsoleted and are not maintained anymore in Pardus 2009 repositories. These packages are going to be removed from your system." ) message += i18n("<br><br>Do you want to continue?</qt>") if KMessageBox.Yes == KMessageBox.warningYesNoList( self.parent, message, QStringList.fromStrList(obsoletes), i18n("Warning"), KGuiItem(i18n("Continue"), "ok"), KGuiItem(i18n("Cancel"), "no"), ): return True
def fillComboBox(self, fieldDef, fieldValue, record): """ Fills the combobox with a picklist. If there has been a combobox for the relevant field, a cached set of items is taken. Every combobox stores a fairly large number pointers to stings in a QStringList object, but there's nothing to be done about that. @param fieldDef: dbFieldDef object that contains the meta-information about this field. @param fieldValue: the current value of the field. Used to set the current item in the picklist. @param record: the current dbRecord object. Used to retrieve the picklist. """ if self.__listCache.has_key(fieldDef): self.items = self.__listCache[fieldDef] else: self.items = QStringList() if fieldDef.nullable: self.__insertItem("<None>", None) fieldName = fieldDef.name descriptor = record.getForeignDescriptorColumnName(fieldName) fk = record.getForeignKeyColumnName(fieldName) for row in record.picklist(fieldName): self.__insertItem(row.getFieldValue(descriptor), row.getFieldValue(fk)) self.__listCache[fieldDef] = self.items self.setStringList(self.items) self.setCurrentItem(fieldValue)
def _make_qlist(self, alist): qlist = QStringList() for item in alist: qlist.append(item) return qlist
class GuiComboTableItem(QComboTableItem): """ A light-weight combobox for use in QTable objects that keeps a mapping between the string shown in the box and the actual data (for instance, database keys) that are used to identify the options. """ __listCache = {} def __init__(self, parent): QComboTableItem.__init__(self, parent, QStringList(), False) self.index_to_key = {} self.key_to_index = {} def fillComboBox(self, fieldDef, fieldValue, record): """ Fills the combobox with a picklist. If there has been a combobox for the relevant field, a cached set of items is taken. Every combobox stores a fairly large number pointers to stings in a QStringList object, but there's nothing to be done about that. @param fieldDef: dbFieldDef object that contains the meta-information about this field. @param fieldValue: the current value of the field. Used to set the current item in the picklist. @param record: the current dbRecord object. Used to retrieve the picklist. """ if self.__listCache.has_key(fieldDef): self.items = self.__listCache[fieldDef] else: self.items = QStringList() if fieldDef.nullable: self.__insertItem("<None>", None) fieldName = fieldDef.name descriptor = record.getForeignDescriptorColumnName(fieldName) fk = record.getForeignKeyColumnName(fieldName) for row in record.picklist(fieldName): self.__insertItem(row.getFieldValue(descriptor), row.getFieldValue(fk)) self.__listCache[fieldDef] = self.items self.setStringList(self.items) self.setCurrentItem(fieldValue) def currentKey(self): try: return self.index_to_key[self.currentItem()] except KeyError: return None def __insertItem(self, text, index): self.items.append(text) self.index_to_key [self.count() - 1] = index self.key_to_index [index] = self.count() - 1
class EnvError(Exception): def __init__(self, value): self.value = value def __str__(self): return repr(self.value) tweek_base_dir = getenv("TWEEK_BASE_DIR") if not tweek_base_dir: raise EnvError, "TWEEK_BASE_DIR environment variable not set" # Construct the path to the images that will be loaded by the GUI. image_dir = path.join(tweek_base_dir, "share", "tweek", "python", "images") # Set up PyQt. app = QApplication(sys.argv) # XXX: Is there a cleaner way to define a QStringList from Python? QMimeSourceFactory.defaultFactory().setFilePath(QStringList(image_dir)) # Load the user's preferences file. If it does not exist, it will be created. prefs = prefs.GlobalPreferences("/home/patrick/.tweekrc") prefs.parse() frame = tweekframe.TweekFrame() # XXX: This is a hack because I am lame. frame.globalPrefs = prefs frame.subjMgrList = [] frame.show() app.exec_loop()