示例#1
0
    def testColorCti(self):

        colorStr = '#FF33EE'
        cti = ColorCti('color', defaultData=colorStr)
        self.assertEqual(cti.data, QtGui.QColor(colorStr))
        self.assertEqual(cti.data, QtGui.QColor(colorStr))
        self.assertEqual(cti.displayValue, colorStr)
示例#2
0
文件: groupcti.py 项目: whigg/argos
class MainGroupCti(GroupCti):
    """ Read only config Tree Item that only stores None.
        To be used as a high level group (e.g. the inspector group)
        Is the same as a groupCti but drawn as light text on a dark grey back ground
    """
    _backgroundBrush = QtGui.QBrush(
        QtGui.QColor("#606060"))  # create only once
    _foregroundBrush = QtGui.QBrush(QtGui.QColor(Qt.white))  # create only once
    _font = QtGui.QFont()
    _font.setWeight(QtGui.QFont.Bold)

    def __init__(self, nodeName, defaultData=None):
        """ Constructor. For the parameters see the AbstractCti constructor documentation.
        """
        super(MainGroupCti, self).__init__(nodeName,
                                           defaultData,
                                           expanded=True)  # always expand

    @property
    def font(self):
        """ Returns a font for displaying this item's text in the tree.
        """
        return self._font

    @property
    def backgroundBrush(self):
        """ Returns a (dark gray) brush for drawing the background role in the tree.
        """
        return self._backgroundBrush

    @property
    def foregroundBrush(self):
        """ Returns a (white) brush for drawing the foreground role in the tree.
        """
        return self._foregroundBrush
示例#3
0
文件: qtctis.py 项目: whigg/argos
 def _enforceDataType(self, data):
     """ Converts to str so that this CTI always stores that type.
     """
     qColor = QtGui.QColor(data)    # TODO: store a RGB string?
     if not qColor.isValid():
         raise ValueError("Invalid color specification: {!r}".format(data))
     return qColor
示例#4
0
文件: pgctis.py 项目: whigg/argos
    def __init__(self, nodeName="pen", defaultData=None, expanded=True):
        """ Constructor.
        """
        super(PgPlotDataItemCti, self).__init__(nodeName,
                                                defaultData=defaultData,
                                                expanded=expanded)
        self.antiAliasCti = self.insertChild(BoolCti("anti-alias", True))

        self.colorCti = self.insertChild(
            ColorCti('color', QtGui.QColor('#FF0066')))
        self.lineCti = self.insertChild(
            BoolCti('line', True, expanded=False, childrenDisabledValue=False))
        self.lineStyleCti = self.lineCti.insertChild(
            createPenStyleCti('style'))
        self.lineWidthCti = self.lineCti.insertChild(
            createPenWidthCti('width'))

        defaultShadowPen = QtGui.QPen(QtGui.QColor('#BFBFBF'))
        defaultShadowPen.setWidth(0)
        self.lineCti.insertChild(
            PenCti("shadow",
                   False,
                   expanded=False,
                   resetTo=QtGui.QPen(defaultShadowPen),
                   includeNoneStyle=True,
                   includeZeroWidth=True))

        self.symbolCti = self.insertChild(
            BoolCti("symbol",
                    False,
                    expanded=False,
                    childrenDisabledValue=False))
        self.symbolShapeCti = self.symbolCti.insertChild(
            ChoiceCti("shape",
                      0,
                      displayValues=[
                          'circle', 'square', 'triangle', 'diamond', 'plus'
                      ],
                      configValues=['o', 's', 't', 'd', '+']))
        self.symbolSizeCti = self.symbolCti.insertChild(
            IntCti('size', 5, minValue=0, maxValue=100, stepSize=1))
示例#5
0
    def openColorDialog(self):
        """ Opens a QColorDialog for the user
        """
        try:
            currentColor = self.getData()
        except InvalidInputError:
            currentColor = "#FFFFFF"

        qColor = QtWidgets.QColorDialog.getColor(QtGui.QColor(currentColor),
                                                 self)

        if qColor.isValid():
            self.setData(qColor)
示例#6
0
文件: qtctis.py 项目: whigg/argos
    def getData(self):
        """ Gets data from the editor widget.
        """
        text = self.lineEditor.text()
        if not text.startswith('#'):
            text = '#' + text

        validator = self.lineEditor.validator()
        if validator is not None:
            state, text, _ = validator.validate(text, 0)
            if state != QtGui.QValidator.Acceptable:
                raise InvalidInputError("Invalid input: {!r}".format(text))

        return  QtGui.QColor(text)
