forked from jaraco/cssutils
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathproperties_with_same_name.py
More file actions
41 lines (33 loc) · 1.45 KB
/
properties_with_same_name.py
File metadata and controls
41 lines (33 loc) · 1.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
"""shows CSSStyleDeclaration multivalue property examples"""
import cssutils
print("\n**SameNamePropertyList is replaced with style.getProperties() from 0.9.4**")
cssutils.ser.prefs.keepComments = False # remove for now
cssText = ''' background: white url(paper.png) scroll; /* for all UAs */
background: white url(ledger.png) fixed; /* for UAs that do fixed backgrounds */
'''
print("\n>>> # cssText")
print(cssText)
print(">>> style = cssutils.css.CSSStyleDeclaration(cssText=cssText)")
style = cssutils.css.CSSStyleDeclaration(cssText=cssText)
print('>>> print style.cssText')
print(style.cssText)
print("\n>>> cssutils.ser.prefs.keepAllProperties = True # output all values")
cssutils.ser.prefs.keepAllProperties = True # output all values
print('>>> style.cssText # with keepAllProperties==True:')
print(style.cssText)
print()
print(">>> # NEW METHOD getProperties")
print(">>> proplist = style.getProperties('background', all=True)")
proplist = style.getProperties('background', all=True)
print(">>> proplist\n", proplist)
print(">>> for prop in proplist: print '\\t', prop.value")
for prop in proplist:
print("\t", prop.value)
print()
print(">>> # overwrite the current property, to overwrite all iterate over proplist")
print(">>> style.setProperty('background', 'red')")
style.setProperty('background', 'red')
print(">>> style.getPropertyValue('background')")
print(style.getPropertyValue('background'))
print(">>> style.cssText")
print(style.cssText)