My favorites | Sign in
Project Home Downloads Issues
READ-ONLY: This project has been archived. For more information see this post.
Search
for
  Advanced search   Search tips   Subscriptions

Issue 105 attachment: hg-push.txt (6.1 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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
comparing with https://pymt.googlecode.com/hg/ pymt
searching for changes
changeset: 1219:8d0ba7416e74
tag: tip
user: damienmiencho
date: Tue Sep 08 12:15:03 2009 +0200
files: pymt/ui/colors.py pymt/ui/widgets/widget.py pymt/ui/window.py
description:
cssstyle update.
change 1: In the style sheet, the class selector can now be either MTWidget or widget.
Eg: MTWidget { bg-color: #ffffff; } is equivalent to widget{ bg-color: #ffffff; }
change 2: In the style sheet, we now support styling by id.
Eg: #mybutton { bg-color: #ffffff; }


diff -r 303b2f665278 -r 8d0ba7416e74 pymt/ui/colors.py
--- a/pymt/ui/colors.py Tue Sep 08 11:57:17 2009 +0200
+++ b/pymt/ui/colors.py Tue Sep 08 12:15:03 2009 +0200
@@ -265,6 +265,8 @@
while parent and len(parent):
# take only the first parent...
widget_classes.append(get_truncated_classname(parent[0].__name__))
+ # use the MTWidget or just widget version for the name
+ widget_classes.append(parent[0].__name__)
# don't back too far
if parent[0].__name__ in ['MTWidget', 'MTWindow']:
break
@@ -276,9 +278,9 @@
if not hasattr(widget, 'cls'):
widget.__setattr__('cls', '')
if type(widget.cls) == str:
- idwidget = str(widget.__class__) + ':' + widget.cls
+ idwidget = str(widget.__class__) + ':' + widget.cls + ':' + `widget._id`
else:
- idwidget = str(widget.__class__) + ':' + '.'.join(widget.cls)
+ idwidget = str(widget.__class__) + ':' + '.'.join(widget.cls) + `widget._id`
return idwidget

css_cache = {}
@@ -318,6 +320,15 @@
if s.element is not None:
if s.element[1] not in reversed(widget_classes):
continue
+
+ if s.specificity[1] == 1:
+ cssid = s.selectorText.split('#')[1:][0]
+ if not hasattr(widget, "_id"):
+ continue
+
+ if not(widget._id == cssid):
+ continue
+
if s.specificity[2] == 1:
cssclass = s.selectorText.split('.')[1:]
if type(widget.cls) == str:
diff -r 303b2f665278 -r 8d0ba7416e74 pymt/ui/widgets/widget.py
--- a/pymt/ui/widgets/widget.py Tue Sep 08 11:57:17 2009 +0200
+++ b/pymt/ui/widgets/widget.py Tue Sep 08 12:15:03 2009 +0200
@@ -122,7 +122,8 @@
self._id = None
if 'id' in kwargs:
self.id = kwargs.get('id')
-
+ self._id = self.id
+
pyglet.event.EventDispatcher.__init__(self)

# Registers events
@@ -135,7 +136,7 @@
self._x, self._y = kwargs.get('pos')
self._width, self._height = kwargs.get('size')
self.animations = []
- self.visible = kwargs.get('visible')
+ self.visible = kwargs.get('visible')
self.draw_children = kwargs.get('draw_children')

# cache for get_parent_window()
diff -r 303b2f665278 -r 8d0ba7416e74 pymt/ui/window.py
--- a/pymt/ui/window.py Tue Sep 08 11:57:17 2009 +0200
+++ b/pymt/ui/window.py Tue Sep 08 12:15:03 2009 +0200
@@ -51,6 +51,8 @@
kwargs.setdefault('show_fps', False)
kwargs.setdefault('style', {})

+ self._id = None
+
# apply styles for window
self.cssstyle = {}
style = css_get_style(widget=self)

changeset: 1218:303b2f665278
user: damienmiencho
date: Tue Sep 08 11:57:17 2009 +0200
files: pymt/ui/widgets/xmlwidget.py
description:
Provide the XML attributes as **kwargs to the __init__ function.
This fix a bug in initializing the cssstyles with XMLWidget.


diff -r faf2e5c211f5 -r 303b2f665278 pymt/ui/widgets/xmlwidget.py
--- a/pymt/ui/widgets/xmlwidget.py Sun Sep 06 20:43:04 2009 +0200
+++ b/pymt/ui/widgets/xmlwidget.py Tue Sep 08 11:57:17 2009 +0200
@@ -43,26 +43,28 @@
if node.nodeType == Node.ELEMENT_NODE:
class_name = node.nodeName

+ keyval={}
+ #set attributes
+ for (name, value) in node.attributes.items():
+ try:
+ keyval[str(name)]=eval(value)
+ except NameError:
+ #if it is a NameError its probably a regular string property like e.g. id
+ #if xml is e.g. <... name="myval" ...> it breaks (had to be: name="'myval'")\
+ #so lets try with just the string value itself
+ keyval[str(name)]=value
+ pymt_logger.warning('NameError when setting %s on %s. Defaulting to string value!' % (name, class_name))
+ except:
+ pymt_logger.exception('unable to set %s on %s' % (name, class_name))
+ raise
+
#create widget
try:
- nodeWidget = MTWidgetFactory.get(class_name)()
+ nodeWidget = MTWidgetFactory.get(class_name)(**keyval)
except:
pymt_logger.exception('unable to create widget %s' % class_name)
raise

- #set attributes
- for (name, value) in node.attributes.items():
- try:
- nodeWidget.__setattr__(name, eval(value))
- except NameError:
- #if it is a NameError its probably a regular string property like e.g. id
- #if xml is e.g. <... name="myval" ...> it breaks (had to be: name="'myval'")\
- #so lets try with just the string value itself
- nodeWidget.__setattr__(name, value)
- pymt_logger.warning('NameError when setting %s on %s. Defaulting to string value!' % (name, class_name))
- except:
- pymt_logger.exception('unable to set %s on %s' % (name, class_name))
- raise

#add child widgets
for c in node.childNodes:

[command completed successfully]
Powered by Google Project Hosting