Can't modify html attribute

24 views
Skip to first unread message

Nicolas Pinault

unread,
May 9, 2016, 4:53:52 PM5/9/16
to 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

unread,
May 10, 2016, 2:47:33 AM5/10/16
to 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

unread,
May 10, 2016, 2:47:19 PM5/10/16
to 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.
Reply all
Reply to author
Forward
0 new messages