示例#1
0
    def update_table(self):
        if (len(self.tb_sta1ip.text()) > 0
                and len(self.tb_sta1len.text()) > 0):
            self.table.item(0, 0).setText(self.tb_sta1ip.text())
        else:
            self.table.item(0, 0).setText('N/A')
        self.table.item(0, 1).setBackground(QtGui.QColor(255, 0, 0))
        self.table.item(0, 2).setText('')
        self.table.item(0, 3).setText('')

        if (len(self.tb_sta2ip.text()) > 0
                and len(self.tb_sta2len.text()) > 0):
            self.table.item(1, 0).setText(self.tb_sta2ip.text())
        else:
            self.table.item(1, 0).setText('N/A')
        self.table.item(1, 1).setBackground(QtGui.QColor(255, 0, 0))
        self.table.item(1, 2).setText('')
        self.table.item(1, 3).setText('')

        if (len(self.tb_sta3ip.text()) > 0
                and len(self.tb_sta3len.text()) > 0):
            self.table.item(2, 0).setText(self.tb_sta3ip.text())
        else:
            self.table.item(2, 0).setText('N/A')
        self.table.item(2, 1).setBackground(QtGui.QColor(255, 0, 0))
        self.table.item(2, 2).setText('')
        self.table.item(2, 3).setText('')
示例#2
0
 def __init__(self, *args):
     QtGui.QWidget.__init__(self, *args)
     self.plot = pg.PlotWidget()
     self.curveColors = [
                                QtGui.QColor("#FF0000"), #Red
                                QtGui.QColor("#0000FF"), #Blue
                                QtGui.QColor("#006400"), #DarkGreen
                                QtGui.QColor("#9932CC"), #DarkOrchid
                                QtGui.QColor("#FFA500"), #Orange
                                QtGui.QColor("#DC143C"), #Crimson
                                QtGui.QColor("#00008B"), #DarkBlue
                                QtGui.QColor("#556B2F"), #DarkOLiveGreen
                                QtGui.QColor("#FF00FF"), #Magenta
                                QtGui.QColor("#FFD700"), #Gold
                                ]
     self.dictCurves = {} # {"name" : {'curve': , 'x': , 'y':, 'color', 'show'}, ... }
     self.colorIndex = 0
     self.plot.setLabel('bottom', 'Position/Energy')        
     self.menu = self.plot.getMenu()
     self.autoScale = QtGui.QAction("Auto Scale", self.menu)
     self.autoScale.triggered.connect(self.setAutoScale)
     self.menu.addAction(self.autoScale)
     
     self.buttons = {}
     self.buttonsLayout = QtGui.QHBoxLayout()  
     
     self.layout = QtGui.QVBoxLayout()
     self.layout.addLayout(self.buttonsLayout)
     self.layout.addWidget(self.plot)
     
     self.setLayout(self.layout)
示例#3
0
    def genDaemonTextAndWarnings(self):
        #Add text to bottom left of GUI showing if daemons are running and enabled
        daemon_text = QtGui.QGraphicsTextItem()
        daemon_warning = QtGui.QGraphicsTextItem()
        text_content = ''
        warning_content = ''
        for dname in self.my_utils.getRelevantDaemons():
            d_enabled, d_running = self.getDaemonStatuses(dname)
            text_content += 'Daemon: %s. Enabled = %d, Running = %d.\n' % (
                dname, d_enabled, d_running)
            if not d_enabled:
                warning_content += 'Daemon %s is DISABLED as of %s\n' % (
                    dname, datetime.datetime.today().strftime(
                        "%A, %d. %B %Y %I:%M%p"))
            if not d_running:
                warning_content += 'Daemon %s is NOT RUNNING as of %s!\n' % (
                    dname, datetime.datetime.today().strftime(
                        "%A, %d. %B %Y %I:%M%p"))
        if warning_content: warning_content += "Tell an expert!"

        daemon_text.setPlainText(text_content)
        daemon_text.setDefaultTextColor(QtGui.QColor('white'))
        myfont = QtGui.QFont()
        myfont.setPointSize(12)
        daemon_text.setFont(myfont)
        daemon_warning.setPlainText(warning_content)
        daemon_warning.setDefaultTextColor(QtGui.QColor('white'))
        warningfont = QtGui.QFont()
        warningfont.setPointSize(50)
        daemon_warning.setFont(warningfont)

        #if daemon_warning actually had nothing in it, return no daemon warning
        return (daemon_text,
                daemon_warning) if warning_content else (daemon_text, 0)
