diff options
author | Willian Padovani Germano <wpgermano@gmail.com> | 2003-07-22 04:27:03 +0400 |
---|---|---|
committer | Willian Padovani Germano <wpgermano@gmail.com> | 2003-07-22 04:27:03 +0400 |
commit | de608898659ea46b1c8dd590cfcd405dc85ccb3f (patch) | |
tree | 00ce951d22fea2bd15725325b3e26e104636aa3b /source/blender/python/api2_2x/doc/Draw.py | |
parent | 9a5cf3cb6679c111794856f038231eab1976826e (diff) |
Exppython docs:
- Updates and fixes to the documentation files, only, no code involved.
Diffstat (limited to 'source/blender/python/api2_2x/doc/Draw.py')
-rw-r--r-- | source/blender/python/api2_2x/doc/Draw.py | 107 |
1 files changed, 54 insertions, 53 deletions
diff --git a/source/blender/python/api2_2x/doc/Draw.py b/source/blender/python/api2_2x/doc/Draw.py index a0135b1bcfd..ffba6863213 100644 --- a/source/blender/python/api2_2x/doc/Draw.py +++ b/source/blender/python/api2_2x/doc/Draw.py @@ -12,63 +12,64 @@ scrollbar, plus support for text drawing. It also includes keyboard keys and mouse button code values in its dictionary (print dir(Blender.Draw)). Example:: - import Blender - from Blender import Draw, BGL - # - mystring = "" - mymsg = "" - toggle = 0 - # - def event(evt, val): # the function to handle input events - global mystring, mymsg + import Blender + from Blender import Draw, BGL + # + mystring = "" + mymsg = "" + toggle = 0 + # + def event(evt, val): # the function to handle input events + global mystring, mymsg - if not val: # val = 0: it's a key/mbutton release - if evt in [Draw.LEFTMOUSE, Draw.MIDDLEMOUSE, Draw.RIGHTMOUSE]: - mymsg = "You released a mouse button." - Draw.Redraw(1) - return + if not val: # val = 0: it's a key/mbutton release + if evt in [Draw.LEFTMOUSE, Draw.MIDDLEMOUSE, Draw.RIGHTMOUSE]: + mymsg = "You released a mouse button." + Draw.Redraw(1) + return - if evt == Draw.ESCKEY: - Draw.Exit() # exit when user presses ESC - return + if evt == Draw.ESCKEY: + Draw.Exit() # exit when user presses ESC + return - elif Draw.AKEY <= evt <= Draw.ZKEY: mystring += chr(evt) - elif evt == Draw.SPACEKEY: mystring += ' ' - elif evt == Draw.BACKSPACEKEY and len(mystring): - mystring = mystring[:-1] - else: return # this is important: only re-register if an event was caught + elif Draw.AKEY <= evt <= Draw.ZKEY: mystring += chr(evt) + elif evt == Draw.SPACEKEY: mystring += ' ' + elif evt == Draw.BACKSPACEKEY and len(mystring): + mystring = mystring[:-1] + else: return # this is important: only re-register if an event was caught + + Draw.Register(gui, event, button_event) # re-register to stay in the loop + # + def button_event(evt): # the function to handle Draw Button events + global mymsg, toggle + if evt == 1: + mymsg = "You pressed the toggle button." + toggle = 1 - toggle + Draw.Redraw(1) + else: + Draw.Register(gui, event, button_event) + # + def gui(): # the function to draw the screen + global mystring, mymsg, toggle + if len(mystring) > 90: mystring = "" + BGL.glClearColor(0,0,1,1) + BGL.glClear(BGL.GL_COLOR_BUFFER_BIT) + BGL.glColor3f(1,1,1) + Draw.Toggle("Toggle", 1, 10, 10, 55, 20, toggle,"A toggle button") + BGL.glRasterPos2i(72, 16) + if toggle: toggle_state = "down" + else: toggle_state = "up" + Draw.Text("The toggle button is %s." % toggle_state, "small") + BGL.glRasterPos2i(10, 230) + Draw.Text("Type letters from a to z, ESC to leave.") + BGL.glRasterPos2i(20, 200) + Draw.Text(mystring) + BGL.glColor3f(1,0.4,0.3) + BGL.glRasterPos2i(340, 70) + Draw.Text(mymsg, "tiny") + # + Draw.Register(gui, event, button_event) # registering the 3 callbacks - Draw.Register(gui, event, button_event) # re-register to stay in the loop - # - def button_event(evt): # the function to handle Draw Button events - global mymsg, toggle - if evt == 1: - mymsg = "You pressed the toggle button." - toggle = 1 - toggle - Draw.Redraw(1) - else: - Draw.Register(gui, event, button_event) - # - def gui(): # the function to draw the screen - global mystring, mymsg, toggle - if len(mystring) > 90: mystring = "" - BGL.glClearColor(0,0,1,1) - BGL.glClear(BGL.GL_COLOR_BUFFER_BIT) - BGL.glColor3f(1,1,1) - Draw.Toggle("Toggle", 1, 10, 10, 55, 20, toggle,"A toggle button") - BGL.glRasterPos2i(72, 16) - if toggle: toggle_state = "down" - else: toggle_state = "up" - Draw.Text("The toggle button is %s." % toggle_state, "small") - BGL.glRasterPos2i(10, 230) - Draw.Text("Type letters from a to z, ESC to leave.") - BGL.glRasterPos2i(20, 200) - Draw.Text(mystring) - BGL.glColor3f(1,0.4,0.3) - BGL.glRasterPos2i(340, 70) - Draw.Text(mymsg, "tiny") - # - Draw.Register(gui, event, button_event) # registering the 3 callbacks @warn: Inside the windowing loop (after Draw.Register() has been executed and before Draw.Exit() is called), don't use the redraw functions from other modules (Blender and Window). The Draw submodule has its own Draw.Redraw() and |