O/S: Mint 8 (Ubuntu).
Clutter & python-clutter: 1.0
Python 2.6
Nvidia (185.18.36) Linux x86
Compiz *is* running. (Indeed, Gnome is useless without it.)


Hello,
This is all about the initial state of a python-clutter app.

The first 'ready' problem
---
See attached for demo. I hope it shows the problem.
When the remarks are toggled (lines 83/84) the result toggles, but it
should be the same:
1. Blue rects get drawn top-left
2. Blue rects are placed on red rect. (Correct behav.)

Using the timeout_add() feels all kind of wrong. It's being used as a
"call after" trick — giving clutter some time to get its house in order*
and then run blah().
* The rot is line 34 in draw_nodes: apply_relative_transform_to_point

Is there a way to know when clutter is "ready" to do point transforms
and other tricksy things? Some kind of event perhaps? I have been
scouring the docs to no avail.


The other 'ready' problem
---
When I run my apps I often get an alternating: works, blocks*, works,
... cycle — each one regular and on a fresh run.

* means it draws the squares and so forth, but after that there's no
update of the window.
1. If I click-around, no white squares are visible.
2. If I shade/unshade the window it updates ok, goto 1.

I have tried to make this reproducible, but it's too slippery. I kind of
assume this second problem is Compiz-related. But the regular cycle
suggests something has not been cleared/reset between calls to
clutter.main() (or whatever.)

(disabling Compiz to test is a horrible thing to do; basically my entire desktop world collapses. I always resist doing this...)

\d
import clutter
from clutter import _gobject as gobject

class Triangle(clutter.CairoTexture):
	def __init__( self ):
		self.h,self.w=64,64
		clutter.CairoTexture.__init__(self, self.h,self.w )
		self.paint()

	def paint(self):
		ctx=self.cairo_create()
		ctx.set_source_rgba(0.71, 0.81, 0.83, 0.5)
		## A small triangle
		ctx.move_to(0,0)
		ctx.line_to(63,63)
		ctx.line_to(0,63)
		ctx.close_path()
		ctx.fill()	
		del(ctx)

class VisibleGroup( clutter.Group ):
	def __init__( self, area, colstr ):
		clutter.Group.__init__(self)
		w, h = area
		## A Rectangle to make this Group 'visible'
		rect = clutter.Rectangle(clutter.color_from_string(colstr))
		rect.set_size(w, h)
		rect.set_position(0,0)
		self.add(rect)

	def draw_nodes(self, ref_actor):
		for x,y in [ (8,8), (32,32) ]: #stage coords
			## becomes a coord in self
			x,y,z = ref_actor.apply_relative_transform_to_point(self,clutter.Vertex(x,y,0))
			self.add_rect((x,y),"blue")

	def add_rect( self, pos, col="white"):
		dot = clutter.Rectangle(clutter.color_from_string(col))
		dot.set_size(6,6)
		dot.set_anchor_point(3,3)
		x,y=pos
		dot.set_position(x,y)
		self.add(dot)


if __name__ == '__main__':
	stage = clutter.Stage()
	stage.set_size(768, 768)
	stage.set_color(clutter.color_from_string('Black'))

	stage.connect('destroy', clutter.main_quit)

	pw1,ph1 = 760,760
	master_pale = VisibleGroup( (pw1,ph1), 'gray')
	master_pale.set_position(4,4)
	master_pale.set_reactive( True )

	pw,ph = 256, 256 
	some_group = VisibleGroup( (pw,ph), 'red')
	some_group.set_rotation(clutter.Z_AXIS, 45.0, 128, 128,0)
	some_group.set_position(256,256)

	cairo_texture=Triangle()

	some_group.add( cairo_texture )
	master_pale.add(some_group)
	stage.add( master_pale )

	def click( obj, evt ):
		x,y=master_pale.transform_stage_point( evt.x, evt.y )
		master_pale.add_rect( (x, y) )
	stage.connect('button-release-event', click)
	

	## PROBLEM ZONE HERE : ##

	def blah():
		master_pale.draw_nodes( cairo_texture )
		return False

	## Toggle remarks below to see the situation: ##

	#blah() # draws blue rects in wrong place.
	gobject.timeout_add(150, blah ) # draws correctly, but not always...
	
	## How long do I set the timeout? What determines when clutter is "ready" to go?


	stage.show_all()
	clutter.main()
_______________________________________________
clutter-app-devel-list mailing list
[email protected]
http://lists.clutter-project.org/listinfo/clutter-app-devel-list

Reply via email to