Python PySide.QtGui.QBrush() Examples
The following are 10
code examples of PySide.QtGui.QBrush().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
PySide.QtGui
, or try the search function
.
Example #1
Source File: heatmap.py From heatmappy with MIT License | 5 votes |
def _paint_point(self, painter, x, y): grad = QtGui.QRadialGradient(x, y, self.point_diameter/2) grad.setColorAt(0, QtGui.QColor(0, 0, 0, max(self.point_strength, 0))) grad.setColorAt(1, QtGui.QColor(0, 0, 0, 0)) brush = QtGui.QBrush(grad) painter.setBrush(brush) painter.drawEllipse( x - self.point_diameter/2, y - self.point_diameter/2, self.point_diameter, self.point_diameter )
Example #2
Source File: QtShim.py From grap with MIT License | 5 votes |
def get_QBrush(): """QBrush getter.""" try: import PySide.QtGui as QtGui return QtGui.QBrush except ImportError: import PyQt5.QtGui as QtGui return QtGui.QBrush
Example #3
Source File: FinderOverlay.py From cadquery-freecad-module with GNU Lesser General Public License v3.0 | 5 votes |
def initUI(self): # container = QWidget(self) # container.resize(200, 100); # container.setStyleSheet("background-color:black;") font_size = QLabel('Font Size') font_size.fillColor = QColor(30, 30, 30, 120) font_size.penColor = QColor("#333333") grid = QGridLayout() grid.setContentsMargins(50, 10, 10, 10) grid.addWidget(font_size, 0, 0) self.setLayout(grid) # palette = QPalette(self.palette()) # palette.setColor(self.backgroundRole(), Qt.black) # palette.setColor(palette.Background, Qt.transparent) # self.setPalette(palette) # def paintEvent(self, event): # painter = QPainter() # painter.begin(self) # # painter.setRenderHint(QPainter.Antialiasing) # painter.fillRect(event.rect(), QBrush(QColor(255, 255, 255, 127))) # painter.drawLine(self.width() / 8, self.height() / 8, 7 * self.width() / 8, 7 * self.height() / 8) # painter.drawLine(self.width() / 8, 7 * self.height() / 8, 7 * self.width() / 8, self.height() / 8) # # painter.setPen(QPen(Qt.NoPen))
Example #4
Source File: grid.py From FreeCAD_drawing_dimensioning with GNU Lesser General Public License v2.1 | 5 votes |
def specifyNewGridColor(self): color = QtGui.QColorDialog.getColor( self.colorRect.brush().color() ) if color.isValid(): self.colorRect.setBrush( QtGui.QBrush(color) ) self.dd_parms.SetUnsigned( 'grid_color', RGBtoUnsigned(color.red(), color.green(), color.blue()) ) dimensioningGrid.update()
Example #5
Source File: preferences.py From FreeCAD_drawing_dimensioning with GNU Lesser General Public License v2.1 | 5 votes |
def clickFun(self): color = QtGui.QColorDialog.getColor( self.colorRect.brush().color() ) if color.isValid(): self.colorRect.setBrush( QtGui.QBrush(color) ) self.dimensioningProcess.dimensionConstructorKWs[ self.name ] = 'rgb(%i,%i,%i)' % (color.red(), color.green(), color.blue() )
Example #6
Source File: preferences.py From FreeCAD_drawing_dimensioning with GNU Lesser General Public License v2.1 | 5 votes |
def revertToDefault( self ): clr = QtGui.QColor(*unsignedToRGB(self.dd_parms.GetUnsigned( self.name, self.defaultValue )) ) self.colorRect.setBrush( QtGui.QBrush( clr ) ) self.dimensioningProcess.dimensionConstructorKWs[ self.name ] = self.getDefaultValue()
Example #7
Source File: preferences.py From FreeCAD_drawing_dimensioning with GNU Lesser General Public License v2.1 | 5 votes |
def generateWidget( self, dimensioningProcess, width = 60, height = 30 ): self.dimensioningProcess = dimensioningProcess clr = QtGui.QColor(*unsignedToRGB(self.dd_parms.GetUnsigned( self.name, self.defaultValue )) ) self.colorRect.setBrush( QtGui.QBrush( clr ) ) colorBox = QtGui.QGraphicsView( self.graphicsScene ) colorBox.setMaximumWidth( width ) colorBox.setMaximumHeight( height ) colorBox.setHorizontalScrollBarPolicy( QtCore.Qt.ScrollBarPolicy.ScrollBarAlwaysOff ) colorBox.setVerticalScrollBarPolicy( QtCore.Qt.ScrollBarPolicy.ScrollBarAlwaysOff ) return DimensioningTaskDialog_generate_row_hbox( self.label, colorBox )
Example #8
Source File: preferences.py From FreeCAD_drawing_dimensioning with GNU Lesser General Public License v2.1 | 5 votes |
def revertToDefault( self ): self.family_textbox.setText( self.dd_parms.GetString(self.name + '_family', self.defaultValue[0]) ) self.size_textbox.setText( self.dd_parms.GetString(self.name + '_size', self.defaultValue[1]) ) clr = QtGui.QColor(*unsignedToRGB(self.dd_parms.GetUnsigned( self.name+'_color', self.defaultValue[2] )) ) self.colorRect.setBrush( QtGui.QBrush( clr ) ) self.update_dimensionConstructorKWs()
Example #9
Source File: grid.py From FreeCAD_drawing_dimensioning with GNU Lesser General Public License v2.1 | 4 votes |
def generateWidget(self, dimensioningProcess): self.dimensioningProcess = dimensioningProcess groupbox = QtGui.QGroupBox("Grid Options") groupbox.setCheckable( True ) groupbox.toggled.connect( self.groupBoxToggled ) self.groupbox = groupbox checked = self.dd_parms.GetBool("show_grid_options",True) groupbox.setChecked(checked) vbox = QtGui.QVBoxLayout() gridOn_checkbox = QtGui.QCheckBox('grid on') gridOn_checkbox.setChecked( self.dd_parms.GetBool( 'grid_on', False )) gridOn_checkbox.stateChanged.connect( self.gridOn_checkbox_stateChanged ) vbox.addWidget( gridOn_checkbox ) self.gridOn_checkbox = gridOn_checkbox spacingSpinbox = QtGui.QDoubleSpinBox() spacingSpinbox.setValue( self.dd_parms.GetFloat( 'grid_spacing', default_grid_spacing ) ) spacingSpinbox.setMinimum( 0.01 ) spacingSpinbox.setDecimals( 2 ) spacingSpinbox.setSingleStep( 0.5 ) spacingSpinbox.setSuffix('mm') spacingSpinbox.valueChanged.connect( self.spacingSpinbox_valueChanged ) vbox.addLayout( DimensioningTaskDialog_generate_row_hbox('spacing', spacingSpinbox) ) self.spacingSpinbox = spacingSpinbox displayPeriodSpinbox = QtGui.QSpinBox() displayPeriodSpinbox.setValue( min( self.dd_parms.GetInt( 'grid_display_period', default_grid_display_period ), 200) ) displayPeriodSpinbox.setMinimum( 0 ) displayPeriodSpinbox.valueChanged.connect( self.displayPeriodSpinbox_valueChanged ) vbox.addLayout( DimensioningTaskDialog_generate_row_hbox('display period', displayPeriodSpinbox) ) self.displayPeriodSpinbox = displayPeriodSpinbox clr = QtGui.QColor(*unsignedToRGB(self.dd_parms.GetUnsigned( 'grid_color', default_grid_clr )) ) graphicsScene = QtGui.QGraphicsScene(0,0,30,30) pen = QtGui.QPen( QtGui.QColor(0,0,0,0) ) pen.setWidth(0.0) rect = ClickRect(-100, -100, 200, 200) rect.setPen(pen) rect.clickFun = self.specifyNewGridColor graphicsScene.addItem(rect) self.graphicsScene = graphicsScene #protect from garbage collector self.colorRect = rect self.colorRect.setBrush( QtGui.QBrush( clr ) ) colorBox = QtGui.QGraphicsView( self.graphicsScene ) colorBox.setMaximumWidth( 60 ) colorBox.setMaximumHeight( 30 ) colorBox.setHorizontalScrollBarPolicy( QtCore.Qt.ScrollBarPolicy.ScrollBarAlwaysOff ) colorBox.setVerticalScrollBarPolicy( QtCore.Qt.ScrollBarPolicy.ScrollBarAlwaysOff ) vbox.addLayout( DimensioningTaskDialog_generate_row_hbox( 'color', colorBox ) ) lineWidthSpinbox = QtGui.QDoubleSpinBox() lineWidthSpinbox.setValue( self.dd_parms.GetFloat( 'grid_line_width', default_grid_line_width ) ) lineWidthSpinbox.setMinimum( 0. ) lineWidthSpinbox.setDecimals( 2 ) lineWidthSpinbox.setSingleStep( 0.05 ) lineWidthSpinbox.valueChanged.connect( self.lineWidthSpinbox_valueChanged ) vbox.addLayout( DimensioningTaskDialog_generate_row_hbox('lineWidth', lineWidthSpinbox) ) self.lineWidthSpinbox = lineWidthSpinbox groupbox.setLayout(vbox) return groupbox
Example #10
Source File: VariablesBrowser.py From PySimulator with GNU Lesser General Public License v3.0 | 4 votes |
def addModel(self, model, treeRoot=None): ''' Adds the given model to the variable browser ''' self.itemChanged.disconnect() model.setVariableTree() if treeRoot is None: treeRoot = QtGui.QTreeWidgetItem(self) treeRoot.setCheckState(0, QtCore.Qt.Checked) treeRoot.setFlags(treeRoot.flags() & ~QtCore.Qt.ItemIsEditable & ~QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsUserCheckable) treeRoot.setText(0, model.numberedModelName) if model.modelType == 'None': treeRoot.setForeground(0, QtGui.QBrush(QtGui.QColor('grey'))) treeRoot.numberedModelName = model.numberedModelName treeRoot.model = model treeRoot.isModelRoot = True treeRoot.setFirstColumnSpanned(True) treeRoot.setExpanded(True) model.rootItem = treeRoot elif treeRoot.childCount() > 0: # Define function that is called when a item of the tree will be checked/unchecked self.itemChanged.connect(self.browserItemCheckChanged) return # Define the tipText displayed when stopping the mouse over the numbered model name in the variable browser tipText = 'Model type: ' + model.modelType if model.variableTree.rootAttribute is not None: if len(model.variableTree.rootAttribute) > 0: tipText += '\n\n' + model.variableTree.rootAttribute treeRoot.setToolTip(0, tipText) # Generate a nice list of model variables # variableNames = model.variableTree.variable.keys() variableNames = list() for name, variable in model.variableTree.variable.iteritems(): variableNames.append([variable.browserName, name]) def natsort_key(x1, _nsre=re.compile('([0-9]+)')): x = x1[0] return [int(text) if text.isdigit() else text.lower() for text in re.split(_nsre, x)] # Sort the variables for the tree variableNames.sort(key=natsort_key) for v in variableNames: self.addItemToTree(treeRoot, v[0], v[1], model) # Show changed start values in startValueBox given in model.settings for variable in model.changedStartValue: self.setVariable(model, variable, model.changedStartValue[variable]) # Define function that is called when a item of the tree will be checked/unchecked self.itemChanged.connect(self.browserItemCheckChanged) self.itemExpanded.connect(self.dyamicLoadBranch) # To set this model as current one self.browserItemCheckChanged(treeRoot)