[Bf-python] This code on linux does't work
Willian Padovani Germano
wgermano at ig.com.br
Sun Sep 12 16:55:12 CEST 2004
Hi Gianmario,
I tested it again, typing the example on the Text Editor and running
with ALT+P (the example below has an extra space in the "elif evt ==
Draw.REDRAW:" line, but that should only cause a syntax error. In my
tests it's working fine: you left-click on the 3d view and the 3d cursor
moves to the chosen position (not exactly where you clicked, but where
the mouse pointer is when the code is executed, which can be different
on slower machines if you move the mouse after clicking).
I tested with a cvs build newer than 2.34 but not current, Python 2.3.3,
linux. Also tested before 2.34.
Could someone else also try the example below and tell us if it works?
What it should do: it takes control of the main event loop and ...
- pops a silly msg when SPACE is pressed
- moves the 3d cursor when left mouse button is pressed (better do it at
the 3d view)
- exits when either ESC or q is pressed
salvetti.gianmario at tiscali.it wrote:
>from Blender import Draw, Window
>
>done = 0
>while not done: # enter a 'get event' loop
> evt, val = Window.QRead() # catch next event
> if evt in [Draw.ESCKEY, Draw.QKEY]:
> done = 1 # end loop
> elif evt == Draw.SPACEKEY:
> Draw.PupMenu("Hey!|What did you expect?")
> elif evt == Draw.REDRAW: # catch redraw events to handle them
> Window.RedrawAll() # redraw all areas
> print "ridisegno intercettato"
> elif evt == Draw.LEFTMOUSE and val: # left button pressed
> v3d = Window.GetScreenInfo(Window.Types.VIEW3D)
> id = v3d[0]['id'] # get the (first) VIEW3D's id
> Window.QAdd(id, evt, 1, 0) # add the caught mouse event to it
> Window.QHandle(id) # process the event
> Window.Redraw() # show the change in the VIEW3D areas.
>
>
>
>When i click the left mouse button, nothing happens. When the
>script quits, the cursor 3d moves into last position
>assumed by the mouse pointer, shifted of one equal amount
>to the width of the script window.
>
--
Willian
More information about the Bf-python
mailing list