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 38 attachment: patch-onload-decoration.diff (25.3 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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
Index: pymt/ui/simulator.py
===================================================================
--- pymt/ui/simulator.py (révision 640)
+++ pymt/ui/simulator.py (copie de travail)
@@ -6,10 +6,11 @@
from ..graphx import drawCircle, set_color
from ..mtpyglet import Tuio2DCursor
from factory import MTWidgetFactory
-from widgets.widget import MTWidget
+from widgets.widget import MTWidget, onload

class MTSimulator(MTWidget):
"""MTSimulator is a widget who generate touch event from mouse event"""
+ @onload
def __init__(self, output):
super(MTSimulator, self).__init__()
self.touches = {}
Index: pymt/ui/widgets/tabs.py
===================================================================
--- pymt/ui/widgets/tabs.py (révision 640)
+++ pymt/ui/widgets/tabs.py (copie de travail)
@@ -2,7 +2,7 @@
__all__ = ['MTTabs']

from ..factory import MTWidgetFactory
-from widget import MTWidget
+from widget import MTWidget, onload
from button import MTButton
from layout.boxlayout import MTBoxLayout

@@ -31,6 +31,7 @@
tabs.select('Tab2')

'''
+ @onload
def __init__(self, **kwargs):
super(MTTabs, self).__init__(**kwargs)
self.topbar = MTBoxLayout(orientation='horizontal')
Index: pymt/ui/widgets/radial.py
===================================================================
--- pymt/ui/widgets/radial.py (révision 640)
+++ pymt/ui/widgets/radial.py (copie de travail)
@@ -6,7 +6,7 @@
from ...graphx import drawCircle, set_color, gx_begin
from ...vector import Vector
from ..factory import MTWidgetFactory
-from widget import MTWidget
+from widget import MTWidget, onload

__all__ = ['MTVectorSlider']

@@ -42,7 +42,7 @@
`slider-color` : color
Color of the triangle
'''
-
+ @onload
def __init__(self, **kwargs):
super(MTVectorSlider, self).__init__(**kwargs)

Index: pymt/ui/widgets/svg.py
===================================================================
--- pymt/ui/widgets/svg.py (révision 640)
+++ pymt/ui/widgets/svg.py (copie de travail)
@@ -5,7 +5,7 @@
import pymt
from ...logger import pymt_logger
from ..factory import MTWidgetFactory
-from widget import MTWidget
+from widget import MTWidget, onload

class MTSvg(MTWidget):
'''Render an svg image
@@ -14,6 +14,7 @@
`filename` : str
Filename of image
'''
+ @onload
def __init__(self, **kwargs):
kwargs.setdefault('filename', None)
if kwargs.get('filename') is None:
Index: pymt/ui/widgets/buttonmatrix.py
===================================================================
--- pymt/ui/widgets/buttonmatrix.py (révision 640)
+++ pymt/ui/widgets/buttonmatrix.py (copie de travail)
@@ -4,7 +4,7 @@
from pyglet.gl import *
from ...graphx import set_color, drawRectangle,drawRoundedRectangle, gx_matrix
from ..factory import MTWidgetFactory
-from widget import MTWidget
+from widget import MTWidget, onload


class MTButtonMatrix(MTWidget):
@@ -13,6 +13,7 @@
draw_tile(i,j) draws the tile @ matrix position (i,j)
'''

+ @onload
def __init__(self,**kwargs):
kwargs.setdefault('matrix_size', (3,3))
kwargs.setdefault('border', 5)
Index: pymt/ui/widgets/multisliderwidget.py
===================================================================
--- pymt/ui/widgets/multisliderwidget.py (révision 640)
+++ pymt/ui/widgets/multisliderwidget.py (copie de travail)
@@ -2,9 +2,10 @@

from ...graphx import set_color, drawRectangle
from ..factory import MTWidgetFactory
-from widget import MTWidget
+from widget import MTWidget, onload

class MTMultiSlider(MTWidget):
+ @onload
def __init__(self, **kwargs):
kwargs.setdefault('sliders', 20)
kwargs.setdefault('size', (400,300))
Index: pymt/ui/widgets/dragable.py
===================================================================
--- pymt/ui/widgets/dragable.py (révision 640)
+++ pymt/ui/widgets/dragable.py (copie de travail)
@@ -1,10 +1,11 @@
__all__ = ['MTDragableWidget']

from ..factory import MTWidgetFactory
-from widget import MTWidget
+from widget import MTWidget, onload

class MTDragableWidget(MTWidget):
'''MTDragableWidget is a moveable widget over the window'''
+ @onload
def __init__(self, **kwargs):
super(MTDragableWidget, self).__init__(**kwargs)
self.state = ('normal', None)
Index: pymt/ui/widgets/popup.py
===================================================================
--- pymt/ui/widgets/popup.py (révision 640)
+++ pymt/ui/widgets/popup.py (copie de travail)
@@ -1,6 +1,7 @@
__all__ = ['MTPopup']

from modalwindow import MTModalWindow
+from widget import onload
from form.form import MTForm
from form.button import MTFormButton
from form.label import MTFormLabel
@@ -16,6 +17,7 @@
`content` : str, default is ''
Content of popup
'''
+ @onload
def __init__(self, **kwargs):
kwargs.setdefault('title', 'Information')
kwargs.setdefault('content', '')
Index: pymt/ui/widgets/innerwindow.py
===================================================================
--- pymt/ui/widgets/innerwindow.py (révision 640)
+++ pymt/ui/widgets/innerwindow.py (copie de travail)
@@ -11,11 +11,13 @@
from scatter import MTScatterWidget
from button import MTImageButton
from layout.boxlayout import MTBoxLayout
+from widget import onload

iconPath = os.path.join(os.path.dirname(pymt.__file__), 'data', 'icons', '')

class MTInnerWindow(MTScatterWidget):

+ @onload
def __init__(self, **kargs):
super(MTInnerWindow, self).__init__(**kargs)

Index: pymt/ui/widgets/xmlwidget.py
===================================================================
--- pymt/ui/widgets/xmlwidget.py (révision 640)
+++ pymt/ui/widgets/xmlwidget.py (copie de travail)
@@ -3,9 +3,10 @@
from xml.dom import minidom, Node
from ...logger import pymt_logger
from ..factory import MTWidgetFactory
-from widget import MTWidget
+from widget import MTWidget, onload

class XMLWidget(MTWidget):
+ @onload
def __init__(self, xml=None):
MTWidget.__init__(self)
if xml is not None:
Index: pymt/ui/widgets/scatter.py
===================================================================
--- pymt/ui/widgets/scatter.py (révision 640)
+++ pymt/ui/widgets/scatter.py (copie de travail)
@@ -8,7 +8,7 @@
from ..animation import Animation, AnimationAlpha
from ..factory import MTWidgetFactory
from svg import MTSvg
-from widget import MTWidget
+from widget import MTWidget, onload

class MTScatterWidget(MTWidget):
'''MTScatterWidget is a scatter widget based on MTWidget
@@ -27,6 +27,7 @@
`do_scale` : boolean, default to True
Set to False for disabling scale
'''
+ @onload
def __init__(self, **kwargs):
kwargs.setdefault('rotation', 0.0)
kwargs.setdefault('translation', (0,0))
@@ -354,6 +355,7 @@
`loader` : Loader instance
Use the loader to load image
'''
+ @onload
def __init__(self, **kwargs):
# Preserve this way to do
# Later, we'll give another possibility, like using a loader...
@@ -384,6 +386,7 @@
`filename` : str
Filename of image
'''
+ @onload
def __init__(self, **kwargs):
kwargs.setdefault('filename', None)
if kwargs.get('filename') is None:
Index: pymt/ui/widgets/object.py
===================================================================
--- pymt/ui/widgets/object.py (révision 640)
+++ pymt/ui/widgets/object.py (copie de travail)
@@ -5,10 +5,11 @@
from ...graphx import drawRectangle, gx_matrix, gx_begin, set_color
from ..factory import MTWidgetFactory
from math import pi
-from widget import MTWidget
+from widget import MTWidget, onload

class MTObjectWidget(MTWidget):
'''MTObjectWidget is a widget who draw an object on table'''
+ @onload
def __init__(self, **kwargs):
super(MTObjectWidget, self).__init__(**kwargs)
self.state = ('normal', None)
Index: pymt/ui/widgets/videowidget.py
===================================================================
--- pymt/ui/widgets/videowidget.py (révision 640)
+++ pymt/ui/widgets/videowidget.py (copie de travail)
@@ -8,6 +8,7 @@
from pyglet.media import *
from ...graphx import set_color, drawRectangle, DO, gx_matrix
from ..factory import MTWidgetFactory
+from widget import onload
from button import MTImageButton
from slider import MTSlider
from scatter import MTScatterWidget
@@ -17,6 +18,7 @@

class MTVideoPlayPause(MTImageButton):
'''MTVideoPlayPause is a dynamic play/pause button of the video widget'''
+ @onload
def __init__(self, **kwargs):
kwargs.setdefault('filename', iconPath + 'videoWidgetPlay.png')
kwargs.setdefault('filename_pause', iconPath + 'videoWidgetPause.png')
@@ -47,6 +49,7 @@

class MTVideoMute(MTImageButton):
'''MTVideoMute is a mute button class of the video widget'''
+ @onload
def __init__(self, **kwargs):
kwargs.setdefault('filename', iconPath + 'videoWidgetMute.png')
kwargs.setdefault('player', None)
@@ -67,6 +70,7 @@

class MTVideoTimeline(MTSlider):
'''MTVideoTimeline is a part of the video widget which tracks the video playback'''
+ @onload
def __init__(self, **kwargs):
kwargs.setdefault('player', None)
kwargs.setdefault('duration', 100)
@@ -134,6 +138,7 @@
Filename of video

'''
+ @onload
def __init__(self, **kwargs):
kwargs.setdefault('video', None)
if kwargs.get('video') is None:
Index: pymt/ui/widgets/button.py
===================================================================
--- pymt/ui/widgets/button.py (révision 640)
+++ pymt/ui/widgets/button.py (copie de travail)
@@ -5,7 +5,7 @@
from pyglet.text import Label
from ...graphx import drawRectangle, drawRoundedRectangle, gx_matrix, GlDisplayList, set_color
from ..factory import MTWidgetFactory
-from widget import MTWidget
+from widget import MTWidget, onload

class MTButton(MTWidget):
'''MTButton is a button implementation using MTWidget
@@ -26,6 +26,7 @@
`border_radius`: float, default is 0
Radius of background border
'''
+ @onload
def __init__(self, **kwargs):
kwargs.setdefault('label', '')
kwargs.setdefault('anchor_x', 'center')
@@ -125,6 +126,7 @@

class MTToggleButton(MTButton):
'''Toggle button implementation, based on MTButton'''
+ @onload
def __init__(self, **kwargs):
kwargs.setdefault('label', 'ToggleButton')
super(MTToggleButton, self).__init__(**kwargs)
@@ -158,6 +160,7 @@
`scale` : float, default is 1.0
Scaling of image, default is 100%, ie 1.0
'''
+ @onload
def __init__(self, **kwargs):
# Preserve this way to do
# Later, we'll give another possibility, like using a loader...
Index: pymt/ui/widgets/form/button.py
===================================================================
--- pymt/ui/widgets/form/button.py (révision 640)
+++ pymt/ui/widgets/form/button.py (copie de travail)
@@ -2,6 +2,7 @@

from ....graphx import set_color, drawRoundedRectangle
from ...factory import MTWidgetFactory
+from ..widget import onload
from label import MTFormLabel

class MTFormButton(MTFormLabel):
@@ -17,7 +18,7 @@
`on_release`
Fired when button is released
'''
-
+ @onload
def __init__(self, **kwargs):
super(MTFormButton, self).__init__(**kwargs)
self.register_event_type('on_press')
Index: pymt/ui/widgets/form/input.py
===================================================================
--- pymt/ui/widgets/form/input.py (révision 640)
+++ pymt/ui/widgets/form/input.py (copie de travail)
@@ -4,11 +4,12 @@
from ....graphx import set_color, drawRectangle
from ...factory import MTWidgetFactory
from ..vkeyboard import MTTextInput
+from ..widget import onload

class MTFormInput(MTTextInput):
'''Form input : a one-line text input, with virtual-keyboard support
'''
-
+ @onload
def __init__(self, **kwargs):
kwargs.setdefault('font_size', 16)
super(MTFormInput, self).__init__(**kwargs)
Index: pymt/ui/widgets/form/label.py
===================================================================
--- pymt/ui/widgets/form/label.py (révision 640)
+++ pymt/ui/widgets/form/label.py (copie de travail)
@@ -3,6 +3,7 @@
from abstract import MTAbstractFormWidget
from pyglet.text import Label
from ...factory import MTWidgetFactory
+from ..widget import onload

class MTFormLabel(MTAbstractFormWidget):
'''Form label : a simple text label with aligmenent support
@@ -25,7 +26,7 @@
`valign` : str, default is 'center'
Vertical alignement, can be 'top', 'center', 'bottom'
'''
-
+ @onload
def __init__(self, **kwargs):
kwargs.setdefault('label', '')
kwargs.setdefault('halign', 'center')
Index: pymt/ui/widgets/form/slider.py
===================================================================
--- pymt/ui/widgets/form/slider.py (révision 640)
+++ pymt/ui/widgets/form/slider.py (copie de travail)
@@ -4,10 +4,12 @@
from ...factory import MTWidgetFactory
from ..slider import MTSlider
from ..layout import MTBoxLayout
+from ..widget import onload
from abstract import MTAbstractFormWidget
from label import MTFormLabel

class MTFormSlider(MTAbstractFormWidget):
+ @onload
def __init__(self, **kwargs):
kwargs.setdefault('min', 0)
kwargs.setdefault('max', 10)
Index: pymt/ui/widgets/form/abstract.py
===================================================================
--- pymt/ui/widgets/form/abstract.py (révision 640)
+++ pymt/ui/widgets/form/abstract.py (copie de travail)
@@ -1,11 +1,11 @@
__all__ = ['MTAbstractFormWidget']

-from ..widget import MTWidget
+from ..widget import MTWidget, onload

class MTAbstractFormWidget(MTWidget):
'''Abstract form widget. Base class used to implement any form widget.
'''
-
+ @onload
def __init__(self, **kwargs):
if self.__class__ == MTAbstractFormWidget:
raise NotImplementedError, 'class MTAbstractFormWidget is abstract'
Index: pymt/ui/widgets/form/form.py
===================================================================
--- pymt/ui/widgets/form/form.py (révision 640)
+++ pymt/ui/widgets/form/form.py (copie de travail)
@@ -3,6 +3,7 @@
from abstract import MTAbstractFormWidget
from ....graphx import set_color, drawRoundedRectangle, drawRectangle
from ...factory import MTWidgetFactory
+from ..widget import onload

class MTForm(MTAbstractFormWidget):
'''Form container : with a basic layout, you can add form widget in it,
@@ -14,7 +15,7 @@
`border_radius` : int, default to 0
Border radius of background
'''
-
+ @onload
def __init__(self, **kwargs):
kwargs.setdefault('layout', None)
kwargs.setdefault('border_radius', 0)
Index: pymt/ui/widgets/form/checkbox.py
===================================================================
--- pymt/ui/widgets/form/checkbox.py (révision 640)
+++ pymt/ui/widgets/form/checkbox.py (copie de travail)
@@ -2,6 +2,7 @@

from ....graphx import set_color, drawRectangle
from ...factory import MTWidgetFactory
+from ..widget import onload
from abstract import MTAbstractFormWidget
from pyglet.gl import GL_LINE_LOOP

@@ -18,7 +19,7 @@
`on_check`
Fired when checkbox change state
'''
-
+ @onload
def __init__(self, **kwargs):
kwargs.setdefault('halign', 'center')
kwargs.setdefault('valign', 'center')
Index: pymt/ui/widgets/label.py
===================================================================
--- pymt/ui/widgets/label.py (révision 640)
+++ pymt/ui/widgets/label.py (copie de travail)
@@ -3,7 +3,7 @@

from ...graphx import drawLabel
from ..factory import MTWidgetFactory
-from widget import MTWidget
+from widget import MTWidget, onload

class MTLabel(MTWidget):
'''A simple label
@@ -12,6 +12,7 @@
`font-size` : int
Size of font
'''
+ @onload
def __init__(self, **kwargs):
kwargs.setdefault('text', 'MTLabel')
super(MTLabel, self).__init__(**kwargs)
Index: pymt/ui/widgets/gesturewidget.py
===================================================================
--- pymt/ui/widgets/gesturewidget.py (révision 640)
+++ pymt/ui/widgets/gesturewidget.py (copie de travail)
@@ -2,9 +2,10 @@

from ...gesture import Gesture
from ..factory import MTWidgetFactory
-from widget import MTWidget
+from widget import MTWidget, onload

class MTGestureWidget(MTWidget):
+ @onload
def __init__(self):
super(MTGestureWidget, self).__init__()
self.register_event_type('on_gesture')
Index: pymt/ui/widgets/slider.py
===================================================================
--- pymt/ui/widgets/slider.py (révision 640)
+++ pymt/ui/widgets/slider.py (copie de travail)
@@ -5,7 +5,7 @@
from pyglet.gl import *
from ...graphx import drawRectangle, drawCircle, drawLabel, set_color
from ..factory import MTWidgetFactory
-from widget import MTWidget
+from widget import MTWidget, onload

class MTSlider(MTWidget):
'''MTSlider is an implementation of a scrollbar using MTWidget.
@@ -27,6 +27,7 @@
`bg-color` : color
Background color of the slider
'''
+ @onload
def __init__(self, **kwargs):
kwargs.setdefault('min', 0)
kwargs.setdefault('max', 100)
@@ -132,6 +133,7 @@
`bg-color` : color
Background color of the slider
'''
+ @onload
def __init__(self, **kwargs):
kwargs.setdefault('min_x', 20)
kwargs.setdefault('max_x', 100)
@@ -250,6 +252,7 @@
`bg-color` : color
Background color of the slider
'''
+ @onload
def __init__(self, **kwargs):
kwargs.setdefault('min', 0)
kwargs.setdefault('max', 100)
Index: pymt/ui/widgets/widget.py
===================================================================
--- pymt/ui/widgets/widget.py (révision 640)
+++ pymt/ui/widgets/widget.py (copie de travail)
@@ -1,6 +1,6 @@
__all__ = ['getWidgetById',
'event_stats_activate', 'event_stats_print',
- 'MTWidget'
+ 'MTWidget', 'onload'
]

import sys
@@ -35,6 +35,16 @@
for k in _event_stats:
pymt_logger.info('%6d: %s' % (_event_stats[k], k))

+def onload(f):
+ def onload_init(*args, **kwargs):
+ inst = args[0]
+ if hasattr(inst, '__onload__'):
+ return f(*args, **kwargs)
+ inst.__setattr__('__onload__', True)
+ f(*args, **kwargs)
+ inst.dispatch_event('on_load')
+ return onload_init
+
class MTWidget(pyglet.event.EventDispatcher):
'''Global base for any multitouch widget.
Implement event for mouse, object, touch and animation.
@@ -84,6 +94,8 @@
'on_animation_reset',
'on_animation_start'
]
+
+ @onload
def __init__(self, **kwargs):
kwargs.setdefault('pos', (0, 0))
kwargs.setdefault('x', None)
@@ -121,6 +133,7 @@

self.register_event_type('on_resize')
self.register_event_type('on_move')
+ self.register_event_type('on_load')

if kwargs.get('x'):
self.x = kwargs.get('x')
Index: pymt/ui/widgets/modalwindow.py
===================================================================
--- pymt/ui/widgets/modalwindow.py (révision 640)
+++ pymt/ui/widgets/modalwindow.py (copie de travail)
@@ -3,14 +3,14 @@

from ...graphx import set_color, drawRectangle
from ..factory import MTWidgetFactory
-from widget import MTWidget
+from widget import MTWidget, onload

class MTModalWindow(MTWidget):
'''A static window, non-movable, with a dark background.
Ideal to add popup or some other things. ModalWindow capture
all touchs events.
'''
-
+ @onload
def __init__(self, **kwargs):
kwargs.setdefault('color', (0,0,0,1))
super(MTModalWindow, self).__init__(**kwargs)
Index: pymt/ui/widgets/colorpick.py
===================================================================
--- pymt/ui/widgets/colorpick.py (révision 640)
+++ pymt/ui/widgets/colorpick.py (copie de travail)
@@ -3,7 +3,7 @@
from pyglet.gl import *
from ...graphx import set_color, drawRectangle
from ..factory import MTWidgetFactory
-from widget import MTWidget
+from widget import MTWidget, onload
from slider import MTSlider

class MTColorPicker(MTWidget):
@@ -17,6 +17,7 @@
`targets` : list, default is []
List of widget to be affected by change
'''
+ @onload
def __init__(self, **kwargs):
kwargs.setdefault('min', 0)
kwargs.setdefault('max', 255)
Index: pymt/ui/widgets/layout/abstractlayout.py
===================================================================
--- pymt/ui/widgets/layout/abstractlayout.py (révision 640)
+++ pymt/ui/widgets/layout/abstractlayout.py (copie de travail)
@@ -1,6 +1,6 @@
__all__ = ['MTAbstractLayout']

-from ..widget import MTWidget
+from ..widget import MTWidget, onload

class MTAbstractLayout(MTWidget):
'''Abstract layout. Base class used to implement layout.
@@ -15,7 +15,7 @@
`on_content_resize`
Fired when content_width or content_height have changed
'''
-
+ @onload
def __init__(self, **kwargs):
if self.__class__ == MTAbstractLayout:
raise NotImplementedError, 'class MTAbstractLayout is abstract'
Index: pymt/ui/widgets/layout/gridlayout.py
===================================================================
--- pymt/ui/widgets/layout/gridlayout.py (révision 640)
+++ pymt/ui/widgets/layout/gridlayout.py (copie de travail)
@@ -2,6 +2,7 @@

from abstractlayout import MTAbstractLayout
from ...factory import MTWidgetFactory
+from ..widget import onload

class MTGridLayout(MTAbstractLayout):
'''Grid layout arrange item in a matrix.
@@ -18,7 +19,7 @@
`uniform_height` : bool, default to False
Try to have same height for all children
'''
-
+ @onload
def __init__(self, **kwargs):
kwargs.setdefault('cols', None)
kwargs.setdefault('rows', None)
Index: pymt/ui/widgets/layout/boxlayout.py
===================================================================
--- pymt/ui/widgets/layout/boxlayout.py (révision 640)
+++ pymt/ui/widgets/layout/boxlayout.py (copie de travail)
@@ -2,6 +2,7 @@

from abstractlayout import MTAbstractLayout
from ...factory import MTWidgetFactory
+from ..widget import onload

class MTBoxLayout(MTAbstractLayout):
'''Box layout can arrange item in horizontal or vertical orientation.
@@ -22,7 +23,7 @@
`invert_y` : bool, default to False
Invert Y axis
'''
-
+ @onload
def __init__(self, **kwargs):
kwargs.setdefault('orientation', 'horizontal')
kwargs.setdefault('spacing', 1)
Index: pymt/ui/widgets/kinetic.py
===================================================================
--- pymt/ui/widgets/kinetic.py (révision 640)
+++ pymt/ui/widgets/kinetic.py (copie de travail)
@@ -10,7 +10,7 @@
from ...graphx import set_color, drawRectangle
from ..factory import MTWidgetFactory
from ...vector import Vector
-from widget import MTWidget
+from widget import MTWidget, onload

class MTKinetic(MTWidget):
'''Kinetic container.
@@ -40,6 +40,7 @@
`velstop` : float, default to 1.0
The distance of velocity vector to stop animation
'''
+ @onload
def __init__(self, **kwargs):
kwargs.setdefault('no_css', True)
kwargs.setdefault('friction', 1.2)
@@ -125,6 +126,7 @@
pixels(so we know they aren't scrolling) it fires a
callback and passes the clicked text as the argument.
'''
+ @onload
def __init__(self, **kwargs):
kwargs.setdefault('font_name', 'Tahoma')
kwargs.setdefault('font_size', 16)
Index: pymt/ui/widgets/vkeyboard.py
===================================================================
--- pymt/ui/widgets/vkeyboard.py (révision 640)
+++ pymt/ui/widgets/vkeyboard.py (copie de travail)
@@ -7,6 +7,7 @@
from ..factory import MTWidgetFactory
from ..animation import Animation, AnimationAlpha
from button import MTButton
+from widget import onload
from scatter import MTScatterWidget
from layout.boxlayout import MTBoxLayout

@@ -16,7 +17,7 @@
A text input widget is a simple label widget that will pop up a virtual keyboard when touched
any input of the virtual keyboard will then have effect on the TextInput widget
'''
-
+ @onload
def __init__(self, **kwargs):
kwargs.setdefault('font_bold', True)
kwargs.setdefault('anchor_x', 'left')
@@ -101,6 +102,7 @@

class MTKeyButton(MTButton):
'''Internal Class used in MTVKeyboard'''
+ @onload
def __init__(self, keyboard, **kwargs):
super(MTKeyButton, self).__init__(**kwargs)
self.keyboard = keyboard
@@ -146,6 +148,7 @@
_row_keys = ['1234567890-=', 'qwertyuiop', 'asdfghjkl;', 'zxcvbnm,./']
_row_keyscaps = ['!@#$%^&*()_+', 'QWERTYUIOP', 'ASDFGHJKL:', 'ZXCVBNM<>?']

+ @onload
def __init__(self, text_widget, pos=(0,0)):
MTScatterWidget.__init__(self, pos=(0,0), size=(400,200))

Index: pymt/ui/window.py
===================================================================
--- pymt/ui/window.py (révision 640)
+++ pymt/ui/window.py (copie de travail)
@@ -256,7 +256,6 @@
glFrustum(-width/2, width/2, -height/2, height/2, 0.1, 1000)
glScalef(5000,5000,1)
glTranslatef(-width/2,-height/2,-500)
-
glMatrixMode(gl.GL_MODELVIEW)


Powered by Google Project Hosting