示例#4
0
    def initUi(self):
        self.pw = pg.PlotWidget(
            name='Plot1'
        )  ## giving the plots names allows us to link their axes together
        self.ui.l.addWidget(self.pw)
        self.pw2 = pg.PlotWidget(name='Plot2')
        self.ui.l.addWidget(self.pw2)

        self.ui.show()

        ## Create an empty plot curve to be filled later, set its pen
        colors = [
            'red', "green", 'blue', 'cyan', 'magenta', 'yellow', 'purple',
            'olive'
        ]
        #for i in range(0,self.ui.channelsSettings.rowCount()):
        #	self.lines[i] = self.pw.plot()
        #	self.lines[i].setPen(QtGui.QColor(colors[i]))
        self.line0 = self.pw2.plot()
        print(self.line0)
        self.line0.setPen(QtGui.QColor('red'))
        self.line1 = self.pw.plot()
        self.line1.setPen(QtGui.QColor("green"))
        self.line2 = self.pw2.plot()
        self.line2.setPen(QtGui.QColor("blue"))
        self.line3 = self.pw.plot()
        self.line3.setPen(QtGui.QColor("cyan"))

        self.pw.setLabel('left', 'Signal', units='arb. un.')
        self.pw.setLabel('bottom', 'Angle', units='deg.')
        self.pw.setXRange(0, 360)
        self.pw.setYRange(0, 1e10)
        self.pw2.setMaximumHeight(300)
        '''
示例#5
0
	def	update(self):
		data = self.allData[self.i]
		self.sImg.setImage(data[0], levels=(0.,1.))
		self.aImg.setImage(data[1], levels=(0.,1.))
		self.zStxt.setText("z = %f" % data[2])
		self.zAtxt.setText("z = %f" % data[2])

		vb = self.aPlot.getViewBox()

		aSzeX = vb.size().width()*0.96
		aSzeY = vb.size().height()*0.8

		self.aLeg.size   = (aSzeX/20, aSzeY)
		self.aLeg.offset = (aSzeX,    aSzeY/12.)

		vs = self.sPlot.getViewBox()

		sSzeX = vs.size().width()*0.96
		sSzeY = vs.size().height()*0.8

		self.sLeg.size   = (sSzeX/20, sSzeY)
		self.sLeg.offset = (aSzeX/0.96 + sSzeX, sSzeY/12.)

		sPos = np.linspace(0.0, data[3], 5)
		sLab = ["%.2f" % mod for mod in sPos]
		self.sLeg.gradient.setColorAt(0.00, QtGui.QColor(255,255,255))
		self.sLeg.gradient.setColorAt(0.25, QtGui.QColor(255,  0,  0))
		self.sLeg.gradient.setColorAt(0.50, QtGui.QColor(255,255,  0))
		self.sLeg.gradient.setColorAt(0.75, QtGui.QColor(  0,255,255))
		self.sLeg.gradient.setColorAt(1.00, QtGui.QColor(  0,  0,  0))
		self.sLeg.setLabels({ sLab[0]: 0.0, sLab[1]: 0.25, sLab[2]: 0.50, sLab[3]: 0.75, sLab[4]: 1.00 })

		self.i = (self.i+self.step)%self.size
示例#6
0
def test_opts():
    # test that curve and scatter plot properties get updated from PlotDataItem methods
    y = list(np.random.normal(size=100))
    x = np.linspace(5, 10, 100)
    pdi = pg.PlotDataItem(x, y)
    pen = QtGui.QPen(QtGui.QColor('#FF0000'))
    pen2 = QtGui.QPen(QtGui.QColor('#FFFF00'))
    brush = QtGui.QBrush(QtGui.QColor('#00FF00'))
    brush2 = QtGui.QBrush(QtGui.QColor('#00FFFF'))
    float_value = 1.0 + 20 * np.random.random()
    pen2.setWidth(int(float_value))
    pdi.setPen(pen)
    assert pdi.curve.opts['pen'] == pen
    pdi.setShadowPen(pen2)
    assert pdi.curve.opts['shadowPen'] == pen2
    pdi.setFillLevel(float_value)
    assert pdi.curve.opts['fillLevel'] == float_value
    pdi.setFillBrush(brush2)
    assert pdi.curve.opts['brush'] == brush2

    pdi.setSymbol('t')
    assert pdi.scatter.opts['symbol'] == 't'
    pdi.setSymbolPen(pen)
    assert pdi.scatter.opts['pen'] == pen
    pdi.setSymbolBrush(brush)
    assert pdi.scatter.opts['brush'] == brush
    pdi.setSymbolSize(float_value)
    assert pdi.scatter.opts['size'] == float_value
    def update_tree(self, index=0):
        try:
            self.ui.treeWidgetProjectFolder.clear()
            self.display_folder_structure(self.project_path,
                                          self.ui.treeWidgetProjectFolder)
            files_loaded = len([
                x for x in os.listdir(self.project_path) if "exp" in x.lower()
                and os.path.isdir(os.path.join(self.project_path, x))
            ])
            circle_files = len([
                f for root, dirs, files in os.walk(self.project_path)
                for f in files if "center" in f.lower()
            ])

            sys.stdout.write("Files Loaded: " + str(files_loaded) +
                             " Center files: " + str(circle_files) + "\n")

            root = self.ui.treeWidgetProjectFolder.invisibleRootItem()
            for i in range(root.childCount()):
                item = root.child(i)
                listed_dir = " ".join(os.listdir(item.text(1)))
                if "center" in listed_dir and "dataframe" not in listed_dir:
                    item.setBackground(0, QtGui.QColor("lightyellow"))
                if "center" not in listed_dir and "dataframe" in listed_dir:
                    item.setBackground(0, QtGui.QColor("lightblue"))
                if "center" in listed_dir and "dataframe" in listed_dir:
                    item.setBackground(0, QtGui.QColor(0, 255, 68, 50))

        except Exception as e:
            print(e)
            print("No paths set. This is likely not so helpful.")
示例#8
0
    def addFilledAreaandLabel(self, coords_0, coords_1, label):
        #filled area
        fill = MyLinearRegionItem([coords_0, coords_1],
                                  movable=True,
                                  pen=QtGui.QColor(255, 0, 255),
                                  brush=QtGui.QColor(0, 0, 255, 25),
                                  hoverPen=QtGui.QColor(58, 59, 60),
                                  swapMode='block')
        fill.sigDoubleClick.connect(self.DoubleClickonRegion)
        fill.sigRegionChanged.connect(self.changeRegionPosition)

        #text
        text = pg.TextItem(text="", color=(0, 0, 0), anchor=(0.5, 0.5))
        text.setPos((coords_0 + coords_1) / 2, (self.height / 2) * 0.8)
        text.setText(label)

        #store the filled area and text to be able to modify them later
        self.filled_areas.append(fill)
        self.texts.append(text)

        #remove infinite line that controls audio plaback
        if self.isWaveFile: self.removeItem(self.ControlLine)

        #add the elements to the picture
        self.addItem(self.filled_areas[-1])
        self.addItem(self.texts[-1])

        #add again infinite line that controls audio plaback
        if self.isWaveFile: self.addItem(self.ControlLine)
示例#9
0
 def map(self, data, mode='byte'):
     """
     Return an array of colors corresponding to the values in *data*. 
     Data must be either a scalar position or an array (any shape) of positions.
     
     The *mode* argument determines the type of data returned:
     
     =========== ===============================================================
     byte        (default) Values are returned as 0-255 unsigned bytes.
     float       Values are returned as 0.0-1.0 floats. 
     qcolor      Values are returned as an array of QColor objects.
     =========== ===============================================================
     """
     if isinstance(mode, basestring):
         mode = self.enumMap[mode.lower()]
         
     if mode == self.QCOLOR:
         pos, color = self.getStops(self.BYTE)
     else:
         pos, color = self.getStops(mode)
         
     data = np.clip(data, pos.min(), pos.max())
         
     if not isinstance(data, np.ndarray):
         interp = scipy.interpolate.griddata(pos, color, np.array([data]))[0]
     else:
         interp = scipy.interpolate.griddata(pos, color, data)
     
     if mode == self.QCOLOR:
         if not isinstance(data, np.ndarray):
             return QtGui.QColor(*interp)
         else:
             return [QtGui.QColor(*x) for x in interp]
     else:
         return interp
示例#10
0
    def __init__(self, dphase):
        self.purple = pg.mkPen(QtGui.QColor(20, 20, 140, 255))
        self.red = pg.mkPen(QtGui.QColor(180, 0, 0, 255))
        self.blue = pg.mkPen(QtGui.QColor(20, 20, 140, 255))
        self.roicolor = QtGui.QPen()
        self.roicolor.setBrush(QtGui.QColor(20, 20, 140, 255))

        self.dphase = dphase
        self.p5main = glo_var.MyPW(x="\u03b1",
                                   y1="\u03b2",
                                   set_range=self.set_range)
        self.p5 = self.p5main.plotItem

        self.viewbox = self.p5main.getPlotItem().getViewBox()
        self.viewbox.setBackgroundColor('w')
        self.p5main.coordinate_label = QtGui.QLabel()
        self.frame = glo_var.setframe(
            self.p5main,
            width=1,
            coordinate_label=self.p5main.coordinate_label)

        self.dphase.addWidget(self.frame)
        self.viewbox.setLimits(xMin=0, yMin=0, xMax=1, yMax=1)
        self.set_range()

        self.p5main.plotItem.addLegend = glo_var.myaddLegend
        self.p5main.addLegend(self.p5main.plotItem, offset=(0, 0.0000001))
        self.leg = self.p5main.plotItem.legend
        self.p5main.setLabel('bottom', "\u03b1", **glo_var.labelstyle)
        self.p5main.setLabel('left', "\u03b2", **glo_var.labelstyle)
        self.initiate()
示例#11
0
 def getColor(self, x, toQColor=True):
     """
     Return a color for a given value.
     
     ============= ==================================================================
     **Arguments** 
     x             Value (position on gradient) of requested color.
     toQColor      If true, returns a QColor object, else returns a (r,g,b,a) tuple.
     ============= ==================================================================
     """
     ticks = self.listTicks()
     if x <= ticks[0][1]:
         c = ticks[0][0].color
         if toQColor:
             return QtGui.QColor(c)  # always copy colors before handing them out
         else:
             return (c.red(), c.green(), c.blue(), c.alpha())
     if x >= ticks[-1][1]:
         c = ticks[-1][0].color
         if toQColor:
             return QtGui.QColor(c)  # always copy colors before handing them out
         else:
             return (c.red(), c.green(), c.blue(), c.alpha())
         
     x2 = ticks[0][1]
     for i in range(1,len(ticks)):
         x1 = x2
         x2 = ticks[i][1]
         if x1 <= x and x2 >= x:
             break
             
     dx = (x2-x1)
     if dx == 0:
         f = 0.
     else:
         f = (x-x1) / dx
     c1 = ticks[i-1][0].color
     c2 = ticks[i][0].color
     if self.colorMode == 'rgb':
         r = c1.red() * (1.-f) + c2.red() * f
         g = c1.green() * (1.-f) + c2.green() * f
         b = c1.blue() * (1.-f) + c2.blue() * f
         a = c1.alpha() * (1.-f) + c2.alpha() * f
         if toQColor:
             return QtGui.QColor(int(r), int(g), int(b), int(a))
         else:
             return (r,g,b,a)
     elif self.colorMode == 'hsv':
         h1,s1,v1,_ = c1.getHsv()
         h2,s2,v2,_ = c2.getHsv()
         h = h1 * (1.-f) + h2 * f
         s = s1 * (1.-f) + s2 * f
         v = v1 * (1.-f) + v2 * f
         c = QtGui.QColor()
         c.setHsv(h,s,v)
         if toQColor:
             return c
         else:
             return (c.red(), c.green(), c.blue(), c.alpha())
示例#12
0
文件: Node.py 项目: slac-lcls/ami
 def recolor(self, typ=None):
     if typ == "exception":
         self.graphicsItem().setPen(QtGui.QPen(QtGui.QColor(255, 0, 0), 5))
     elif typ == "selected":
         self.graphicsItem().setPen(QtGui.QPen(QtGui.QColor(250, 150, 0),
                                               3))
     else:
         self.graphicsItem().setPen(QtGui.QPen(QtGui.QColor(0, 0, 0)))
示例#13
0
 def __init__(self, sides, parent=None):
     QtWidgets.QWidget.__init__(self, parent)
     self.pen = QtGui.QPen(QtGui.QColor(0, 0, 0))  # set lineColor
     self.pen.setWidth(3)  # set lineWidth
     self.brush = QtGui.QBrush(QtGui.QColor(255, 255, 255,
                                            255))  # set fillColor
     self.polygon = self.createPoly(
         sides, 260,
         18)  # polygon with n points, radius, angle of the first point
示例#14
0
    def paintEvent(self, ev):
        if self.dropArea is None:
            return
        p = QtGui.QPainter(self)
        rgn = self.rect()

        p.setBrush(QtGui.QBrush(QtGui.QColor(100, 100, 255, 50)))
        p.setPen(QtGui.QPen(QtGui.QColor(50, 50, 150), 3))
        p.drawRect(rgn)
示例#15
0
    def setStatus(self, isConnected, isError=False):
        def dotChange(
            item, nDots
        ):  #Timer function to display a varying number of dots after "retrying"
            if Parameters.isConnected == True:
                return
            if Parameters.isAppKilled == True:
                return
            textNotConnected = "System not connected, retrying"
            item.setText(textNotConnected + ".")
            #Number of dots varies from 1 to 5
            if nDots == 1:
                textDots = "."
                nDots = 2
            elif nDots == 2:
                textDots = ".."
                nDots = 3
            elif nDots == 3:
                textDots = "..."
                nDots = 4
            elif nDots == 4:
                textDots = "...."
                nDots = 5
            else:
                textDots = "....."
                nDots = 1
            item.setForeground(QtGui.QColor("red"))
            item.setText(textNotConnected + textDots)
            self.timerDotChange = Timer(0.25, dotChange,
                                        [self.itemStatus, nDots])
            self.timerDotChange.start()

        if (isError == True):  #System not connected
            print "Error"
            if hasattr(self, 'timerDotChange'):
                self.timerDotChange.cancel()
                time.sleep(0.5)
            self.itemStatus.setForeground(QtGui.QColor("red"))
            self.itemStatus.setText(
                "Error with system. Please restart the application and the system."
            )
        elif (isConnected == False):  #System not connected
            nDots = 1
            if hasattr(self, 'timerDotChange'):
                self.timerDotChange.cancel()
            self.timerDotChange = Timer(0.25, dotChange,
                                        [self.itemStatus, nDots])
            self.timerDotChange.start()
        else:
            print "Connected"
            if hasattr(self, 'timerDotChange'):
                self.timerDotChange.cancel()
                time.sleep(0.1)
            self.itemStatus.setForeground(QtGui.QColor("green"))
            self.itemStatus.setText("System connected.")
            print "Connected2"
示例#16
0
 def __init__(self, parent=None):
     super(TabWidget, self).__init__(parent)
     d = {
         "custom": QtGui.QColor("#e7e7e7"),
         "other": QtGui.QColor("#f0f0f0"),
         "POS Sales": QtGui.QColor("#90EE90"),
         "Cash Sales": QtGui.QColor("pink"),
         "invoice": QtGui.QColor("#800080"),
     }
     self.setTabBar(TabBar(d))
示例#17
0
 def __init__(self, size, offset):
     self.size = size
     self.offset = offset
     UIGraphicsItem.__init__(self)
     self.setAcceptedMouseButtons(QtCore.Qt.NoButton)
     self.brush = QtGui.QBrush(QtGui.QColor(200, 0, 0))
     self.pen = QtGui.QPen(QtGui.QColor(0, 0, 0))
     self.labels = {'max': 1, 'min': 0}
     self.gradient = QtGui.QLinearGradient()
     self.gradient.setColorAt(0, QtGui.QColor(0, 0, 0))
     self.gradient.setColorAt(1, QtGui.QColor(255, 0, 0))
 def colour_listwidget_by_datatype(self, widget):
     try:
         self.check_datatype()
         for i in range(widget.count()):
             item = widget.item(i)
             text = item.text()
             if self.datatype_columns[text]['datatype'] == "categorical":
                 item.setBackground(QtGui.QColor(252, 186, 3, 50))
             else:
                 item.setBackground(QtGui.QColor(0, 255, 68, 50))
     except Exception as e:
         print(str(e))
示例#19
0
    def __init__(self):
        self.list = []
        QtGui.QWidget.__init__(self)
        mainlayout = QtGui.QVBoxLayout()
        pw = pg.PlotWidget()
        pw1 = pg.PlotWidget()
        pw.setBackground(QtGui.QColor(43, 43, 43))
        pw1.setBackground(QtGui.QColor(43, 43, 43))
        p1 = pw.plot()
        p2 = pw1.plot()

        x1 = np.linspace(0, 10, 100)
        y1 = np.sin(x1)
        p1.setData(x1, y1)

        for i in y1:
            listc = []
            if i > 0:
                listc.append(1)
            else:
                listc.append(0)
                i = i * -1

            c = int(i * 2048)
            listc += self.f1(c)

            operator = {'000': self.f000, '001': self.f001, '010': self.f010,
                        '011': self.f011,
                        '100': self.f100,
                        '101': self.f101,
                        '110': self.f110,
                        '111': self.f111}

            tmp = [str(i) for i in listc[1:4]]
            strt = ''.join(tmp)
            listc += operator.get(strt)(c)
            self.list.append(listc)

        listy = []
        for l in self.list:

            listy.append(self.unlock(l))

        nyy = np.array(listy)

        p2.setData(x1, nyy)
        mainlayout.addWidget(pw)
        mainlayout.addWidget(pw1)
        self.setLayout(mainlayout)
示例#20
0
    def paint(self, p, opt, widget):
        super(GradientLegend, self).paint(p, opt, widget)
        pen = QtGui.QPen(QtGui.QColor(0, 0, 0))
        rect = self.boundingRect()
        unit = self.pixelSize()

        offset = 10, 10
        size = widget.width() / 10, widget.height() / 3
        padding = 10

        x1 = rect.left() + unit[0] * offset[0]
        x2 = x1 + unit[0] * size[0]
        y1 = rect.bottom() - unit[1] * offset[1]
        y2 = y1 - unit[1] * size[1]

        # Draw background
        p.setPen(pen)
        p.setBrush(QtGui.QBrush(QtGui.QColor(255, 255, 255, 100)))
        rect = QtCore.QRectF(
            QtCore.QPointF(x1 - padding * unit[0], y1 + padding * unit[1]),
            QtCore.QPointF(x2 + padding * unit[0], y2 - padding * unit[1]))
        p.drawRect(rect)

        p.scale(unit[0], unit[1])

        # Draw color bar
        gradient = QtGui.QLinearGradient()
        i = 0.0
        while i < 1:
            color = plt.get_cmap(self.cm_type)(i)
            color = [x * 255 for x in color]
            gradient.setColorAt(i, QtGui.QColor(*color))
            i += 0.1
        gradient.setStart(0, y1 / unit[1])
        gradient.setFinalStop(0, y2 / unit[1])
        p.setBrush(gradient)
        rect = QtCore.QRectF(QtCore.QPointF(x1 / unit[0], y1 / unit[1]),
                             QtCore.QPointF(x2 / unit[0], y2 / unit[1]))
        p.drawRect(rect)

        # Draw labels
        self.labelsize = self.maximumLabelSize(p)
        lh = self.labelsize.height()
        p.setPen(QtGui.QPen(QtGui.QColor(0, 0, 0)))
        for label in self.labels:
            y = y1 + self.labels[label] * (y2 - y1)
            p.drawText(
                QtCore.QRectF(x1 + widget.width() / 20, y - lh / 2.0, 1000,
                              lh), QtCore.Qt.AlignVCenter, str(label))
示例#21
0
 def updateMasses(self):
     reagents = self.recipe.solution.reagents
     for j, vol in enumerate(self.recipe.volumes):
         for reagent, conc in reagents.items():
             stock = self.recipeSet.stocks.get(reagent, None)
             item = self.reagentItems[reagent][j]
             if stock is None:
                 mw = self.db.reagents[reagent]['molweight']
                 mass = float((vol * 1e-3) * (conc * 1e-3) * (mw * 1e3))
                 item.setText(formatFloat(mass))
                 item.setForeground(QtGui.QColor(0, 0, 0))
             else:
                 rvol = float((vol * 1e-3) * (conc * 1e-3) / (stock * 1e-3))
                 item.setText(formatFloat(rvol))
                 item.setForeground(QtGui.QColor(0, 0, 200))
示例#22
0
class Colors(object):
    FIELD_COLOR = "w"
    FIELD_LINE_COLOR = "w"

    BLUE_ROBOT = QtGui.QColor(255, 100, 0, 255)
    BALL_COLOR = QtGui.QColor(255, 100, 0, 255)
    YELLOW_ROBOT_COLOR = QtGui.QColor(255, 255, 0, 255)
    BLUE_ROBOT_COLOR = QtGui.QColor(0, 75, 255, 255)

    ROBOT_SPEED_SLOW_COLOR = "black"
    NAVIGATOR_PATH_COLOR = "b"
    NAVIGATOR_OBSTACLE_COLOR = "r"

    VALIDATION_PASSED_COLOR = "g"
    VALIDATION_FAILED_COLOR = "r"
示例#23
0
    def __init__(self, pos, id=None, **kargs):
        pg.ROI.__init__(self, pos, **kargs)
        self.posx = pos[0]
        self.posy = pos[1]
        # set the size and color of the handle
        self.handleSize = 9
        self.handlePen = QtGui.QPen(QtGui.QColor(255, 255, 255))
        self.hand1 = None
        self.hand2 = None

        #status
        self._isLocked = False
        self._remove_flag = False
        self._empty = True
        self._updated = False
        self._selected = False

        self._old_style = ""
        # save old style before applying new ones
        self._current_style = "empty"
        #default style since _empty =True is the default state

        # content : this is where graphical object store the logical class
        self.content = -1

        if "parent" in kargs:
            self.parent = kargs["parent"]

        # object id (used to refer to this object by parent or other classes)
        self.id = id
        self.content = None
        # logical object linked to this  graphic object

        #define the Brush and default color
        brush = QtGui.QBrush(QtGui.QColor(0, 255, 255, 150))
        self.setBrush(brush)

        # define the text item and set it to empty string
        # it is positioned at top left of the  box
        self.text_label = ""
        self.showText = False
        self.textItem = pg.TextItem(self.text_label)
        self.textItem.setParentItem(self)
        width, height = self.size()

        self.textItem.setPos(0, height + .1 * height)

        self.menu = None
示例#24
0
    def __init__(self):
        QtGui.QWidget.__init__(self)
        mainLayout = QtGui.QVBoxLayout()
        pw = pg.PlotWidget()
        pw.setBackground(QtGui.QColor(43, 43, 43))
        self.p1 = pw.plot()
        self.p2 = pw.plot(pen=None,
                          symbol='o',
                          symbolPen=None,
                          symbolSize=10,
                          symbolBrush=(100, 100, 255, 100))
        self.value = 10

        checkBtn = QtGui.QPushButton("чбошод")
        valueLabel = QtGui.QLabel("value:  ")
        self.valueLine = QtGui.QLineEdit()

        bottomLayout = QtGui.QHBoxLayout()
        bottomLayout.addWidget(valueLabel)
        bottomLayout.addWidget(self.valueLine)
        bottomLayout.addWidget(checkBtn)
        mainLayout.addWidget(pw)
        mainLayout.addLayout(bottomLayout)
        self.setLayout(mainLayout)

        checkBtn.clicked.connect(self.onCheck)
示例#25
0
    def __init__(self):
        QtGui.QWidget.__init__(self)
        mainLayout = QtGui.QVBoxLayout()
        pw = pg.PlotWidget()
        self.p1 = pw.plot()

        self.p2 = pw.plot(pen=None,
                          symbol='o',
                          symbolPen=None,
                          symbolSize=10,
                          symbolBrush=(100, 100, 255, 100))

        pw.setBackground(QtGui.QColor(43, 43, 43))
        x = np.linspace(0, 10, 100)
        y = np.sin(x)

        for i in range(100):
            if y[i] > 0.8:
                y[i] = 0.8

            if y[i] < 0:
                y[i] = 0

        z = np.sin(x)
        self.p1.setData(x, y)
        self.p2.setData(x, z)
        mainLayout.addWidget(pw)
        self.setLayout(mainLayout)
示例#26
0
    def __init__(self, node, brush=None):
        super().__init__()

        self.pen = fn.mkPen(0, 0, 0)
        self.selectPen = fn.mkPen(200, 200, 200, width=2)

        if brush:
            self.brush = brush
        else:
            self.brush = fn.mkBrush(255, 255, 255, 255)

        self.hoverBrush = fn.mkBrush(200, 200, 200, 200)
        self.selectBrush = fn.mkBrush(200, 200, 255, 200)
        self.hovered = False

        self.node = node
        flags = self.ItemIsMovable | self.ItemIsSelectable | self.ItemSendsGeometryChanges

        self.setFlags(flags)
        self.bounds = QtCore.QRectF(0, 0, 100, 100)
        self.nameItem = QtGui.QGraphicsTextItem(self.node.name(), self)
        self.nameItem.setDefaultTextColor(QtGui.QColor(50, 50, 50))
        self.nameItem.moveBy(
            self.bounds.width() / 2. -
            self.nameItem.boundingRect().width() / 2., 0)

        self.updateTerminals()

        self.menu = None
        self.add_condition = None
        self.enabled = QtGui.QAction("Enabled",
                                     self.menu,
                                     checkable=True,
                                     checked=True)
        self.buildMenu()
示例#27
0
    def setDefault(self, rnum=None):
        if rnum is None and self.table.currentRow() < 0:
            QtGui.QMessageBox.warning(None, "Set Default", "No item selected")
        else:
            if rnum is None:
                rnum = self.table.currentRow()
            else:
                self.table.setCurrentCell(rnum, 0)

            highlight = QtGui.QBrush(QtGui.QColor(0, 255, 0))

            for row in range(0, self.table.rowCount()):
                for col in range(0, self.table.columnCount()):
                    item = self.table.item(row, col)
                    if row == rnum:
                        self.table.item(row, col).setBackground(highlight)
                        # item.setFlags(item.flags() | QtCore.Qt.ItemIsSelectable)
                    else:
                        self.table.item(row, col).setBackground(
                            self.oldbackgrounds[row])
                        # item.setFlags(item.flags() & ~QtCore.Qt.ItemIsSelectable)

            if self.editor:
                desc = self.table.item(rnum, 0).text()
                fname = self.table.item(rnum, 1).text()
                self.editor(filename=fname, filedesc=desc, default=True)
示例#28
0
 def getGradient(self, p1=None, p2=None):
     """Return a QLinearGradient object spanning from QPoints p1 to p2."""
     if p1 == None:
         p1 = QtCore.QPointF(0,0)
     if p2 == None:
         p2 = QtCore.QPointF(self.pos.max()-self.pos.min(),0)
     g = QtGui.QLinearGradient(p1, p2)
     
     pos, color = self.getStops(mode=self.BYTE)
     color = [QtGui.QColor(*x) for x in color]
     g.setStops(zip(pos, color))
     
     #if self.colorMode == 'rgb':
         #ticks = self.listTicks()
         #g.setStops([(x, QtGui.QColor(t.color)) for t,x in ticks])
     #elif self.colorMode == 'hsv':  ## HSV mode is approximated for display by interpolating 10 points between each stop
         #ticks = self.listTicks()
         #stops = []
         #stops.append((ticks[0][1], ticks[0][0].color))
         #for i in range(1,len(ticks)):
             #x1 = ticks[i-1][1]
             #x2 = ticks[i][1]
             #dx = (x2-x1) / 10.
             #for j in range(1,10):
                 #x = x1 + dx*j
                 #stops.append((x, self.getColor(x)))
             #stops.append((x2, self.getColor(x2)))
         #g.setStops(stops)
     return g
示例#29
0
    def __init__(self,
                 text,
                 parent,
                 dataRange=[-100, 0],
                 color=QtGui.QColor(0, 0, 0)):
        QtGui.QWidget.__init__(self, parent=parent)
        self.myParent = parent
        self.color = color

        self.sources = [
            DropTarget("x", self, color=self.color, class_filter="ValueNode"),
            DropTarget("y", self, color=self.color, class_filter="ValueNode")
        ]
        self.curveTypeCombo = gui_elements.PlainComboField(
            parent=self,
            label="curve",
            value="Line",
            choices=["Line", "Scatter"])
        self.curveType = "Line"
        self.connect(self.curveTypeCombo.combo,
                     QtCore.SIGNAL("currentIndexChanged(QString)"),
                     self.updateCurveType)
        self.layout = QtGui.QVBoxLayout()
        self.layout.setMargin(0)
        self.layout.setContentsMargins(0, 0, 0, 0)
        self.layout.setSpacing(0)
        #self.layout.addStretch()
        self.setLayout(self.layout)
        for s in self.sources:
            self.layout.addWidget(s)
        self.layout.addWidget(self.curveTypeCombo)
        self.curve = None
        self.setAcceptDrops(True)
        self.dataRange = dataRange
示例#30
0
    def __init__(self,
                 text,
                 parent,
                 color=QtGui.QColor(0, 0, 0),
                 class_filter=None):
        QtGui.QWidget.__init__(self, parent=parent)
        self.myParent = parent
        self.class_filter = class_filter
        self.originalName = text
        self.currentName = self.originalName
        self.color = color
        self.label = QtGui.QLabel(text, self)
        self.removeButton = QtGui.QPushButton("-")
        #self.removeButton.setAutoFillBackground(True)
        #self.removeButton.setStyleSheet("background-color: rgba(%i, %i, %i, %i); "%(color.red(),  color.green(),  color.blue(),  255))

        self.removeButton.setFixedSize(15, 15)
        self.connect(self.removeButton, QtCore.SIGNAL("clicked()"),
                     self.remove)
        self.layout = QtGui.QHBoxLayout()
        self.setLayout(self.layout)
        self.layout.setMargin(0)

        self.layout.addWidget(self.label)
        self.layout.addWidget(self.removeButton)
        self.layout.addStretch()
        self.setAcceptDrops(True)
        self.source = None
        self.curve = None