Can't modify html attribute

24 vues
Accéder directement au premier message non lu

Nicolas Pinault

non lue,
9 mai 2016, 16:53:5209/05/2016
à bry...@googlegroups.com
Hi,

Here is what I am trying :

self.win = html.DIV(style={...})
...
self.win.style["backgroundColor"] = colour

I get the following error :
Traceback (most recent call last):
module wx.window line 37
self.win.style["backgroundColor"] = colour
AttributeError: 'CSSProperty' object has no attribute '__setitem__'

Does this mean I can't modify style attribute ?

Regards,
Nicolas

Kiko

non lue,
10 mai 2016, 02:47:3310/05/2016
à bry...@googlegroups.com
The CSSProperty is a class (not a dict type). You have __setattr__ available, but not __setitem__, so you can do:
self.win.style.backgroundColor = colour
 

Regards,
Nicolas

--
You received this message because you are subscribed to the Google Groups "brython" group.
To unsubscribe from this group and stop receiving emails from it, send an email to brython+u...@googlegroups.com.
To post to this group, send email to bry...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/brython/ede37202-183b-fe55-7bf7-1ea5cdaae498%40famillepinault.fr.
For more options, visit https://groups.google.com/d/optout.

Nicolas Pinault

non lue,
10 mai 2016, 14:47:1910/05/2016
à bry...@googlegroups.com
Le 10/05/2016 à 08:47, Kiko a écrit :


2016-05-09 22:53 GMT+02:00 Nicolas Pinault <d...@famillepinault.fr>:
Hi,

Here is what I am trying :

self.win = html.DIV(style={...})
...
self.win.style["backgroundColor"] = colour 

I get the following error :
Traceback (most recent call last):
  module wx.window line 37
    self.win.style["backgroundColor"] = colour
AttributeError: 'CSSProperty' object has no attribute '__setitem__'

Does this mean I can't modify style attribute ?

The CSSProperty is a class (not a dict type). You have __setattr__ available, but not __setitem__, so you can do:
self.win.style.backgroundColor = colour
Ok. Thanks for your help.
 

Regards,
Nicolas

--
You received this message because you are subscribed to the Google Groups "brython" group.
To unsubscribe from this group and stop receiving emails from it, send an email to brython+u...@googlegroups.com.
To post to this group, send email to bry...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/brython/ede37202-183b-fe55-7bf7-1ea5cdaae498%40famillepinault.fr.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "brython" group.
To unsubscribe from this group and stop receiving emails from it, send an email to brython+u...@googlegroups.com.
To post to this group, send email to bry...@googlegroups.com.
Répondre à tous
Répondre à l'auteur
Transférer
0 nouveau message