Can't modify html attribute

Visto 24 veces
Saltar al primer mensaje no leído

Nicolas Pinault

no leída,
9 may 2016, 16:53:529/5/16
a 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

no leída,
10 may 2016, 2:47:3310/5/16
a 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

no leída,
10 may 2016, 14:47:1910/5/16
a 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.
Responder a todos
Responder al autor
Reenviar
0 mensajes nuevos