def createEditor( self, parent, options, index, ): setting = index.model().data(index, Qt.UserRole) if setting.valuetype == Setting.FOLDER: return FileDirectorySelector(parent) elif setting.valuetype == Setting.FILE: return FileDirectorySelector(parent, True) elif setting.valuetype == Setting.SELECTION: combo = QComboBox(parent) combo.addItems(setting.options) return combo else: value = self.convertValue(index.model().data(index, Qt.EditRole)) if isinstance(value, (int, long)): spnBox = QSpinBox(parent) spnBox.setRange(-999999999, 999999999) return spnBox elif isinstance(value, float): spnBox = QDoubleSpinBox(parent) spnBox.setRange(-999999999.999999, 999999999.999999) spnBox.setDecimals(6) return spnBox elif isinstance(value, (str, unicode)): return QLineEdit(parent)
class FontLayout(QHBoxLayout): """Font selection""" def __init__(self, value, parent=None): QHBoxLayout.__init__(self) font = tuple_to_qfont(value) assert font is not None # Font family self.family = QFontComboBox(parent) self.family.setCurrentFont(font) self.addWidget(self.family) # Font size self.size = QComboBox(parent) self.size.setEditable(True) sizelist = list(itertools.chain(range(6, 12), range(12, 30, 2), [36, 48, 72])) size = font.pointSize() if size not in sizelist: sizelist.append(size) sizelist.sort() self.size.addItems([str(s) for s in sizelist]) self.size.setCurrentIndex(sizelist.index(size)) self.addWidget(self.size) def get_font(self): font = self.family.currentFont() font.setPointSize(int(self.size.currentText())) return qfont_to_tuple(font)
def createEditor( self, parent, options, index, ): setting = index.model().data(index, Qt.UserRole) if setting.valuetype == Setting.FOLDER: return FileDirectorySelector(parent) elif setting.valuetype == Setting.FILE: return FileDirectorySelector(parent, True) elif setting.valuetype == Setting.SELECTION: combo = QComboBox(parent) combo.addItems(setting.options) return combo else: value = self.convertValue(index.model().data(index, Qt.EditRole)) if isinstance(value, (int, long)): spnBox = QgsSpinBox(parent) spnBox.setRange(-999999999, 999999999) return spnBox elif isinstance(value, float): spnBox = QgsDoubleSpinBox(parent) spnBox.setRange(-999999999.999999, 999999999.999999) spnBox.setDecimals(6) return spnBox elif isinstance(value, (str, unicode)): return QLineEdit(parent)
def Translate(self, lang): translator = QTranslator(qApp) translator.load(":Translations/dc_" + lang + ".qm") qApp.installTranslator(translator) self.basename = self.tr("Data Centers GUI") self.demandGraphEditor.basename = self.demandGraphEditor.tr("Request Graph Editor") self.resourcesGraphEditor.basename = self.resourcesGraphEditor.tr("Resources Graph Editor") self.ui.retranslateUi(self) self.settingsDialog.ui.retranslateUi(self.settingsDialog) self.demandGraphEditor.ui.retranslateUi(self.demandGraphEditor) self.resourcesGraphEditor.ui.retranslateUi(self.resourcesGraphEditor) self.randomDialog.ui.retranslateUi(self.randomDialog) self.Vis.ui.retranslateUi(self.Vis) self.graphvis.ui.retranslateUi(self.graphvis) self.showStats() for k in self.demands.keys(): cb = QComboBox() cb.addItems([self.tr("No"),self.tr("Yes")]) cb.setCurrentIndex(0 if self.demands[k].critical else 1) QObject.connect(cb, SIGNAL("currentIndexChanged(int)"), k.emitDataChanged) self.ui.demands.setItemWidget(k,3,cb) if self.demands[k].assigned: k.setText(4, self.tr("Yes")) else: k.setText(4, self.tr("No"))
class EnumConfigControl(ConfigControl): def __init__(self, config_item): ConfigControl.__init__(self, config_item) self._init_ui() def _init_ui(self): lbl_enum = QLabel(self._config_item.tag()) lbl_enum.setFixedWidth(self.LABEL_WIDTH) self._cmbo_enum = QComboBox() self._cmbo_enum.addItems(self._config_item.enum_names) selected = self._config_item.value() index = self._cmbo_enum.findText(selected, QtCore.Qt.MatchFixedString) self._cmbo_enum.setCurrentIndex(index) hbox = QHBoxLayout() hbox.setContentsMargins(0, 0, 0, 0) hbox.addWidget(lbl_enum) hbox.addWidget(self._cmbo_enum) hbox.addStretch() self.setLayout(hbox) def update_from_config(self): selected = self._config_item.value() index = self._cmbo_enum.findText(selected, QtCore.Qt.MatchFixedString) index = max(0, index) self._cmbo_enum.setCurrentIndex(index) def save_to_config(self): value = self._cmbo_enum.currentText() self._config_item.set(value)
class PltTypeDlg(QDialog): def __init__(self, parent=None): super(PltTypeDlg, self).__init__(parent) pltLabel = QLabel("&Select plot type:") self.pltComboBox = QComboBox() pltLabel.setBuddy(self.pltComboBox) self.pltComboBox.addItems(["", "Dark", "Illuminated"]) pltbuttonBox = QDialogButtonBox(QDialogButtonBox.Ok|QDialogButtonBox.Cancel) pltbuttonBox.button(QDialogButtonBox.Ok).setDefault(True) layout = QGridLayout() layout.addWidget(pltLabel, 0, 0) layout.addWidget(self.pltComboBox, 0, 1) layout.addWidget(pltbuttonBox, 1, 0, 1, 2) self.connect(pltbuttonBox, SIGNAL("accepted()"), self, SLOT("accept()")) self.connect(pltbuttonBox, SIGNAL("rejected()"), self, SLOT("reject()")) self.setWindowTitle("I-V proc - Plot type") def accept(self): plttype = unicode(self.pltComboBoxcurrentText()) try: if plttype is None: raise TypeError, ("You must select between Dark or Illuminated plot") except TypeError, e: QMessageBox.warning(self, "Selection Error", unicode(e)) return selt.plottype = plttype
def OpenProjectFromFile(self, name): self.demands = {} self.project = Project() #try: self.project.Load(name) #except : # TODO: proper exceptioning # QMessageBox.critical(self, self.tr("An error occured"), self.tr("File is not a valid project file: ") + name) # return self.projectFile = name self.resourcesGraphEditor.setData(self.project.resources) self.ui.demands.clear() for d in self.project.demands: it = QTreeWidgetItem(self.ui.demands, QStringList([d.id, str(d.startTime), str(d.endTime), self.tr("No") if d.critical else self.tr("Yes"), self.tr("Yes") if d.assigned else self.tr("No")])) cb = QComboBox() cb.addItems([self.tr("No"),self.tr("Yes")]) cb.setCurrentIndex(0 if d.critical else 1) QObject.connect(cb, SIGNAL("currentIndexChanged(int)"), it.emitDataChanged) self.ui.demands.setItemWidget(it,3,cb) it.setFlags(Qt.ItemIsEditable | Qt.ItemIsEnabled | Qt.ItemIsSelectable) self.demands[it] = d self.UpdateRecentFiles() self.setWindowTitle(self.project.name + " - " + self.basename) self.ui.projectname.setText(self.project.name) self.showStats() self.backupTimer.start() self.autosaveTimer.start()
def __init__(self, game): SelectRuleset.__init__(self) self.game = game Players.load() self.setWindowTitle(m18n('Select four players') + ' - Kajongg') self.names = None self.nameWidgets = [] for idx, wind in enumerate(WINDS): cbName = QComboBox() cbName.manualSelect = False # increase width, we want to see the full window title cbName.setMinimumWidth(350) # is this good for all platforms? cbName.addItems(Players.humanNames.values()) self.grid.addWidget(cbName, idx+1, 1) self.nameWidgets.append(cbName) self.grid.addWidget(WindLabel(wind), idx+1, 0) cbName.currentIndexChanged.connect(self.slotValidate) query = Query("select p0,p1,p2,p3 from game where seed is null and game.id = (select max(id) from game)") if len(query.records): for pidx, playerId in enumerate(query.records[0]): try: playerName = Players.humanNames[playerId] cbName = self.nameWidgets[pidx] playerIdx = cbName.findText(playerName) if playerIdx >= 0: cbName.setCurrentIndex(playerIdx) except KeyError: logError('database is inconsistent: player with id %d is in game but not in player' \ % playerId) self.slotValidate()
class Dial(QDialog): choices =['flat', 'hanning', 'hamming', 'bartlett', 'blackman'] def __init__(self, parent): QDialog.__init__(self, parent) f =QFormLayout(self) self.a =QSpinBox(self) self.a.setValue(30) self.b = QComboBox(self) self.b.addItems(self.choices) self.c= QDialogButtonBox(self) self.c.setStandardButtons(QDialogButtonBox.Cancel|QDialogButtonBox.Ok) f.addRow("window:" ,self.a) f.addRow("method:", self.b) f.addRow("", self.c) self.connect(self.c, SIGNAL("accepted()"), self.sendData) self.connect(self.c, SIGNAL("rejected()"), self.reinitialize) def sendData(self): self.parent().window = self.a.value() self.parent().method = self.b.currentText() self.close() def reinitialize(self): self.parent().window = None self.parent().method = None self.close()
def _add_task_to_table(self, row, task): self._ignore_cell_changed = True self.setItem(row, self._dict_header['id'], QTableWidgetItem(str(task.identifier))) self.item(row, self._dict_header['id']) \ .setTextAlignment(Qt.AlignCenter) self.setItem(row, self._dict_header['name'], QTableWidgetItem(str(task.name))) combo = QComboBox() items = [task_type for task_type in Task.task_types_names] combo.addItems(items) # FIXME: only until I get an access to the documentation. for i, t in enumerate(Task.task_types_names): if t == task.task_type: combo.setCurrentIndex(i) combo.currentIndexChanged.connect( lambda x: self._cell_changed(row, self._dict_header['task_type'])) self.setCellWidget(row, self._dict_header['task_type'], combo) item = QTableWidgetItem(task.abort_on_miss and 'Yes' or 'No') item.setFlags( Qt.ItemIsUserCheckable | Qt.ItemIsEnabled | Qt.ItemIsSelectable) item.setCheckState(task.abort_on_miss and Qt.Checked or Qt.Unchecked) self.setItem(row, self._dict_header['abort'], item) self.setItem(row, self._dict_header['list_activation_dates'], QTableWidgetItem( ', '.join(map(str, task.list_activation_dates)))) self.item(row, self._dict_header['list_activation_dates']) \ .setTextAlignment(Qt.AlignRight | Qt.AlignVCenter) for i in ['activation_date', 'period', 'deadline', 'wcet', 'base_cpi', 'n_instr', 'mix', 'acet', 'et_stddev', 'preemption_cost']: self.setItem(row, self._dict_header[i], QTableWidgetItem(str(task.__dict__[i]))) self.item(row, self._dict_header[i]) \ .setTextAlignment(Qt.AlignRight | Qt.AlignVCenter) stack_item = QTableWidgetItem(str(task.stack_file)) stack_item.setFlags(stack_item.flags() ^ (Qt.ItemIsEditable)) self.setItem(row, self._dict_header['sdp'], stack_item) combo = QComboBox() combo.currentIndexChanged.connect( lambda x: self._cell_changed(row, self._dict_header['followed'])) self.setCellWidget(row, self._dict_header['followed'], combo) for col in range(len(self._custom_fields)): key = self._custom_fields[col] if key in task.data and task.data[key] is not None: item = QTableWidgetItem(str(task.data[key])) else: item = QTableWidgetItem('') item.setBackgroundColor(QColor.fromRgb(200, 255, 200)) self.setItem(row, col + len(self._header), item) self._ignore_cell_changed = False self._show_period(task, row)
def createEditor(self, parent, option, index): if index.column() == TEU: spinbox = QSpinBox(parent) spinbox.setRange(0, 200000) spinbox.setSingleStep(1000) spinbox.setAlignment(Qt.AlignRight|Qt.AlignVCenter) return spinbox elif index.column() == OWNER: combobox = QComboBox(parent) combobox.addItems(sorted(index.model().owners)) combobox.setEditable(True) return combobox elif index.column() == COUNTRY: combobox = QComboBox(parent) combobox.addItems(sorted(index.model().countries)) combobox.setEditable(True) return combobox elif index.column() == NAME: editor = QLineEdit(parent) self.connect(editor, SIGNAL("returnPressed()"), self.commitAndCloseEditor) return editor elif index.column() == DESCRIPTION: editor = richtextlineedit.RichTextLineEdit(parent) self.connect(editor, SIGNAL("returnPressed()"), self.commitAndCloseEditor) return editor else: return QStyledItemDelegate.createEditor(self, parent, option, index)
def lineEditor(self, name, item, props, parent): """ Creates a new editor suitable for selecting a series or index. @param name item parameter name, as string, to receive value updates @param item IndexItem instance @param props mapping of index class constructor properties @param parent ancestor of new widget @return QComboBox widget """ children = list(item.root().children(True)) editor = QComboBox(parent) editor.addItem('') exclude = [item.text(), self.defaultText] items = [c.text() for c in children if c.text() not in exclude] editor.addItems(items) try: editor.setCurrentIndex(editor.findText(item.parameters[name])) except (KeyError, ): item.parameters[name] = '' @pyqtSignature('int') def onChange(index): item.parameters[name] = str(editor.currentText()) self.emit(Signals.modified) editor.onChange = onChange editor.connect(editor, Signals.currentIndexChanged, onChange) return editor
def __init__(self, game): SelectRuleset.__init__(self) self.game = game Players.load() self.setWindowTitle(m18n('Select four players') + ' - Kajongg') self.names = None self.nameWidgets = [] for idx, wind in enumerate(WINDS): cbName = QComboBox() cbName.manualSelect = False # increase width, we want to see the full window title cbName.setMinimumWidth(350) # is this good for all platforms? cbName.addItems(Players.humanNames.values()) self.grid.addWidget(cbName, idx + 1, 1) self.nameWidgets.append(cbName) self.grid.addWidget(WindLabel(wind), idx + 1, 0) cbName.currentIndexChanged.connect(self.slotValidate) query = Query( "select p0,p1,p2,p3 from game where seed is null and game.id = (select max(id) from game)" ) if len(query.records): for pidx, playerId in enumerate(query.records[0]): try: playerName = Players.humanNames[playerId] cbName = self.nameWidgets[pidx] playerIdx = cbName.findText(playerName) if playerIdx >= 0: cbName.setCurrentIndex(playerIdx) except KeyError: logError('database is inconsistent: player with id %d is in game but not in player' \ % playerId) self.slotValidate()
def createEditor(self, parent, option, index): """ Create the editor @param parent: @type parent: @param option: @type option: @param index: @type index: @return: @rtype: """ # get running probe from context self.items_ = ServerProbes.instance().getRunningProbes() self.items_ = sorted(self.items_) # sort agents list, new in v12.2 # load probs in combobox value = self.getValue(index) if index.column() == self.col_: editor = QComboBox(parent) editor.activated.connect(self.onItemActivated) editor.addItem(value) editor.insertSeparator(1) editor.addItems(self.items_) return editor return QItemDelegate.createEditor(self, parent, option, index)
def createCellWidget(self, qmlDict, attr, count): """ Creates specific widgets for each attribute, which can be a QCombobox, a QLineEdit or a QListWidget. """ if attr in qmlDict.keys(): #case the type is dict the cell widget must be a combobox if isinstance(qmlDict[attr], dict): comboItem = QComboBox() comboItem.addItems(sorted(qmlDict[attr].keys())) self.attributeTableWidget.setCellWidget(count, 1, comboItem) #case the type is tuple the cell widget must be a listwidget if isinstance(qmlDict[attr], tuple): (table, filterKeys) = qmlDict[attr] #getting the value relation dictionary used to make the listwidget valueRelation = self.makeValueRelationDict(table, filterKeys) list = QListWidget() for key in valueRelation.keys(): listItem = QListWidgetItem(key) listItem.setCheckState(Qt.Unchecked) list.addItem(listItem) self.attributeTableWidget.setCellWidget(count, 1, list) #this is the normal case, a simple lineedit else: textItem = QLineEdit() self.attributeTableWidget.setCellWidget(count, 1, textItem)
def createEditor(self, parent, option, index): if index.column() == TEU: spinbox = QSpinBox(parent) spinbox.setRange(0, 200000) spinbox.setSingleStep(1000) spinbox.setAlignment(Qt.AlignRight | Qt.AlignVCenter) return spinbox elif index.column() == OWNER: combobox = QComboBox(parent) combobox.addItems(sorted(index.model().owners)) combobox.setEditable(True) return combobox elif index.column() == COUNTRY: combobox = QComboBox(parent) combobox.addItems(sorted(index.model().countries)) combobox.setEditable(True) return combobox elif index.column() == NAME: editor = QLineEdit(parent) self.connect(editor, SIGNAL("returnPressed()"), self.commitAndCloseEditor) return editor elif index.column() == DESCRIPTION: editor = richtextlineedit.RichTextLineEdit(parent) self.connect(editor, SIGNAL("returnPressed()"), self.commitAndCloseEditor) return editor else: return QStyledItemDelegate.createEditor(self, parent, option, index)
class CodecSelector(QHBoxLayout): codecChanged = pyqtSignal(EnCoder) checked = pyqtSignal(int) List = [] def __init__(self, cod=[], **kwargs): super(CodecSelector, self).__init__() ctitle = kwargs['CTitle'] self.combo = QComboBox() self.check = QCheckBox(ctitle) self.combo.currentIndexChanged.connect(self.choiceCodec) self.check.stateChanged.connect(self.checked.emit) self.addWidget(self.combo) self.addWidget(self.check) self.setCodec(cod) def choiceCodec(self, a): self.codecChanged.emit(self.List[a]) def addCodec(self, lst): for c in lst: self.List.append(c) self.combo.addItems([c.title]) def setCodec(self, lst): self.List = lst for c in lst: self.combo.addItems([c.title]) def get(self): return self.List[self.combo.currentIndex()]
class PltTypeDlg(QDialog): def __init__(self, parent=None): super(PltTypeDlg, self).__init__(parent) pltLabel = QLabel("&Select plot type:") self.pltComboBox = QComboBox() pltLabel.setBuddy(self.pltComboBox) self.pltComboBox.addItems(["", "Dark", "Illuminated"]) pltbuttonBox = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel) pltbuttonBox.button(QDialogButtonBox.Ok).setDefault(True) layout = QGridLayout() layout.addWidget(pltLabel, 0, 0) layout.addWidget(self.pltComboBox, 0, 1) layout.addWidget(pltbuttonBox, 1, 0, 1, 2) self.connect(pltbuttonBox, SIGNAL("accepted()"), self, SLOT("accept()")) self.connect(pltbuttonBox, SIGNAL("rejected()"), self, SLOT("reject()")) self.setWindowTitle("I-V proc - Plot type") def accept(self): plttype = unicode(self.pltComboBoxcurrentText()) try: if plttype is None: raise TypeError, ( "You must select between Dark or Illuminated plot") except TypeError, e: QMessageBox.warning(self, "Selection Error", unicode(e)) return selt.plottype = plttype
class KeywordConfigurationWidget(ConfigurationWidget): def __init__(self): ConfigurationWidget.__init__(self) self.keyIndexCombo = QComboBox() self.addRow("Key index:", self.keyIndexCombo) self.connect(self.keyIndexCombo, SIGNAL("currentIndexChanged(QString)"), self.applyConfiguration) def setKeyIndexList(self, list): self.disconnect(self.keyIndexCombo, SIGNAL("currentIndexChanged(QString)"), self.applyConfiguration) self.keyIndexCombo.clear() self.keyIndexCombo.addItems(list) self.connect(self.keyIndexCombo, SIGNAL("currentIndexChanged(QString)"), self.applyConfiguration) def setParameter(self, parameter): self.parameter = parameter self.applyConfiguration(False) def applyConfiguration(self, emit=True): user_data = {"state": self.getState(), "key_index": self.getKeyIndex()} self.parameter.setUserData(user_data) self.emitConfigurationChanged(emit) def getKeyIndex(self): return str(self.keyIndexCombo.currentText())
def setTable(self): table = self.dlg.layerPropTable table.clear() UnitSelector = QComboBox() UnitSelector.addItems(['SI', 'EN']) if self.dlg.recTypeCombo.currentIndex() == 0: self.dlg.addColumnBtn.setEnabled(False) self.dlg.removeColumnBtn.setEnabled(False) table.setRowCount(4) table.setColumnCount(self.grads) table.setItem(0, 0, QTableWidgetItem('Thickness')) table.setItem(0, 1, QTableWidgetItem('Unit')) table.setItem(0, 2, QTableWidgetItem('Density of\n Clay\n(optional)')) table.setItem(1, 0, QTableWidgetItem(u'')) table.setCellWidget(1, 1, UnitSelector) table.setItem(1, 2, QTableWidgetItem(u'')) for j in range(0, self.grads): table.setItem(2, j, QTableWidgetItem('V' + str(j + 1))) table.setItem(3, j, QTableWidgetItem(u'')) self.dlg.chartBtn.setEnabled(True) elif self.dlg.recTypeCombo.currentIndex() == 1: self.dlg.addColumnBtn.setEnabled(True) self.dlg.removeColumnBtn.setEnabled(True) table.setRowCount(6) table.setColumnCount(7) table.setItem(0, 0, QTableWidgetItem('Thickness')) table.setItem(0, 1, QTableWidgetItem('Unit')) table.setItem(0, 2, QTableWidgetItem('Density of\n Clay\n(optional)')) table.setItem(1, 0, QTableWidgetItem(u'')) table.setCellWidget(1, 1, UnitSelector) table.setItem(1, 2, QTableWidgetItem(u'')) for j in range(0, table.columnCount()): table.setItem(2, j, QTableWidgetItem('D' + str(j + 1))) table.setItem(3, j, QTableWidgetItem(u'')) table.setItem(4, j, QTableWidgetItem('P' + str(j + 1))) table.setItem(5, j, QTableWidgetItem(u'')) self.dlg.chartBtn.setEnabled(True) elif self.dlg.recTypeCombo.currentIndex() == 2: self.dlg.addColumnBtn.setEnabled(False) self.dlg.removeColumnBtn.setEnabled(False) table.setColumnCount(2) table.setRowCount(2) table.setItem(0, 0, QTableWidgetItem('Thickness')) table.setItem(0, 1, QTableWidgetItem('Unit')) table.setItem(0, 2, QTableWidgetItem('Density of\n Clay\n(optional)')) table.setItem(1, 0, QTableWidgetItem(u'')) table.setCellWidget(1, 1, UnitSelector) table.setItem(1, 2, QTableWidgetItem(u'')) self.dlg.chartBtn.setEnabled(False)
def create_combo_box(choice_l, index=None, choice=None): qcb = QComboBox() qcb.addItems(choice_l) if index: qcb.setCurrentIndex(index) elif choice: qcb.setCurrentIndex(choice_l.index(choice)) return qcb
def generateVirtualityField(): """ @rtype: QComboBox """ field = QComboBox() field.addItems(helper_methods.buildQStringList(['', 'VIRTUAL', 'PERSISTENT'])) return field
def create_editor(self): w = QComboBox() items = self.potential_values() names = [o.name for o in items] w.addItems(names) if self.current_item is not None and self.current_item.name in names: w.setCurrentIndex(names.index(self.current_item.name)) return w
class ProjectData(QWidget): def __init__(self, parent): super(ProjectData, self).__init__() self._parent = parent grid = QGridLayout(self) grid.addWidget(QLabel(translations.TR_PROJECT_NAME), 0, 0) self.name = QLineEdit() if not len(self._parent.project.name): self.name.setText(file_manager.get_basename( self._parent.project.path)) else: self.name.setText(self._parent.project.name) grid.addWidget(self.name, 0, 1) grid.addWidget(QLabel(translations.TR_PROJECT_LOCATION), 1, 0) self.txtPath = QLineEdit() self.txtPath.setReadOnly(True) self.txtPath.setText(self._parent.project.path) grid.addWidget(self.txtPath, 1, 1) grid.addWidget(QLabel(translations.TR_PROJECT_TYPE), 2, 0) self.txtType = QLineEdit() completer = QCompleter(sorted(settings.PROJECT_TYPES)) completer.setCompletionMode(QCompleter.UnfilteredPopupCompletion) self.txtType.setCompleter(completer) self.txtType.setText(self._parent.project.project_type) grid.addWidget(self.txtType, 2, 1) grid.addWidget(QLabel(translations.TR_PROJECT_DESCRIPTION), 3, 0) self.description = QPlainTextEdit() self.description.setPlainText(self._parent.project.description) grid.addWidget(self.description, 3, 1) grid.addWidget(QLabel(translations.TR_PROJECT_URL), 4, 0) self.url = QLineEdit() self.url.setText(self._parent.project.url) self.url.setPlaceholderText('https://www.{}.com'.format(getuser())) grid.addWidget(self.url, 4, 1) grid.addWidget(QLabel(translations.TR_PROJECT_LICENSE), 5, 0) self.cboLicense = QComboBox() self.cboLicense.addItems(LICENCES) self.cboLicense.setCurrentIndex(12) index = self.cboLicense.findText(self._parent.project.license) self.cboLicense.setCurrentIndex(index) grid.addWidget(self.cboLicense, 5, 1) self.txtExtensions = QLineEdit() self.txtExtensions.setText(', '.join(self._parent.project.extensions)) grid.addWidget(QLabel(translations.TR_PROJECT_EXTENSIONS), 6, 0) grid.addWidget(self.txtExtensions, 6, 1) grid.addWidget(QLabel(translations.TR_PROJECT_INDENTATION), 7, 0) self.spinIndentation = QSpinBox() self.spinIndentation.setValue(self._parent.project.indentation) self.spinIndentation.setRange(2, 10) self.spinIndentation.setValue(4) self.spinIndentation.setSingleStep(2) grid.addWidget(self.spinIndentation, 7, 1) self.checkUseTabs = QCheckBox(translations.TR_PROJECT_USE_TABS) self.checkUseTabs.setChecked(self._parent.project.use_tabs) grid.addWidget(self.checkUseTabs, 7, 2)
def _add_task_to_table(self, row, task): self._ignore_cell_changed = True self.setItem(row, self._dict_header['id'], QTableWidgetItem(str(task.identifier))) self.item(row, self._dict_header['id']) \ .setTextAlignment(Qt.AlignCenter) self.setItem(row, self._dict_header['name'], QTableWidgetItem(str(task.name))) combo = QComboBox() items = [task_type for task_type in Task.task_types_names] combo.addItems(items) combo.setCurrentIndex(combo.findText(task.task_type)) combo.currentIndexChanged.connect( lambda x: self._cell_changed(row, self._dict_header['task_type'])) self.setCellWidget(row, self._dict_header['task_type'], combo) item = QTableWidgetItem(task.abort_on_miss and 'Yes' or 'No') item.setFlags(Qt.ItemIsUserCheckable | Qt.ItemIsEnabled | Qt.ItemIsSelectable) item.setCheckState(task.abort_on_miss and Qt.Checked or Qt.Unchecked) self.setItem(row, self._dict_header['abort'], item) self.setItem( row, self._dict_header['list_activation_dates'], QTableWidgetItem(', '.join(map(str, task.list_activation_dates)))) self.item(row, self._dict_header['list_activation_dates']) \ .setTextAlignment(Qt.AlignRight | Qt.AlignVCenter) for i in [ 'activation_date', 'period', 'deadline', 'wcet', 'base_cpi', 'n_instr', 'mix', 'acet', 'et_stddev', 'preemption_cost' ]: self.setItem(row, self._dict_header[i], QTableWidgetItem(str(task.__dict__[i]))) self.item(row, self._dict_header[i]) \ .setTextAlignment(Qt.AlignRight | Qt.AlignVCenter) stack_item = QTableWidgetItem(str(task.stack_file)) stack_item.setFlags(stack_item.flags() ^ (Qt.ItemIsEditable)) self.setItem(row, self._dict_header['sdp'], stack_item) combo = QComboBox() combo.currentIndexChanged.connect( lambda x: self._cell_changed(row, self._dict_header['followed'])) self.setCellWidget(row, self._dict_header['followed'], combo) for col in range(len(self._custom_fields)): key = self._custom_fields[col] if key in task.data and task.data[key] is not None: item = QTableWidgetItem(str(task.data[key])) else: item = QTableWidgetItem('') item.setBackgroundColor(QColor.fromRgb(200, 255, 200)) self.setItem(row, col + len(self._header), item) self._ignore_cell_changed = False self._show_period(task, row)
class StartSession(preferences.Group): def __init__(self, page): super(StartSession, self).__init__(page) grid = QGridLayout() self.setLayout(grid) def changed(): self.changed.emit() self.combo.setEnabled(self.custom.isChecked()) self.none = QRadioButton(toggled=changed) self.lastused = QRadioButton(toggled=changed) self.custom = QRadioButton(toggled=changed) self.combo = QComboBox(currentIndexChanged=changed) grid.addWidget(self.none, 0, 0, 1, 2) grid.addWidget(self.lastused, 1, 0, 1, 2) grid.addWidget(self.custom, 2, 0, 1, 1) grid.addWidget(self.combo, 2, 1, 1, 1) app.translateUI(self) def translateUI(self): self.setTitle( _("Session to load if Frescobaldi is started without arguments")) self.none.setText(_("Start with no session")) self.lastused.setText(_("Start with last used session")) self.custom.setText(_("Start with session:")) def loadSettings(self): s = QSettings() s.beginGroup("session") startup = s.value("startup", "none", type("")) if startup == "lastused": self.lastused.setChecked(True) elif startup == "custom": self.custom.setChecked(True) else: self.none.setChecked(True) sessionNames = sessions.sessionNames() self.combo.clear() self.combo.addItems(sessionNames) custom = s.value("custom", "", type("")) if custom in sessionNames: self.combo.setCurrentIndex(sessionNames.index(custom)) def saveSettings(self): s = QSettings() s.beginGroup("session") s.setValue("custom", self.combo.currentText()) if self.custom.isChecked(): startup = "custom" elif self.lastused.isChecked(): startup = "lastused" else: startup = "none" s.setValue("startup", startup)
def generateVirtualityField(): """ @rtype: QComboBox """ field = QComboBox() field.addItems( helper_methods.buildQStringList(['', 'VIRTUAL', 'PERSISTENT'])) return field
class StartSession(preferences.Group): def __init__(self, page): super(StartSession, self).__init__(page) grid = QGridLayout() self.setLayout(grid) def changed(): self.changed.emit() self.combo.setEnabled(self.custom.isChecked()) self.none = QRadioButton(toggled=changed) self.lastused = QRadioButton(toggled=changed) self.custom = QRadioButton(toggled=changed) self.combo = QComboBox(currentIndexChanged=changed) grid.addWidget(self.none, 0, 0, 1, 2) grid.addWidget(self.lastused, 1, 0, 1, 2) grid.addWidget(self.custom, 2, 0, 1, 1) grid.addWidget(self.combo, 2, 1, 1, 1) app.translateUI(self) def translateUI(self): self.setTitle(_("Session to load if Frescobaldi is started without arguments")) self.none.setText(_("Start with no session")) self.lastused.setText(_("Start with last used session")) self.custom.setText(_("Start with session:")) def loadSettings(self): s = QSettings() s.beginGroup("session") startup = s.value("startup", "none", type("")) if startup == "lastused": self.lastused.setChecked(True) elif startup == "custom": self.custom.setChecked(True) else: self.none.setChecked(True) sessionNames = sessions.sessionNames() self.combo.clear() self.combo.addItems(sessionNames) custom = s.value("custom", "", type("")) if custom in sessionNames: self.combo.setCurrentIndex(sessionNames.index(custom)) def saveSettings(self): s = QSettings() s.beginGroup("session") s.setValue("custom", self.combo.currentText()) if self.custom.isChecked(): startup = "custom" elif self.lastused.isChecked(): startup = "lastused" else: startup = "none" s.setValue("startup", startup)
def createEditor(self, parent, option, index): if index.isValid() and index.column() == 0: finishmentWidget = QComboBox(parent) finishmentWidget.addItems( [self.trUtf8("已完成"), self.trUtf8("进行中"), self.trUtf8("未完成")]) return finishmentWidget return QStyledItemDelegate.createEditor(self, parent, option, index)
def __eventAddTechnique(self): techniquesCombo = QComboBox() techniquesCombo.setGeometry(QRect(10, 50, 171, 22)) techniquesCombo.addItems(self.techniquesClass.keys()) self.techniques.append(techniquesCombo) self.rowsTechiques[self.techniquesNumber].addWidget(techniquesCombo) self.techniquesNumber = self.techniquesNumber + 1 if ((len(self.rowsTechiques) - 1) == self.techniquesNumber): self.addTechnique.setEnabled(False)
class ProjectData(QWidget): def __init__(self, parent): super(ProjectData, self).__init__() self._parent = parent grid = QGridLayout(self) grid.addWidget(QLabel(translations.TR_PROJECT_NAME), 0, 0) self.name = QLineEdit() if not len(self._parent.project.name): self.name.setText( file_manager.get_basename(self._parent.project.path)) else: self.name.setText(self._parent.project.name) grid.addWidget(self.name, 0, 1) grid.addWidget(QLabel(translations.TR_PROJECT_LOCATION), 1, 0) self.txtPath = QLineEdit() self.txtPath.setReadOnly(True) self.txtPath.setText(self._parent.project.path) grid.addWidget(self.txtPath, 1, 1) grid.addWidget(QLabel(translations.TR_PROJECT_TYPE), 2, 0) self.txtType = QLineEdit() completer = QCompleter(sorted(settings.PROJECT_TYPES)) completer.setCompletionMode(QCompleter.UnfilteredPopupCompletion) self.txtType.setCompleter(completer) self.txtType.setText(self._parent.project.project_type) grid.addWidget(self.txtType, 2, 1) grid.addWidget(QLabel(translations.TR_PROJECT_DESCRIPTION), 3, 0) self.description = QPlainTextEdit() self.description.setPlainText(self._parent.project.description) grid.addWidget(self.description, 3, 1) grid.addWidget(QLabel(translations.TR_PROJECT_URL), 4, 0) self.url = QLineEdit() self.url.setText(self._parent.project.url) self.url.setPlaceholderText('https://www.{}.com'.format(getuser())) grid.addWidget(self.url, 4, 1) grid.addWidget(QLabel(translations.TR_PROJECT_LICENSE), 5, 0) self.cboLicense = QComboBox() self.cboLicense.addItems(LICENCES) self.cboLicense.setCurrentIndex(12) index = self.cboLicense.findText(self._parent.project.license) self.cboLicense.setCurrentIndex(index) grid.addWidget(self.cboLicense, 5, 1) self.txtExtensions = QLineEdit() self.txtExtensions.setText(', '.join(self._parent.project.extensions)) grid.addWidget(QLabel(translations.TR_PROJECT_EXTENSIONS), 6, 0) grid.addWidget(self.txtExtensions, 6, 1) grid.addWidget(QLabel(translations.TR_PROJECT_INDENTATION), 7, 0) self.spinIndentation = QSpinBox() self.spinIndentation.setValue(self._parent.project.indentation) self.spinIndentation.setRange(2, 10) self.spinIndentation.setValue(4) self.spinIndentation.setSingleStep(2) grid.addWidget(self.spinIndentation, 7, 1) self.checkUseTabs = QCheckBox(translations.TR_PROJECT_USE_TABS) self.checkUseTabs.setChecked(self._parent.project.use_tabs) grid.addWidget(self.checkUseTabs, 7, 2)
class LilyPondPreferences(QGroupBox): def __init__(self, parent): super(LilyPondPreferences, self).__init__(parent) grid = QGridLayout() self.setLayout(grid) self.pitchLanguageLabel = QLabel() self.pitchLanguage = QComboBox() self.versionLabel = QLabel() self.version = QComboBox(editable=True) self.pitchLanguage.addItem('') self.pitchLanguage.addItems( [lang.title() for lang in sorted(scoreproperties.keyNames)]) self.version.addItem(lilypondinfo.preferred().versionString()) for v in ("2.18.0", "2.16.0", "2.14.0", "2.12.0"): if v != lilypondinfo.preferred().versionString(): self.version.addItem(v) grid.addWidget(self.pitchLanguageLabel, 0, 0) grid.addWidget(self.pitchLanguage, 0, 1) grid.addWidget(self.versionLabel, 1, 0) grid.addWidget(self.version, 1, 1) self.pitchLanguage.activated.connect(self.slotPitchLanguageChanged) app.translateUI(self) self.loadSettings() self.window().finished.connect(self.saveSettings) def translateUI(self): self.setTitle(_("LilyPond")) self.pitchLanguageLabel.setText(_("Pitch name language:")) self.pitchLanguage.setToolTip( _("The LilyPond language you want to use for the pitch names.")) self.pitchLanguage.setItemText(0, _("Default")) self.versionLabel.setText(_("Version:")) self.version.setToolTip( _("The LilyPond version you will be using for this document.")) def slotPitchLanguageChanged(self, index): if index == 0: language = '' else: language = self.pitchLanguage.currentText().lower() self.window().setPitchLanguage(language) def loadSettings(self): language = self.window().pitchLanguage() languages = list(sorted(scoreproperties.keyNames)) index = languages.index(language) + 1 if language in languages else 0 self.pitchLanguage.setCurrentIndex(index) def saveSettings(self): QSettings().setValue('scorewiz/lilypond/pitch_language', self.window().pitchLanguage())
def create_combobox(): """ Creates toolbar QComboBox :return combobox: Combobox :rtype combobox: QComboBox """ combobox = QComboBox() combobox.setObjectName("filterComboBox") combobox.addItems(["Apply Filter"]) return combobox
def initId(self, chunks, param): cb = QComboBox() tmp_list = [] for chunk in chunks: events = chunk.events() for event in events: tmp_list.append(str(events[event][param])) tmp_list = self.unique(tmp_list) cb.addItems(tmp_list) return cb
def createEditor(self, parent, option, index): combo = QComboBox(parent) keys = Q.Op.keys() keys = map(lambda x: projex.text.joinWords(x, ' ').lower(), keys) combo.addItems(sorted(keys)) combo.setEditable(True) combo.setInsertPolicy(QComboBox.NoInsert) return combo
def __combotableitem(self): """Devuelve un nuevo objeto tipo combotableitem con la lista de tipos""" lista = QtCore.QStringList() from pyrqt.listas import SL from PyQt4.QtCore import SIGNAL for tipo in SL.nombrevariables: lista.append(tipo) combo = QComboBox() combo.addItems(lista) self.connect(combo, SIGNAL("currentIndexChanged(const QString &)"),self.__modificacion_combotableitem) return combo#self.table2)#,lista)
def createEditor( self, parent, option, index ): combo = QComboBox(parent) keys = Q.Op.keys() keys = map(lambda x: projex.text.joinWords(x, ' ').lower(), keys) combo.addItems(sorted(keys)) combo.setEditable(True) combo.setInsertPolicy(QComboBox.NoInsert) return combo
class LilyPondPreferences(QGroupBox): def __init__(self, parent): super(LilyPondPreferences, self).__init__(parent) grid = QGridLayout() self.setLayout(grid) self.pitchLanguageLabel = QLabel() self.pitchLanguage = QComboBox() self.versionLabel = QLabel() self.version = QComboBox(editable=True) self.pitchLanguage.addItem('') self.pitchLanguage.addItems([lang.title() for lang in sorted(scoreproperties.keyNames)]) self.version.addItem(lilypondinfo.preferred().versionString()) for v in ("2.18.0", "2.16.0", "2.14.0", "2.12.0"): if v != lilypondinfo.preferred().versionString(): self.version.addItem(v) grid.addWidget(self.pitchLanguageLabel, 0, 0) grid.addWidget(self.pitchLanguage, 0, 1) grid.addWidget(self.versionLabel, 1, 0) grid.addWidget(self.version, 1, 1) self.pitchLanguage.activated.connect(self.slotPitchLanguageChanged) app.translateUI(self) self.loadSettings() self.window().finished.connect(self.saveSettings) def translateUI(self): self.setTitle(_("LilyPond")) self.pitchLanguageLabel.setText(_("Pitch name language:")) self.pitchLanguage.setToolTip(_( "The LilyPond language you want to use for the pitch names.")) self.pitchLanguage.setItemText(0, _("Default")) self.versionLabel.setText(_("Version:")) self.version.setToolTip(_( "The LilyPond version you will be using for this document.")) def slotPitchLanguageChanged(self, index): if index == 0: language = '' else: language = self.pitchLanguage.currentText().lower() self.window().setPitchLanguage(language) def loadSettings(self): language = self.window().pitchLanguage() languages = list(sorted(scoreproperties.keyNames)) index = languages.index(language) + 1 if language in languages else 0 self.pitchLanguage.setCurrentIndex(index) def saveSettings(self): QSettings().setValue('scorewiz/lilypond/pitch_language', self.window().pitchLanguage())
def addItems(self, items, severe=False): """ Fügt der Box eine Liste von Geistesstörungen einer bestimmten Kategorie hinzu. """ if severe: for item in items: self.addItem(item) self.__severeDerangements.append(item) self.setItemData(self.count()-1, QColor(Config.COLOR_DERANGEMENTS_SEVERE), Qt.BackgroundRole) else: QComboBox.addItems(self, items)
def combo_box(self, selected, items=["None", "Happy", "Concentrated", "Bored", "Annoyed", "Angry"]): """ Returns a combo box of the available emotions. """ combo = QComboBox() combo.setStyleSheet("QComboBox { combobox-popup: 0; }") combo.addItems(items) if selected in items: combo.setCurrentIndex(items.index(selected)) combo.resize(300, 30) return combo
def createEditor(self, parent, option, index): editor = QComboBox(parent) if index.column() == 0: items = self._items_pair[0] elif index.column() == 1: items = self._items_pair[1] editor.addItems(items) return editor
def createEditor(self, parent, option, index): if index.column() in (MOD1, MOD2, MOD3): combobox = QComboBox(parent) combobox.addItems(self.modifiers) return combobox elif index.column() == KEY: combobox = QComboBox(parent) combobox.addItems(self.keys) return combobox else: return QItemDelegate.createEditor(self, parent, option, index)
def createEditor(self, parent, option, index): """ Reimplementation of generic list column QItemDelegate createEditor method """ data_source = index.model().data_source() if DelegateRoutine().is_pdf(data_source, index): return import_types = data_source.import_as() combobox = QComboBox(parent) combobox.addItems(sorted(import_types)) return combobox
def on_adicionar_vertice_button_clicked(self): if not self.grafo: nome = str(self.nome_edit.text()) if nome == '': QMessageBox(self).critical(self, 'ERRO', 'O Gravo deve ter um nome!', buttons=QMessageBox.Ok) return self.grafo = AlgoritmosGrafoNO(nome) self.observe(self.grafo) self.limparInferencias() vertices = str(self.vertices_edit.text()) vertices = vertices.split(',') if len(vertices) > 0: self.signalMapper = QSignalMapper(self) for vertice in vertices: vertice = vertice.strip() if vertice != '': cont = self.tabela_adjacencia.rowCount() item = QTableWidgetItem(vertice) self.tabela_adjacencia.insertColumn(cont) self.tabela_adjacencia.insertRow(cont) self.tabela_adjacencia.setHorizontalHeaderItem(cont,item) self.tabela_adjacencia.setVerticalHeaderItem(cont,item) self.grafo.adicionarVertice(vertice) for x in xrange(self.tabela_adjacencia.rowCount()): comboV = QComboBox(self) comboH = QComboBox(self) comboV.addItems(['0','1']) comboH.addItems(['0','1']) comboV.setSizePolicy(QSizePolicy().Minimum, QSizePolicy().Minimum) comboH.setSizePolicy(QSizePolicy().Minimum, QSizePolicy().Minimum) self.tabela_adjacencia.setCellWidget(cont,x,comboH) self.tabela_adjacencia.setCellWidget(x,cont,comboV) for x in xrange(self.tabela_adjacencia.rowCount()): for y in xrange(self.tabela_adjacencia.rowCount()): item = self.tabela_adjacencia.cellWidget(x, y) self.connect(item, SIGNAL('currentIndexChanged(int)'),self.signalMapper, SLOT('map()')) self.signalMapper.setMapping(item, '{0};{1}'.format(x,y)) self.connect(self.signalMapper, SIGNAL('mapped(QString)'), self.valorAlterado) self.tabela_adjacencia.resizeColumnsToContents() self.tabela_adjacencia.resizeRowsToContents() self.fecho_origem.addItems(vertices) self.informacoes_vertice.addItems(vertices) self.busca_destino.addItems(vertices) self.busca_origem.addItems(vertices) self.remover_vertice_combo.addItems(vertices) self.ordem_resultado.setText(str(self.grafo.obterOrdem())) self.gerar_arestas_button.setEnabled(True) self.vertices_edit.clear()
class NewFileDialog(QDialog): def __init__(self, parent=None): QDialog.__init__(self, parent) self.setMinimumWidth(400) self.setWindowTitle(self.tr("Nuevo archivo")) self._data = {} container = QVBoxLayout(self) # Filename hbox = QHBoxLayout() hbox.addWidget(QLabel(self.tr("Nombre:"))) self._line_filename = QLineEdit() hbox.addWidget(self._line_filename) container.addLayout(hbox) # Type hbox = QHBoxLayout() hbox.addWidget(QLabel(self.tr("Tipo:"))) self._combo_type = QComboBox() self._combo_type.addItems([ self.tr("Archivo Fuente"), self.tr("Archivo de Cabecera") ]) hbox.addWidget(self._combo_type, 1) container.addLayout(hbox) # Buttons hbox = QHBoxLayout() hbox.addStretch(1) btn_ok = QPushButton(self.tr("Aceptar")) hbox.addWidget(btn_ok) btn_cancel = QPushButton(self.tr("Cancelar")) hbox.addWidget(btn_cancel) container.addLayout(hbox) # Conexiones self.connect(btn_ok, SIGNAL("clicked()"), self._save_data) self.connect(btn_cancel, SIGNAL("clicked()"), self.close) self.exec_() def _save_data(self): filename = self._line_filename.text() file_type = self._combo_type.currentIndex() if file_type == 0: filename += '.c' else: filename += '.h' self._data = {'filename': filename, 'type': file_type} self.close() @property def data(self): return self._data
class resampleDialog(QDialog): def __init__(self, parent, multipleSelection, currSampRate): QDialog.__init__(self, parent) self.currLocale = self.parent().prm['data']['currentLocale'] self.currLocale.setNumberOptions(self.currLocale.OmitGroupSeparator | self.currLocale.RejectGroupSeparator) grid = QGridLayout() n = 0 if multipleSelection == False: currSampRateLabel = QLabel(self.currLocale.toString(currSampRate)) grid.addWidget(currSampRateLabel, n, 0) n = n+1 newSampRateLabel = QLabel(self.tr('New Sampling Rate: ')) grid.addWidget(newSampRateLabel, n, 0) self.newSampRateWidget = QLineEdit('48000') self.newSampRateWidget.setValidator(QIntValidator(self)) grid.addWidget(self.newSampRateWidget, n, 1) self.newSampRateWidget.editingFinished.connect(self.onSampRateChanged) n = n+1 convertorLabel = QLabel(self.tr('Resampling Algorithm: ')) grid.addWidget(convertorLabel, n, 0) self.convertorChooser = QComboBox() self.convertorChooser.addItems(['fourier']) self.convertorChooser.setCurrentIndex(0) grid.addWidget(self.convertorChooser, n, 1) n = n+1 winLabel = QLabel(self.tr('Window Type: ')) grid.addWidget(winLabel, n, 0) self.winChooser = QComboBox() self.winChooser.addItems(self.parent().prm['data']['available_windows']) self.winChooser.setCurrentIndex(self.winChooser.findText(self.parent().prm['pref']['smoothingWindow'])) grid.addWidget(self.winChooser, n, 1) n = n+1 buttonBox = QDialogButtonBox(QDialogButtonBox.Ok| QDialogButtonBox.Cancel) buttonBox.accepted.connect(self.accept) buttonBox.rejected.connect(self.reject) grid.addWidget(buttonBox, n, 1) self.setLayout(grid) self.setWindowTitle(self.tr("Resample")) def onSampRateChanged(self): newSampRate = int(self.newSampRateWidget.text()) if newSampRate < 1: QMessageBox.warning(self, self.tr('Warning'), self.tr('New sampling rate too small')) else: self.newSampRate = newSampRate
def createEditor(self, parent, option, index): schema = self.parent().schema() if (not schema): return None colNames = map(lambda x: x.displayName(), schema.columns()) combo = QComboBox(parent) combo.setEditable(True) combo.setInsertPolicy(QComboBox.NoInsert) combo.addItems(colNames) return combo
def createEditor( self, parent, option, index ): schema = self.parent().schema() if ( not schema ): return None colNames = map(lambda x: x.displayName(), schema.columns()) combo = QComboBox(parent) combo.setEditable(True) combo.setInsertPolicy(QComboBox.NoInsert) combo.addItems(colNames) return combo
def AddTenant(self): d = self.project.CreateTenant() it = QTreeWidgetItem(self.ui.tenants, QStringList(["New_tenant", self.tr("No"), self.tr("No")])) cb = QComboBox() cb.addItems([self.tr("No"),self.tr("Yes")]) self.ui.tenants.setItemWidget(it,1,cb) QObject.connect(cb, SIGNAL("currentIndexChanged(int)"), it.emitDataChanged) it.setFlags(Qt.ItemIsEditable | Qt.ItemIsEnabled | Qt.ItemIsSelectable) self.tenants[it] = d self.ui.tenants.editItem(it) self.tenants[it].name = unicode(it.text(0)) self.tenants[it].critical = False if self.ui.tenants.itemWidget(it,1).currentText() == self.tr("Yes") else True self.UpdateTenant(it)
def createAditionalParameters(self, count, enableIgnoreOption): """ Creates aditional parameters upon creation of an attribute item """ #editable item comboItem = QComboBox() comboItem.addItems([self.tr('Yes'), self.tr('No')]) self.attributeTableWidget.setCellWidget(count, 2, comboItem) #ignored item comboItem = QComboBox() comboItem.addItems([self.tr('No'), self.tr('Yes')]) comboItem.setEnabled(enableIgnoreOption) self.attributeTableWidget.setCellWidget(count, 3, comboItem)
class Form(QDialog): def __init__(self, parent=None): super(Form, self).__init__(parent) principalLabel = QLabel("Principal:") self.principalSpinBox = QDoubleSpinBox() self.principalSpinBox.setRange(1, 1000000000) self.principalSpinBox.setValue(1000) self.principalSpinBox.setPrefix("$ ") rateLabel = QLabel("Rate:") self.rateSpinBox = QDoubleSpinBox() self.rateSpinBox.setRange(1, 100) self.rateSpinBox.setValue(5) self.rateSpinBox.setSuffix(" %") yearsLabel = QLabel("Years:") self.yearsComboBox = QComboBox() self.yearsComboBox.addItem("1 year") self.yearsComboBox.addItems( ["{0} years".format(x) for x in range(2, 26)]) amountLabel = QLabel("Amount") self.amountLabel = QLabel() grid = QGridLayout() grid.addWidget(principalLabel, 0, 0) grid.addWidget(self.principalSpinBox, 0, 1) grid.addWidget(rateLabel, 1, 0) grid.addWidget(self.rateSpinBox, 1, 1) grid.addWidget(yearsLabel, 2, 0) grid.addWidget(self.yearsComboBox, 2, 1) grid.addWidget(amountLabel, 3, 0) grid.addWidget(self.amountLabel, 3, 1) self.setLayout(grid) self.connect(self.principalSpinBox, SIGNAL("valueChanged(double)"), self.updateUi) self.connect(self.rateSpinBox, SIGNAL("valueChanged(double)"), self.updateUi) self.connect(self.yearsComboBox, SIGNAL("currentIndexChanged(int)"), self.updateUi) self.setWindowTitle("Interest") self.updateUi() def updateUi(self): """Calculates compound interest""" principal = self.principalSpinBox.value() rate = self.rateSpinBox.value() years = self.yearsComboBox.currentIndex() + 1 amount = principal * ((1 + (rate / 100.0))**years) self.amountLabel.setText("$ {0:.2f}".format(amount))
def __init_widgets__(self): """ Initialise the widgets of the window. """ # The Address/Attachment portion of the window self.attach_model = MessageAttachmentModel() attach_list = QListView() attach_list.setModel(self.attach_model) tab_bar_pxm = QPixmap('res/msg_tabbar_r.png') self.tab_bar = QTabWidget() self.tab_bar.setTabPosition(2) self.tab_bar.setIconSize(QSize(16, 16)) self.tab_bar.addTab(QWidget(), QIcon(tab_bar_pxm.copy(0, 0, 16, 16)), '') self.tab_bar.addTab(attach_list, QIcon(tab_bar_pxm.copy(0, 16, 16, 16)), '') # The Composition Properties portion of the window self.subject_line = QLineEdit() self.subject_line.setPlaceholderText('Subject') QObject.connect(self.subject_line, SIGNAL('textEdited(QString)'), self.update_title) priority_label = QLabel('Priority:') priority_dropdown = QComboBox(self) priority_dropdown.addItems( ['Highest', 'High', 'Normal', 'Low', 'Lowest']) subject_prio_layout = QHBoxLayout() subject_prio_layout.addWidget(self.subject_line) # subject_prio_layout.addStretch(1) subject_prio_layout.addWidget(priority_label) subject_prio_layout.addWidget(priority_dropdown) # The actual Composition portion of the window self.message = MessageTextEdit(self) # The bottom pane bottom_pane_layout = QVBoxLayout() bottom_pane_layout.addLayout(subject_prio_layout) bottom_pane_layout.addWidget(self.message) bottom_pane = QWidget() bottom_pane.setLayout(bottom_pane_layout) # Central widget is the splitter splitter = QSplitter() splitter.setOrientation(2) splitter.addWidget(self.tab_bar) splitter.addWidget(bottom_pane) self.setCentralWidget(splitter)
class DocumentTab(QWidget): def __init__(self, parent): self.parent = parent super(DocumentTab, self).__init__(parent) self.name = 'Documents' self.formats = config.document_formats flist = [] for i in self.formats: for y in self.formats[i]: flist.append(i + ' to ' + y) flist.sort() convertQL = QLabel(self.tr('Convert:')) self.convertQCB = QComboBox() self.convertQCB.addItems(flist) final_layout = utils.add_to_layout( 'h', convertQL, self.convertQCB, None) self.setLayout(final_layout) def ok_to_continue(self): """ Check if everything is ok with documenttab to continue conversion. Checks if: - unoconv is missing. - Given file extension is same with the declared extension. Return True if all tests pass, else False. """ decl_ext = self.convertQCB.currentText().split(' ')[0] try: if not self.parent.unoconv: raise ValidationError( self.tr( 'Unocov is not installed.\nYou will not be able ' 'to convert document files until you install it.') ) for i in self.parent.fnames: file_ext = os.path.splitext(i)[-1][1:] if file_ext != decl_ext: raise ValidationError( self.trUtf8('{0} is not {1}!'.format(i, decl_ext))) return True except ValidationError as e: QMessageBox.warning(self, 'FF Multi Converter - ' + \ self.tr('Error!'), str(e)) return False