[Bf-python] Window.QRead() QAdd, QHandle

Willian Padovani Germano wgermano at ig.com.br
Fri Oct 15 23:34:23 CEST 2004


Hi,

Tom Musgrove wrote:

> Hi,
>
> I have a script that I'd like to pass everything that isn't handled 
> back to Blender and let it handle it
>
> ...
> evt, val = Window.QRead()
>
> if evt = myevent: do stuff
> else:
>        id = Window.GetScreenInfo(Window.Types.VIEW3D)[0].get('id')
>        Window.QAdd(id, evt, val)
>        Window.QHandle(id)
>
I made a quick test with some speed-ups:

done = 0
while not done:
  evt, val = Window.QRead()
  if not val or evt in [Draw.MOUSEX, Draw.MOUSEY]: continue # helps speed
  elif evt == Draw.QKEY: done = 1
  elif evt == myevent: do stuff
  else:
    id = Window.GetScreenInfo(Window.Types.VIEW3D)[0].get('id')
    Window.QAdd(id, evt, val)
    Window.QHandle(id)
    Blender.Redraw(-1)  # don't forget to redraw

And it seems to work fine.  Transform tools have their own event loops, 
that are entered when you get in their modes, so once inside them your 
script won't do anything, but will gain control again after the 
transformation is confirmed or canceled.

> So, I use RMB and MMB with key combos, expecting to be able to rotate, 
> pan, etc. the object, but nothing is happening,
>
> Am I supposed to be doing this differently?
>
Possibly the missing redraw is the problem, assuming it's not really 
there.  BTW, another possible speed-up I'll try (in C) is making the 
Window.QRead() function accept an optional parameter that tells it not 
to return mouse movement events but instead process the event queue 
until all of them have been ignored.

-- 
Willian





More information about the Bf-python mailing list