Exemple #1
0
    def __init__(self):
        super(ColorPickerApplication, self).__init__()

        # The foreground color.
        self._foregroundColor = Color.BLACK  # The currently selected

        # The background color.
        self._backgroundColor = Color.WHITE  # The currently selected

        # The display box where the image is rendered.
        self._display = None

        self._mainLayout = None

        self._colorpicker1 = None
        self._colorpicker2 = None
        self._colorpicker3 = None
        self._colorpicker4 = None
        self._colorpicker5 = None
        self._colorpicker6 = None

        self._rgbVisible = True
        self._hsvVisible = True
        self._swaVisible = True
        self._historyVisible = True
        self._txtfieldVisible = True

        self._rgbBox = CheckBox('RGB tab visible')
        self._hsvBox = CheckBox('HSV tab visible')
        self._swaBox = CheckBox('Swatches tab visible')
        self._hisBox = CheckBox('History visible')
        self._txtBox = CheckBox('CSS field visible')
Exemple #2
0
    def createFieldByPropertyType(cls, typ):
        """Creates fields based on the property type.

        The default field type is L{TextField}. Other field types
        generated by this method:

          - B{Boolean}: L{CheckBox}.
          - B{Date}: L{DateField}(resolution: day).
          - B{IItem}: L{Form}.
          - B{default field type}: L{TextField}.

        @param typ:
                   the type of the property
        @return: the most suitable generic L{Field} for given type
        """
        from muntjac.ui.date_field import DateField  # FIXME: circular import
        from muntjac.ui.text_field import TextField
        from muntjac.ui.check_box import CheckBox
        from muntjac.ui.form import Form

        # Null typed properties can not be edited
        if typ is None:
            return None

        # IItem field
        if issubclass(typ, IItem):
            return Form()

        # Date field
        if issubclass(typ, datetime):
            df = DateField()
            df.setResolution(DateField.RESOLUTION_DAY)
            return df

        # Boolean field
        if issubclass(typ, bool):
            return CheckBox()

        return TextField()
    def init(self):
        mainWindow = Window('CodeMirror Sample Application')

        hl = GridLayout(2, 5)
        hl.setSpacing(True)
        mainWindow.addComponent(hl)

        # #1
        code = CodeMirror('Your Code', CodeMode.TEXT)
        code.setValue(self._SAMPLE_CODE)
        code.setWidth('500px')
        code.setHeight('350px')
        hl.addComponent(code)

        # #2
        code2 = CodeMirror('Your Code Too', CodeMode.PYTHON)
        code2.setValue(self._SAMPLE_CODE)
        #        code2.setWidth('400px')
        #        code2.setHeight('300px')
        hl.addComponent(code2)

        codeMode = Select('Select your mode')
        for cs in CodeMode.values():
            codeMode.addItem(cs)
        codeMode.setNewItemsAllowed(False)
        codeMode.setNullSelectionAllowed(False)
        codeMode.setImmediate(True)
        hl.addComponent(codeMode)

        l = CodeModeChangeListener(code, codeMode)
        codeMode.addListener(l, IValueChangeListener)
        codeMode.setValue(CodeMode.TEXT)

        codeMode = Select('Select your mode too')
        for cs in CodeMode.values():
            codeMode.addItem(cs)
        codeMode.setNewItemsAllowed(False)
        codeMode.setNullSelectionAllowed(False)
        codeMode.setImmediate(True)
        hl.addComponent(codeMode)

        l = CodeModeChangeListener(code2, codeMode)
        codeMode.addListener(l, IValueChangeListener)
        codeMode.setValue(CodeMode.PYTHON)

        codeTheme = Select('Select your theme')
        for ct in CodeTheme.values():
            codeTheme.addItem(ct)
        codeTheme.setNewItemsAllowed(False)
        codeTheme.setImmediate(True)
        hl.addComponent(codeTheme)

        l = CodeThemeChangeListener(code, codeTheme)
        codeTheme.addListener(l, IValueChangeListener)
        codeTheme.setValue(CodeTheme.DEFAULT)

        codeTheme = Select('Select your theme too')
        for ct in CodeTheme.values():
            codeTheme.addItem(ct)
        codeTheme.setNewItemsAllowed(False)
        codeTheme.setImmediate(True)
        hl.addComponent(codeTheme)

        l = CodeThemeChangeListener(code2, codeTheme)
        codeTheme.addListener(l, IValueChangeListener)
        codeTheme.setValue(CodeTheme.ECLIPSE)

        l = CopyClickListener(code, code2)
        hl.addComponent(Button('copy to -->', l))

        l = CopyClickListener(code2, code)
        hl.addComponent(Button('<- copy to', l))

        l = ShowLineNumbersListener(code)
        cb = CheckBox("Show line numbers", l)
        cb.setImmediate(True)
        hl.addComponent(cb)

        l = ShowLineNumbersListener(code2)
        cb = CheckBox("Show line numbers", l)
        cb.setImmediate(True)
        hl.addComponent(cb)

        self.setMainWindow(mainWindow)