GeezerVison is showing github.com — clutter: nicer wrapper around actor_animatev · leonhd/rpythonic@28d3f3f
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: examples/clutter-animation.py +7-24Lines changed: 7 additions & 24 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 34 | 34 |
| 35 | 35 | def sayhi(b, actor): | 36 | 36 | print('hello world', actor) | 37 | | - if 1: | 38 | | - val = gtk.GValue() | 39 | | - gtype = gtk.g_type_from_name('gdouble') | 40 | | - assert gtype | 41 | | - print('GTYPE',gtype) | 42 | | - val = gtk.g_value_init( val, gtype ) | 43 | | - val.set_double( 2.0 ) | 44 | | - print('VAL',val) | 45 | | - anim = actor.animatev( | 46 | | - clutter.CLUTTER_LINEAR, 4000, | 47 | | - 1, #num properties | 48 | | - ctypes.pointer(ctypes.c_char_p('scale-x')), val, | 49 | | - ) | 50 | | - print(anim) | 51 | | - #actor.set_scale( 2.0, 1.0 ) | | 37 | + if actor.get_scale()[0] < 1.0: scale = 2.0 | | 38 | + else: scale = 0.75 | | 39 | + actor.animate( | | 40 | + clutter.CLUTTER_LINEAR, 4000, | | 41 | + scale_x=scale, | | 42 | + ) | 52 | 43 |
| 53 | 44 | for i in range(10): | 54 | 45 | button = gtk.Button('Click me') | 55 | 46 | button.connect('clicked', sayhi, gact) | 56 | | - #vbox.pack_end(button, False, False, 0) | 57 | | - #gact.set_size(100, 100) | 58 | | - #gact.set_anchor_point(50, 50) | 59 | | - #gact.set_position(150, 150) | 60 | | - #gact.set_rotation(clutter.CLUTTER_Z_AXIS, 80.0, 0, 0, 0) | 61 | 47 | box.pack_start( button ) | 62 | | -box.show_all() | | 48 | +box.show_all() # required | 63 | 49 |
| 64 | 50 | button = gtk.Button('gtk-ok') | 65 | 51 | button.set_use_stock(True) | @@ -73,6 +59,3 @@ def sayhi(b, actor): | 73 | 59 |
| 74 | 60 | print('exit') | 75 | 61 |
| 76 | | -#if __name__ == '__main__': main() | 77 | | - | 78 | | - |
Collapse file Copy file name to clipboardExpand all lines: examples/libclutter_gtk/__init__.py +30-1Lines changed: 30 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -78264,6 +78264,35 @@ def connect( ptr, name, func, *args ): | 78264 | 78264 | if 'GtkSocket' in globals(): # this is missing with Clutter | 78265 | 78265 | GTK_WIDGET_CLASSES[ GtkSocket ] = gtk_socket_new | 78266 | 78266 |
| | 78267 | +if 'ClutterActor' in globals(): | | 78268 | + def _clutter_actor_animate_helper(self, atype, ms, **kw): | | 78269 | + anims = {} | | 78270 | + for prop in kw: | | 78271 | + val = GValue() | | 78272 | + gtype = g_type_from_name('gdouble') | | 78273 | + assert gtype | | 78274 | + val = g_value_init( val, gtype ) | | 78275 | + val.set_double( kw[prop] ) | | 78276 | + anims[prop] = self.animatev( | | 78277 | + atype, ms, | | 78278 | + 1, #num properties | | 78279 | + ctypes.pointer(ctypes.c_char_p(prop)), val, | | 78280 | + ) | | 78281 | + return anims | | 78282 | + ClutterActor.animate = _clutter_actor_animate_helper | | 78283 | + | | 78284 | + def _get_(self): | | 78285 | + x = ctypes.pointer( ctypes.c_double() ) | | 78286 | + y = ctypes.pointer( ctypes.c_double() ) | | 78287 | + self.clutter_actor_get_scale( x, y ) | | 78288 | + return x.contents.value, y.contents.value | | 78289 | + ClutterActor.get_scale = _get_ | | 78290 | + def _get_(self): | | 78291 | + x = ctypes.pointer( ctypes.c_double() ) | | 78292 | + y = ctypes.pointer( ctypes.c_double() ) | | 78293 | + self.clutter_actor_get_size( x, y ) | | 78294 | + return x.contents.value, y.contents.value | | 78295 | + ClutterActor.get_size = _get_ | 78267 | 78296 |
| 78268 | 78297 |
| 78269 | 78298 | for d in (GTK_WIDGET_CLASSES, GTK_CONTAINER_CLASSES): | @@ -78296,4 +78325,4 @@ def gdk2rgb( c ): return (c.red/65536.0, c.green/65536.0, c.blue/65536.0) | 78296 | 78325 | _rpythonic_setup_return_wrappers() | 78297 | 78326 | _rpythonic_make_nice_global_enums_() | 78298 | 78327 | _rpythonic_clean_up_missing_functions_() | 78299 | | -_rpythonic_strip_prefixes_(['GTK_', 'gtk_', 'clutter_']) | | 78328 | +_rpythonic_strip_prefixes_(['GTK_', 'gtk_', 'clutter_']) |
Collapse file Copy file name to clipboardExpand all lines: scripts/gtkfooter.py +29-1Lines changed: 29 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -302,7 +302,35 @@ def connect( ptr, name, func, *args ): | 302 | 302 | if 'GtkSocket' in globals(): # this is missing with Clutter | 303 | 303 | GTK_WIDGET_CLASSES[ GtkSocket ] = gtk_socket_new | 304 | 304 |
| 305 | | - | | 305 | +if 'ClutterActor' in globals(): | | 306 | + def _clutter_actor_animate_helper(self, atype, ms, **kw): | | 307 | + anims = {} | | 308 | + for prop in kw: | | 309 | + val = GValue() | | 310 | + gtype = g_type_from_name('gdouble') | | 311 | + assert gtype | | 312 | + val = g_value_init( val, gtype ) | | 313 | + val.set_double( kw[prop] ) | | 314 | + anims[prop] = self.animatev( | | 315 | + atype, ms, | | 316 | + 1, #num properties | | 317 | + ctypes.pointer(ctypes.c_char_p(prop)), val, | | 318 | + ) | | 319 | + return anims | | 320 | + ClutterActor.animate = _clutter_actor_animate_helper | | 321 | + | | 322 | + def _get_(self): | | 323 | + x = ctypes.pointer( ctypes.c_double() ) | | 324 | + y = ctypes.pointer( ctypes.c_double() ) | | 325 | + self.clutter_actor_get_scale( x, y ) | | 326 | + return x.contents.value, y.contents.value | | 327 | + ClutterActor.get_scale = _get_ | | 328 | + def _get_(self): | | 329 | + x = ctypes.pointer( ctypes.c_double() ) | | 330 | + y = ctypes.pointer( ctypes.c_double() ) | | 331 | + self.clutter_actor_get_size( x, y ) | | 332 | + return x.contents.value, y.contents.value | | 333 | + ClutterActor.get_size = _get_ | 306 | 334 |
| 307 | 335 | for d in (GTK_WIDGET_CLASSES, GTK_CONTAINER_CLASSES): | 308 | 336 | for o in d: | |
|