示例#7
0
    def _createConfig(self):
        """ Creates a config tree item (CTI) hierarchy containing default children.
        """
        rootItem = MainGroupCti('debug inspector')

        if DEBUGGING:
            # Some test config items.
            import numpy as np
            from argos.config.untypedcti import UntypedCti
            from argos.config.stringcti import StringCti
            from argos.config.intcti import IntCti
            from argos.config.floatcti import FloatCti, SnFloatCti
            from argos.config.boolcti import BoolCti, BoolGroupCti
            from argos.config.choicecti import ChoiceCti
            from argos.config.qtctis import PenCti

            grpItem = GroupCti("group")
            rootItem.insertChild(grpItem)

            lcItem = UntypedCti('line color', 123)
            grpItem.insertChild(lcItem)

            disabledItem = rootItem.insertChild(StringCti('disabled', "Can't touch me"))
            disabledItem.enabled=False

            grpItem.insertChild(IntCti('line-1 color', 7, minValue = -5, stepSize=2,
                                       prefix="@", suffix="%", specialValueText="I'm special"))
            rootItem.insertChild(StringCti('letter', 'aa', maxLength = 1))
            grpItem.insertChild(FloatCti('width', 2, minValue =5, stepSize=0.45, decimals=3,
                                         prefix="@", suffix="%", specialValueText="so very special"))
            grpItem.insertChild(SnFloatCti('scientific', defaultData=-np.inf))

            gridItem = rootItem.insertChild(BoolGroupCti('grid', True))
            gridItem.insertChild(BoolCti('X-Axis', True))
            gridItem.insertChild(BoolCti('Y-Axis', False))

            rootItem.insertChild(ChoiceCti('hobbit', 2, editable=True,
                                           configValues=['Frodo', 'Sam', 'Pippin', 'Merry']))
            myPen = QtGui.QPen(QtGui.QColor('#1C8857'))
            myPen.setWidth(2)
            myPen.setStyle(Qt.DashDotDotLine)
            rootItem.insertChild(PenCti('line', False, resetTo=myPen))

        return rootItem
示例#8
0
""" Classes for displaying the registry contents in a table
"""

from __future__ import print_function

import logging

from argos.qt import QtCore, QtGui, QtWidgets, Qt
from argos.qt.registry import ClassRegistry, ClassRegItem
from argos.qt.togglecolumn import ToggleColumnTableView
from argos.utils.cls import check_class

logger = logging.getLogger(__name__)

QCOLOR_REGULAR = QtGui.QColor('black')
QCOLOR_NOT_IMPORTED = QtGui.QColor('brown')
QCOLOR_ERROR = QtGui.QColor('red')

# The main window inherits from a Qt class, therefore it has many
# ancestors public methods and attributes.
# pylint: disable=R0901, R0902, R0904, W0201


