def setData(self, xx, yy, zz): self.xx = xx self.yy = yy self.zz = zz self.axes.cla() x = range(len(xx)) self.figures = [] lines = [] prev_y = [0 * len(xx)] progressDlg = ProgressDialog(self.tr("Building chart"), self.tr("Cancel"), len(yy), self) progressDlg.setMinimumDuration(2000) for i, y in enumerate(yy): progressDlg.step() if progressDlg.wasCanceled(): return color = self.multicolors[i % len(self.multicolors)] bars = self.axes.barh(x, y, left=prev_y, color=color) for bar in bars: self.figures.append(bar) prev_y = numpy.add(prev_y, y) lines.append(bars[0]) progressDlg.setLabelText(self.tr("Drawing chart")) self.axes.set_yticks(x) keys = ['\n'.join(wrap(l, 17)) for l in xx] self.axes.set_yticklabels(keys) self.axes.set_xlabel(self.label) xa = self.axes.get_xaxis() xa.set_major_locator(MaxNLocator(integer=True)) self.axes.legend(lines, zz, frameon=True) self.draw() progressDlg.reset()
def preview(self): self.table.show() category = self.categorySelector.currentData() if category in ('coins', 'stamps'): self.distributionSelector.setVisible(True) else: self.distributionSelector.setVisible(False) series = self.seriesSelector.currentData() year = self.yearSelector.currentData() value = self.valueSelector.currentData() currency = self.currencySelector.currentData() if self.distributionSelector.isVisible(): distribution = self.distributionSelector.currentData() else: distribution = None country = self.countrySelector.currentData() action = "list_id/cat/%s/producer/%d" % (category, country) if series: action += "/series/%s" % series if distribution: if category == 'coins': action += "/distribution/%s" % distribution elif category == 'stamps': action += "/emission/%s" % distribution if year: action += "/year/%s" % year if value: action += "/face_value/%s" % value if currency: action += "/currency/%s" % currency item_ids = self.colnect.getData(action) progressDlg = ProgressDialog(self.tr("Downloading"), self.tr("Cancel"), len(item_ids), self) self.table.setRowCount(len(item_ids)) for i, item_id in enumerate(item_ids): progressDlg.step() if progressDlg.wasCanceled(): break action = "item/cat/%s/id/%d" % (category, item_id) data = self.colnect.getData(action) data.append(self._itemUrl(category, item_id)) self.items.append(data) image = self._getImage(int(data[8]), data[0]) pixmap = QPixmap.fromImage(image) item = QTableWidgetItem() item.setData(Qt.DecorationRole, pixmap) self.table.setItem(i, 0, item) image = self._getImage(int(data[9]), data[0]) pixmap = QPixmap.fromImage(image) item = QTableWidgetItem() item.setData(Qt.DecorationRole, pixmap) self.table.setItem(i, 1, item) item = QTableWidgetItem(data[0]) self.table.setItem(i, 2, item) item = QTableWidgetItem(data[2]) self.table.setItem(i, 3, item) item = QTableWidgetItem(str(data[4])) self.table.setItem(i, 4, item) item = QTableWidgetItem(data[14]) self.table.setItem(i, 5, item) item = QTableWidgetItem(data[19]) self.table.setItem(i, 6, item) item = QTableWidgetItem(str(data[13])) self.table.setItem(i, 7, item) item = QTableWidgetItem(data[12]) self.table.setItem(i, 8, item) progressDlg.reset() if item_ids: self.addButton.setEnabled(True) self.addCloseButton.setEnabled(True)
def preview(self): self.table.show() category = self.categorySelector.currentData() if category in ('coins', 'stamps'): self.distributionSelector.setVisible(True) else: self.distributionSelector.setVisible(False) series = self.seriesSelector.currentData() year = self.yearSelector.currentData() value = self.valueSelector.currentData() currency = self.currencySelector.currentData() if self.distributionSelector.isVisible(): distribution = self.distributionSelector.currentData() else: distribution = None country = self.countrySelector.currentData() action = "list_id/cat/%s/producer/%d" % (category, country) if series: action += "/series/%s" % series if distribution: if category == 'coins': action += "/distribution/%s" % distribution elif category == 'stamps': action += "/emission/%s" % distribution if year: action += "/year/%s" % year if value: action += "/face_value/%s" % value if currency: action += "/currency/%s" % currency item_ids = self.colnect.getData(action) if item_ids: progressDlg = ProgressDialog(self.tr("Downloading"), self.tr("Cancel"), len(item_ids), self) action = "fields/cat/%s" % category fields = self.colnect.getFields(action) self.table.setRowCount(len(item_ids)) for i, item_id in enumerate(item_ids): progressDlg.step() if progressDlg.wasCanceled(): break action = "item/cat/%s/id/%d" % (category, item_id) data = self.colnect.getData(action) data.append(self._itemUrl(category, item_id)) self.items.append(data) name_val = self._getFieldData(data, fields, 'Name') img_pos = fields.index('FrontPicture') image = self._getImage(int(data[img_pos]), name_val) pixmap = QPixmap.fromImage(image) item = QTableWidgetItem() item.setData(Qt.DecorationRole, pixmap) self.table.setItem(i, 0, item) img_pos = fields.index('BackPicture') image = self._getImage(int(data[img_pos]), name_val) pixmap = QPixmap.fromImage(image) item = QTableWidgetItem() item.setData(Qt.DecorationRole, pixmap) self.table.setItem(i, 1, item) value = self._getFieldData(data, fields, 'Name') item = QTableWidgetItem(value) self.table.setItem(i, 2, item) value = self._getFieldData(data, fields, 'Series') item = QTableWidgetItem(value) self.table.setItem(i, 3, item) value = self._getFieldData(data, fields, 'Issued on') item = QTableWidgetItem(str(value)) self.table.setItem(i, 4, item) value = self._getFieldData(data, fields, 'Distribution') item = QTableWidgetItem(value) self.table.setItem(i, 5, item) value = self._getFieldData(data, fields, 'Composition') item = QTableWidgetItem(value) self.table.setItem(i, 6, item) value = self._getFieldData(data, fields, 'FaceValue') item = QTableWidgetItem(str(value)) self.table.setItem(i, 7, item) value = self._getFieldData(data, fields, 'Currency') item = QTableWidgetItem(value) self.table.setItem(i, 8, item) progressDlg.reset() self.addButton.setEnabled(True) self.addCloseButton.setEnabled(True)