def table_item_clicked(self, tableItem): if tableItem.text() == "none": return # set color if tableItem.column() == 1: remember_color = tableItem.background().color() remember_color = QColor("white") if remember_color.name( ) == QColor("black").name() else remember_color color = QColorDialog.getColor(remember_color, self) if color.isValid(): tableItem.setBackground(color) self.tableBtnsConfig.clearSelection() # set the thematic class if tableItem.column() == 2: thematic_raster_class = ThematicRasterClasses() if thematic_raster_class.exec_(): tableItem.setText(thematic_raster_class.pix_value) self.tableBtnsConfig.item(tableItem.row(), 1).setBackground( thematic_raster_class.color) # clean the current row clicked in the trash icon if tableItem.column() == 3: self.tableBtnsConfig.item(tableItem.row(), 0).setText("") self.tableBtnsConfig.item(tableItem.row(), 1).setBackground( QColor(255, 255, 255, 0)) if not self.tableBtnsConfig.item(tableItem.row(), 2).text() == "none": self.tableBtnsConfig.item(tableItem.row(), 2).setText("")
def on_reliefClassTree_itemDoubleClicked(self, item, column): if not item: return if column == 0: d, ok = QInputDialog.getDouble(None, self.tr('Enter lower elevation class bound'), self.tr('Elevation'), float(item.text(0)), decimals=2) if ok: item.setText(0, str(d)) elif column == 1: d, ok = QInputDialog.getDouble(None, self.tr('Enter upper elevation class bound'), self.tr('Elevation'), float(item.text(1)), decimals=2) if ok: item.setText(1, str(d)) elif column == 2: c = QColorDialog.getColor(item.background(2).color(), None, self.tr('Select color for relief class')) if c.isValid(): item.setBackground(2, QBrush(c))
def on_reliefClassTree_itemDoubleClicked(self, item, column): if not item: return if column == 0: d, ok = QInputDialog.getDouble( None, self.tr('Enter lower elevation class bound'), self.tr('Elevation'), float(item.text(0)), decimals=2) if ok: item.setText(0, str(d)) elif column == 1: d, ok = QInputDialog.getDouble( None, self.tr('Enter upper elevation class bound'), self.tr('Elevation'), float(item.text(1)), decimals=2) if ok: item.setText(1, str(d)) elif column == 2: c = QColorDialog.getColor( item.background(2).color(), None, self.tr('Select color for relief class')) if c.isValid(): item.setBackground(2, QBrush(c))
def setBackgroundColour(self): col = QColorDialog.getColor() if col.isValid(): self.BACKGROUND_COLOUR = col self.dlg.ui.frmColour.setStyleSheet("QWidget { background-color: %s }" % self.BACKGROUND_COLOUR.name())
def change_tiles_color(self, color=None): if not color: color = QColorDialog.getColor( self.layer_to_edit.navigation.tiles_color, self) if color.isValid(): self.layer_to_edit.navigation.tiles_color = color self.TilesColor.setStyleSheet( "QToolButton{{background-color:{};}}".format(color.name()))
def setFill( self ): if self.profile == None: return if self.ax == None: return clr = QColorDialog.getColor( Qt.white, self, QCoreApplication.translate( "geopunt4QgisElevationDialog", "Kies de vulkleur") ) if clr.isValid(): xdata = np.array( [n[0] for n in self.profile ] ) * self.xscaleUnit[0] ydata = np.array( [n[3] for n in self.profile ] ) self.ax.fill_between( xdata, ydata, -9999, color=clr.name() )
def select_color(self, button): initial = button.palette().color(QPalette.Button) color = QColorDialog.getColor(initial) if color.isValid(): self.set_button_color(button, color)
class QdrawSettings(QWidget): """Window used to change settings (transparency/color)""" settingsChanged = pyqtSignal() def __init__(self): QWidget.__init__(self) self.setWindowTitle(self.tr('Qdraw - Settings')) self.setFixedSize(320, 100) self.center() # default color self.color = QColor(60, 151, 255, 255) self.sld_opacity = QSlider(Qt.Horizontal, self) self.sld_opacity.setRange(0, 255) self.sld_opacity.setValue(255) self.sld_opacity.tracking = True self.sld_opacity.valueChanged.connect(self.handler_opacitySliderValue) self.lbl_opacity = QLabel(self.tr('Opacity') + ': 100%', self) self.dlg_color = QColorDialog(self) btn_chColor = QPushButton(self.tr('Change the drawing color'), self) btn_chColor.clicked.connect(self.handler_chColor) vbox = QVBoxLayout() vbox.addWidget(self.lbl_opacity) vbox.addWidget(self.sld_opacity) vbox.addWidget(btn_chColor) self.setLayout(vbox) def tr(self, message): return QCoreApplication.translate('Qdraw', message) def handler_opacitySliderValue(self, val): self.color.setAlpha(val) self.lbl_opacity.setText( self.tr('Opacity')+': '+str(int((float(val) / 255) * 100))+'%') self.settingsChanged.emit() def handler_chColor(self): color = self.dlg_color.getColor(self.color) if color.isValid(): color.setAlpha(self.color.alpha()) self.color = color self.settingsChanged.emit() self.close() def getColor(self): return self.color def center(self): screen = QDesktopWidget().screenGeometry() size = self.geometry() self.move((screen.width() - size.width()) / 2, (screen.height() - size.height()) / 2) def closeEvent(self, e): self.clear() e.accept() def clear(self): return
def pickcolour(self): colour = QColorDialog.getColor(Qt.black, self) self.scribbleArea.setPenColor(colour)
class QdrawSettings(QWidget): """Window used to change settings (transparency/color)""" settingsChanged = pyqtSignal() def __init__(self): QWidget.__init__(self) self.setWindowTitle(self.tr('Qdraw - Settings')) self.setFixedSize(320, 100) self.center() # default color self.color = QColor(60, 151, 255, 255) self.sld_opacity = QSlider(Qt.Horizontal, self) self.sld_opacity.setRange(0, 255) self.sld_opacity.setValue(255) self.sld_opacity.tracking = True self.sld_opacity.valueChanged.connect(self.handler_opacitySliderValue) self.lbl_opacity = QLabel(self.tr('Opacity') + ': 100%', self) self.dlg_color = QColorDialog(self) btn_chColor = QPushButton(self.tr('Change the drawing color'), self) btn_chColor.clicked.connect(self.handler_chColor) vbox = QVBoxLayout() vbox.addWidget(self.lbl_opacity) vbox.addWidget(self.sld_opacity) vbox.addWidget(btn_chColor) self.setLayout(vbox) def tr(self, message): return QCoreApplication.translate('Qdraw', message) def handler_opacitySliderValue(self, val): self.color.setAlpha(val) self.lbl_opacity.setText( self.tr('Opacity') + ': ' + str(int((float(val) / 255) * 100)) + '%') self.settingsChanged.emit() def handler_chColor(self): color = self.dlg_color.getColor(self.color) if color.isValid(): color.setAlpha(self.color.alpha()) self.color = color self.settingsChanged.emit() self.close() def getColor(self): return self.color def center(self): screen = QDesktopWidget().screenGeometry() size = self.geometry() self.move((screen.width() - size.width()) / 2, (screen.height() - size.height()) / 2) def closeEvent(self, e): self.clear() e.accept() def clear(self): return