Exemple #1
0
    def _format_bitmap_property(self, name, val, ntabs):
        "Return formatted bitmap/icon XRC property (as string)."

        if val.startswith('art:'):
            content = val[4:]
            elements = [item.strip() for item in content.split(',')]
            art_id = elements[0]
            art_client = elements[1]

            if art_client != 'wxART_OTHER':
                return common.format_xml_prop(name,
                                              '',
                                              ntabs,
                                              stock_id=art_id,
                                              stock_client=art_client)
            else:
                return common.format_xml_prop(name,
                                              u'',
                                              ntabs,
                                              stock_id=art_id)

        elif val.startswith('code:') or val.startswith(
                'empty:') or val.startswith('var:'):
            self._logger.warn(
                _('XRC: Unsupported bitmap statement "%s" for %s "%s"'), val,
                self.klass, self.name)
            return None

        return common.format_xml_prop(name, val, ntabs)
Exemple #2
0
    def write_property(self, name, val, output, ntabs):
        if not val:
            return

        if name in ['icon', 'bitmap']:
            prop = self._format_bitmap_property(name, val, ntabs)
        else:
            prop = common.format_xml_prop(name, val, ntabs)

        output.append(prop)
Exemple #3
0
    def write_property(self, name, val, output, ntabs):
        if not val:
            return

        if isinstance(val, np.BitmapProperty):
            # rename: no '..._bitmap' and some renames
            if name.endswith('_bitmap'):
                name = name[:-7]
            if name == "pressed": name = "selected"
            elif name == "current": name = "hover"

            prop = self._format_bitmap_property(name, val.get_value(), ntabs)
        else:
            prop = common.format_xml_prop(name, val, ntabs)

        output.append(prop)