class RegistryTableModel(QtCore.QAbstractTableModel):

    SORT_ROLE = Qt.UserRole

    def __init__(self, registry, attrNames = ('fullName', ), parent=None):
        """ Constructor.
示例#9
0
文件: qtctis.py 项目: whigg/argos
 def _nodeSetValuesFromDict(self, dct):
     """ Sets values from a dictionary in the current node.
         Non-recursive auxiliary function for setValuesFromDict
     """
     if 'data' in dct:
         self.data = QtGui.QColor(dct['data'])
示例#10
0
文件: constants.py 项目: xyt556/argos
COL_SHAPE_WIDTH = 90
COL_ELEM_TYPE_WIDTH = 50

# Spacing and margin in central widgets in pixels
CENTRAL_SPACING = 0
CENTRAL_MARGIN = 0

# Spacing and margin in dock widgets in pixels. Is now set in style sheet padding.

DOCK_SPACING = 0
DOCK_MARGIN = 0

if sys.platform == 'linux':
    MONO_FONT = 'Monospace'
    FONT_SIZE = 10
elif sys.platform == 'win32' or sys.platform == 'cygwin':
    MONO_FONT = 'Courier'
    FONT_SIZE = 10
elif sys.platform == 'darwin':
    MONO_FONT = 'Courier'
    FONT_SIZE = 13
else:
    MONO_FONT = 'Courier'
    FONT_SIZE = 13

COLOR_ERROR = '#FF0000'  # red

QCOLOR_REGULAR = QtGui.QColor('black')
QCOLOR_NOT_IMPORTED = QtGui.QColor('grey')
QCOLOR_ERROR = QtGui.QColor(COLOR_ERROR)
示例#11
0
文件: qtctis.py 项目: xyt556/argos
 def _nodeUnmarshall(self, data):
     """ Initializes itself non-recursively from data. Is called by unmarshall()
     """
     self.data = QtGui.QColor(data)
示例#12
0
    def __init__(self, tableInspector, nodeName):

        super(TableInspectorCti, self).__init__(nodeName)

        check_class(tableInspector, TableInspector)
        self.tableInspector = tableInspector

        # The defaultRowHeightCti and defaultColWidthCti are initialized with -1; they will get
        # the actual values in the TableInspector constructor.
        self.autoRowHeightCti = self.insertChild(
            BoolCti("auto row heights", False, childrenDisabledValue=True))
        self.defaultRowHeightCti = self.autoRowHeightCti.insertChild(
            IntCti("row height", -1, minValue=20, maxValue=500, stepSize=5))

        self.autoColWidthCti = self.insertChild(
            BoolCti("auto column widths", False, childrenDisabledValue=True))
        self.defaultColWidthCti = self.autoColWidthCti.insertChild(
            IntCti("column width", -1, minValue=20, maxValue=500, stepSize=5))

        self.insertChild(BoolCti("separate fields", True))
        self.insertChild(BoolCti("word wrap", False))

        self.encodingCti = self.insertChild(
            ChoiceCti(
                'encoding',
                editable=True,
                configValues=['utf-8', 'ascii', 'latin-1', 'windows-1252']))

        fmtCti = self.insertChild(GroupCti("format specifiers"))

        # Use '!r' as default for Python 2. This will convert the floats with repr(), which is
        # necessary because str() or an empty format string will only print 2 decimals behind the
        # point. In Python 3 this is not necessary: all relevant decimals are printed.
        numDefaultValue = 6 if six.PY2 else 0

        self.strFormatCti = fmtCti.insertChild(
            ChoiceCti("strings",
                      0,
                      editable=True,
                      completer=None,
                      configValues=[
                          '', 's', '!r', '!a', '10.10s', '_<15s', '_>15s',
                          "'str: {}'"
                      ]))

        self.intFormatCti = fmtCti.insertChild(
            ChoiceCti("integers",
                      0,
                      editable=True,
                      completer=None,
                      configValues=[
                          '', 'd', 'n', 'c', '#b', '#o', '#x', '!r', '8d',
                          '#8.4g', '_<10', '_>10', "'int: {}'"
                      ]))

        self.numFormatCti = fmtCti.insertChild(
            ChoiceCti("other numbers",
                      numDefaultValue,
                      editable=True,
                      completer=None,
                      configValues=[
                          '', 'f', 'g', 'n', '%', '!r', '8.3e', '#8.4g',
                          '_<15', '_>15', "'num: {}'"
                      ]))

        self.otherFormatCti = fmtCti.insertChild(
            ChoiceCti("other types",
                      0,
                      editable=True,
                      completer=None,
                      configValues=['', '!s', '!r', "'other: {}'"]))

        self.maskFormatCti = fmtCti.insertChild(
            ChoiceCti("missing data",
                      2,
                      editable=True,
                      completer=None,
                      configValues=['', "' '", "'--'", "'<masked>'", '!r']))

        self.fontCti = self.insertChild(
            FontCti(self.tableInspector,
                    "font",
                    defaultData=QtGui.QFont(MONO_FONT, FONT_SIZE)))

        self.dataColorCti = self.insertChild(
            ColorCti('text color', QtGui.QColor('#000000')))

        self.missingColorCti = self.insertChild(
            ColorCti('missing data color', QtGui.QColor('#B0B0B0')))

        self.horAlignCti = self.insertChild(
            ChoiceCti(
                'horizontal alignment',
                configValues=[
                    ALIGN_SMART, Qt.AlignLeft, Qt.AlignHCenter, Qt.AlignRight
                ],
                displayValues=['Type-dependent', 'Left', 'Center', 'Right']))
        # Qt.AlignJustify not included, it doesn't seem to do anything,

        self.verAlignCti = self.insertChild(
            ChoiceCti(
                'vertical alignment',
                defaultData=1,
                configValues=[Qt.AlignTop, Qt.AlignVCenter, Qt.AlignBottom],
                displayValues=['Top', 'Center', 'Bottom']))

        # Per pixel scrolling works better for large cells (e.g. containing XML strings).
        self.insertChild(
            ChoiceCti("scroll",
                      displayValues=["Per cell", "Per pixel"],
                      configValues=[
                          QtWidgets.QAbstractItemView.ScrollPerItem,
                          QtWidgets.QAbstractItemView.ScrollPerPixel
                      ]))