225
Exit the windowing interface.
225
Exit the windowing interface.
228
228
def BeginAlign():
230
Buttons after this function will draw aligned (button layout only).
230
Buttons after this function will draw aligned (button layout only).
235
Use after BeginAlign() to stop aligning the buttons (button layout only).
235
Use after BeginAlign() to stop aligning the buttons (button layout only).
240
This function creates a popup area where buttons, lebels, sliders etc can be dwarn.
243
@param draw: A function to draw to the popup area, taking no arguments: draw().
245
@note: The size of the popup will expand to fit the bounds of the buttons created in the draw function.
246
@note: Be sure to use the mouse coordinates to position the buttons under the mouse,
247
so the popup dosnt exit as soon as it opens.
248
The coordinates for buttons start 0,0 at the bottom left hand side of the screen.
249
@note: Within this popup, Redraw events and the registered button callback will not work.
250
For buttons to run events, use per button callbacks.
251
@note: OpenGL drawing functions wont work within this popup, for text use L{Label} rather then L{Text}
238
254
def Register(draw = None, event = None, button = None):
240
Register callbacks for windowing.
242
@type event: function
243
@type button: function
244
@param draw: A function to draw the screen, taking no arguments: f().
245
@param event: A function to handle keyboard and mouse input events, taking
246
two arguments: f(evt, val), where:
247
- 'evt' (int) is the event number;
248
- 'val' (int) is the value modifier. If val = 0, the event refers to a
249
key or mouse button being released. Otherwise it's a key/button press.
250
@param button: A function to handle Draw Button events, taking one argument:
252
- 'evt' is the button number (see the I{event} parameter in L{Button}).
253
@note: note that in the example at the beginning of this page Draw.Register
254
is called only once. It's not necessary to re-register the callbacks,
255
they will stay until Draw.Exit is called. It's enough to redraw the
256
screen, when a relevant event is caught.
257
@note: only during the B{event} callback: the L{Blender}.ascii variable holds
258
the ASCII integer value (if it exists and is valid) of the current event.
256
Register callbacks for windowing.
258
@type event: function
259
@type button: function
260
@param draw: A function to draw the screen, taking no arguments: draw().
261
@param event: A function to handle keyboard and mouse input events, taking
262
two arguments: f(evt, val), where:
263
- 'evt' (int) is the event number;
264
- 'val' (int) is the value modifier. If val = 0, the event refers to a
265
key or mouse button being released. Otherwise it's a key/button press.
266
@param button: A function to handle Draw Button events, taking one argument:
268
- 'evt' is the button number (see the I{event} parameter in L{Button}).
269
@note: note that in the example at the beginning of this page Draw.Register
270
is called only once. It's not necessary to re-register the callbacks,
271
they will stay until Draw.Exit is called. It's enough to redraw the
272
screen, when a relevant event is caught.
273
@note: only during the B{event} callback: the L{Blender}.ascii variable holds
274
the ASCII integer value (if it exists and is valid) of the current event.
261
277
def Redraw(after = 0):
263
Queue a redraw event. Redraw events are buffered so that, regardless of how
264
many events are queued, the window only receives one redraw event.
266
@param after: If non-zero, the redraw is processed before other input events.
279
Queue a redraw event. Redraw events are buffered so that, regardless of how
280
many events are queued, the window only receives one redraw event.
282
@param after: If non-zero, the redraw is processed before other input events.
271
Force an immediate redraw. Forced redraws are not buffered. In other words,
272
the window is redrawn once every time this function is called.
287
Force an immediate redraw. Forced redraws are not buffered. In other words,
288
the window is redrawn once every time this function is called.
275
291
def Create(value):
277
Create a default Button object.
278
@type value: int, float, string or 3 floats
279
@param value: The value to store in the button.
280
@rtype: Blender Button
281
@return: The Button created.
282
@note: String values must have less then 400 characters.
293
Create a default Button object.
294
@type value: int, float, string or 3 floats
295
@param value: The value to store in the button.
296
@rtype: Blender Button
297
@return: The Button created.
298
@note: String values must have less then 400 characters.
285
def PushButton(name, event, x, y, width, height, tooltip = None):
287
Create a new (push) Button object.
289
@param name: The string to display on the button.
291
@param event: The event number to pass to the button event function when
295
@param x: The lower left x (horizontal) coordinate of the button.
296
@param y: The lower left y (vertical) coordinate of the button.
299
@param width: The button width.
300
@param height: The button height.
301
@type tooltip: string
302
@param tooltip: The button's tooltip (the string that appears when the mouse
303
is kept over the button).
304
@note: This function used to be called only "Button". We added an
305
alternative alias to avoid a name clash with the L{Button} class/type that
306
caused trouble in this documentation's generation. The old name shouldn't
307
be deprecated, use Button or PushButton (better) at your choice.
301
def PushButton(name, event, x, y, width, height, tooltip = None, callback = None):
303
Create a new (push) Button object.
305
@param name: The string to display on the button.
307
@param event: The event number to pass to the button event function when
311
@param x: The lower left x (horizontal) coordinate of the button.
312
@param y: The lower left y (vertical) coordinate of the button.
315
@param width: The button width.
316
@param height: The button height.
317
@type tooltip: string
318
@param tooltip: The button's tooltip (the string that appears when the mouse
319
is kept over the button).
320
@type callback: function
321
@param callback: an optional argument so this button can have its own
322
callback function. the function will run whenever this button is pressed.
323
This function must accept 2 arguments (event, val).
324
@note: This function used to be called only "Button". We added an
325
alternative alias to avoid a name clash with the L{Button} class/type that
326
caused trouble in this documentation's generation. The old name shouldn't
327
be deprecated, use Button or PushButton (better) at your choice.
310
330
def PupMenu(name, maxrow = None):
312
Create a pop-up menu.
314
The menu options are specified through the 'name' parameter, like with
315
L{Menu}: options are followed by a format code and separated by the '|'
316
character. Valid format codes are:
317
- %t - The option should be used as the title of the pop-up;
318
- %l - insert a separating line (only works if 'maxrow' isn't given);
319
- %xB{N} - Chosen this option, PupMenu should return the integer B{N}.
322
name = "OK?%t|QUIT BLENDER" # if no %xN int is set, indices start from 1
323
result = Draw.PupMenu(name)
325
Draw.PupMenu("Really?%t|Yes|No")
328
@param name: The format string to define the contents of the button.
330
@param maxrow: The maximum number of rows for each column in the pop-up.
332
@return: the chosen entry number or -1 if none was chosen.
332
Create a pop-up menu.
334
The menu options are specified through the 'name' parameter, like with
335
L{Menu}: options are followed by a format code and separated by the '|'
336
character. Valid format codes are:
337
- %t - The option should be used as the title of the pop-up;
338
- %l - insert a separating line (only works if 'maxrow' isn't given);
339
- %xB{N} - Chosen this option, PupMenu should return the integer B{N}.
342
name = "OK?%t|QUIT BLENDER" # if no %xN int is set, indices start from 1
343
result = Draw.PupMenu(name)
345
Draw.PupMenu("Really?%t|Yes|No")
348
@param name: The format string to define the contents of the button.
350
@param maxrow: The maximum number of rows for each column in the pop-up.
352
@return: the chosen entry number or -1 if none was chosen.
335
355
def PupIntInput(text, default, min, max):
337
Create an integer number input pop-up.
339
This allows python to use Blender's integer number pop-up input.
346
msg = "Set this value between 0 and 100"
347
result = Draw.PupIntInput(msg, default, min, max)
351
print 'no user input'
354
@param text: The text that is displayed in the pop-up.
356
@param default: The value that the pop-up is set to initially.
358
@param min: The lowest value the pop-up will allow.
360
@param max: The highest value the pop-up will allow.
362
@return: the number chosen or None if none was chosen.
357
Create an integer number input pop-up.
359
This allows python to use Blender's integer number pop-up input.
366
msg = "Set this value between 0 and 100"
367
result = Draw.PupIntInput(msg, default, min, max)
371
print 'no user input'
374
@param text: The text that is displayed in the pop-up.
376
@param default: The value that the pop-up is set to initially.
378
@param min: The lowest value the pop-up will allow.
380
@param max: The highest value the pop-up will allow.
382
@return: the number chosen or None if none was chosen.
365
385
def PupFloatInput(text, default, min, max, clickStep, floatLen):
367
Create a floating point number input pop-up.
369
This allows python to use Blender's floating point pop-up input.
378
msg = "Set this value between 0 and 100"
379
result = Draw.PupFloatInput(msg, default, min, max, clickStep, floatLen)
383
print 'no user input'
386
@param text: The text that is displayed in the pop-up.
388
@param default: The value that the pop-up is set to initially.
390
@param min: The lowest value the pop-up will allow.
392
@param max: The highest value the pop-up will allow.
394
@param clickStep: How much is incremented per user click, 100 will increment 1.0, 10 will increment 0.1 etc.
396
@param floatLen: The number of decimal places to display, between 2 and 4.
398
@return: the number chosen or None if none was chosen.
387
Create a floating point number input pop-up.
389
This allows python to use Blender's floating point pop-up input.
398
msg = "Set this value between 0 and 100"
399
result = Draw.PupFloatInput(msg, default, min, max, clickStep, floatLen)
403
print 'no user input'
406
@param text: The text that is displayed in the pop-up.
408
@param default: The value that the pop-up is set to initially.
410
@param min: The lowest value the pop-up will allow.
412
@param max: The highest value the pop-up will allow.
414
@param clickStep: How much is incremented per user click, 100 will increment 1.0, 10 will increment 0.1 etc.
416
@param floatLen: The number of decimal places to display, between 2 and 4.
418
@return: the number chosen or None if none was chosen.
401
421
def PupStrInput(text, default, max = 20):
403
Create a string input pop-up.
405
This allows python to use Blender's string pop-up input.
408
Blender.Draw.PupStrInput("Name:", "untitled", 25)
411
@param text: The text that is displayed in the pop-up.
412
@type default: string
413
@param default: The value that the pop-up is set to initially. If it's longer
414
then 'max', it's truncated.
416
@param max: The most characters the pop-up input will allow. If not given
417
it defaults to 20 chars. It should be in the range [1, 100].
419
@return: The text entered by the user or None if none was chosen.
423
Create a string input pop-up.
425
This allows python to use Blender's string pop-up input.
428
Blender.Draw.PupStrInput("Name:", "untitled", 25)
431
@param text: The text that is displayed in the pop-up.
432
@type default: string
433
@param default: The value that the pop-up is set to initially. If it's longer
434
then 'max', it's truncated.
436
@param max: The most characters the pop-up input will allow. If not given
437
it defaults to 20 chars. It should be in the range [1, 100].
439
@return: The text entered by the user or None if none was chosen.
422
442
def PupBlock(title, sequence):
463
483
@return: 1 if the pop-up is confirmed, 0 otherwise
466
def Menu(name, event, x, y, width, height, default, tooltip = None):
468
Create a new Menu Button object.
470
The menu options are specified through the 'name' of the button. Options are
471
I{followed} by a format code and separated by the '|' (pipe) character. Valid
473
- %t - The option should be used as the title;
474
- %l - Insert a separating line;
475
- %xB{N} - The option should set the integer B{N} in the button value.
478
name = "The Title %t|First Entry %x1|Second Entry %x2|Third Entry %x3"
479
menu = Draw.Menu(name, 2, 60, 120, 200, 40, 3, "Just a test menu.")
480
# note that, since default = 3, the "Third Entry"
481
# will appear as the default choice in the Menu.
484
@param name: The format string to define the contents of the button.
486
@param event: The event number to pass to the button event function when
490
@param x: The lower left x (horizontal) coordinate of the button.
491
@param y: The lower left y (vertical) coordinate of the button.
494
@param width: The button width.
495
@param height: The button height.
497
@param default: The number of the option to be selected by default.
498
@type tooltip: string
499
@param tooltip: The button's tooltip (the string that appears when the mouse
500
is kept over the button).
501
@rtype: Blender Button
502
@return: The Button created.
505
def Toggle(name, event, x, y, width, height, default, tooltip = None):
507
Create a new Toggle Button object.
509
@param name: The string to display on the button.
511
@param event: The event number to pass to the button event function when
515
@param x: The lower left x (horizontal) coordinate of the button.
516
@param y: The lower left y (vertical) coordinate of the button.
519
@param width: The button width.
520
@param height: The button height.
522
@param default: The value specifying the default state:
523
(0 for "up", 1 for "down").
524
@type tooltip: string
525
@param tooltip: The button's tooltip (the string that appears when the mouse
526
is kept over the button).
527
@rtype: Blender Button
528
@return: The Button created.
486
def Menu(name, event, x, y, width, height, default, tooltip = None, callback = None):
488
Create a new Menu Button object.
490
The menu options are specified through the 'name' of the button. Options are
491
I{followed} by a format code and separated by the '|' (pipe) character. Valid
493
- %t - The option should be used as the title;
494
- %l - Insert a separating line;
495
- %xB{N} - The option should set the integer B{N} in the button value.
498
name = "The Title %t|First Entry %x1|Second Entry %x2|Third Entry %x3"
499
menu = Draw.Menu(name, 2, 60, 120, 200, 40, 3, "Just a test menu.")
500
# note that, since default = 3, the "Third Entry"
501
# will appear as the default choice in the Menu.
504
@param name: The format string to define the contents of the button.
506
@param event: The event number to pass to the button event function when
510
@param x: The lower left x (horizontal) coordinate of the button.
511
@param y: The lower left y (vertical) coordinate of the button.
514
@param width: The button width.
515
@param height: The button height.
517
@param default: The number of the option to be selected by default.
518
@type tooltip: string
519
@param tooltip: The button's tooltip (the string that appears when the mouse
520
is kept over the button).
521
@type callback: function
522
@param callback: an optional argument so this button can have its own
523
callback function. the function will run whenever this button is pressed.
524
This function must accept 2 arguments (event, val).
525
@rtype: Blender Button
526
@return: The Button created.
529
def Toggle(name, event, x, y, width, height, default, tooltip = None, callback = None):
531
Create a new Toggle Button object.
533
@param name: The string to display on the button.
535
@param event: The event number to pass to the button event function when
539
@param x: The lower left x (horizontal) coordinate of the button.
540
@param y: The lower left y (vertical) coordinate of the button.
543
@param width: The button width.
544
@param height: The button height.
546
@param default: The value specifying the default state:
547
(0 for "up", 1 for "down").
548
@type tooltip: string
549
@param tooltip: The button's tooltip (the string that appears when the mouse
550
is kept over the button).
551
@type callback: function
552
@param callback: an optional argument so this button can have its own
553
callback function. the function will run whenever this button is pressed.
554
This function must accept 2 arguments (event, val).
555
@rtype: Blender Button
556
@return: The Button created.
531
559
def Slider(name, event, x, y, width, height, initial, min, max, realtime = 1,
534
Create a new Slider Button object.
536
@param name: The string to display on the button.
538
@param event: The event number to pass to the button event function when
542
@param x: The lower left x (horizontal) coordinate of the button.
543
@param y: The lower left y (vertical) coordinate of the button.
546
@param width: The button width.
547
@param height: The button height.
548
@type initial: int or float
549
@type min: int or float
550
@type max: int or float
551
@param initial: The initial value.
552
@param min: The minimum value.
553
@param max: The maximum value.
555
@param realtime: If non-zero (the default), the slider will emit events as
557
@type tooltip: string
558
@param tooltip: The button's tooltip (the string that appears when the mouse
559
is kept over the button).
560
@rtype: Blender Button
561
@return: The Button created.
560
tooltip = None, callback = None):
562
Create a new Slider Button object.
564
@param name: The string to display on the button.
566
@param event: The event number to pass to the button event function when
570
@param x: The lower left x (horizontal) coordinate of the button.
571
@param y: The lower left y (vertical) coordinate of the button.
574
@param width: The button width.
575
@param height: The button height.
576
@type initial: int or float
577
@type min: int or float
578
@type max: int or float
579
@param initial: The initial value.
580
@param min: The minimum value.
581
@param max: The maximum value.
583
@param realtime: If non-zero (the default), the slider will emit events as
585
@type tooltip: string
586
@param tooltip: The button's tooltip (the string that appears when the mouse
587
is kept over the button).
589
@type callback: function
590
@param callback: an optional argument so this button can have its own
591
callback function. the function will run whenever this button is pressed.
592
This function must accept 2 arguments (event, val).
593
@rtype: Blender Button
594
@return: The Button created.
595
@note: slider callbacks will not work if the realtime setting is enabled.
564
598
#def Scrollbar(event, x, y, width, height, initial, min, max, realtime = 1,
565
599
# tooltip = None):
592
626
# @return: The Button created.
595
def ColorPicker(event, x, y, width, height, initial, tooltip = None):
597
Create a new Color Picker Button object.
599
@param event: The event number to pass to the button event function when
603
@param x: The lower left x (horizontal) coordinate of the button.
604
@param y: The lower left y (vertical) coordinate of the button.
607
@param width: The button width.
608
@param height: The button height.
609
@type initial: 3-float tuple
610
@param initial: The initial color value. All values must be between 0 and 1
611
@type tooltip: string
612
@param tooltip: The button's tooltip (the string that appears when the mouse
613
is kept over the button).
614
@rtype: Blender Button
615
@return: The Button created.
616
@note: The color picker will not work if the Register's event function is None.
617
@note: Using the same button variable with more then 1 button at a time will corrupt memory.
620
def Normal(event, x, y, width, height, initial, tooltip = None):
622
Create a new Normal button, this allows you to set a 3d vector by rotating a sphere.
624
@param event: The event number to pass to the button event function when
628
@param x: The lower left x (horizontal) coordinate of the button.
629
@param y: The lower left y (vertical) coordinate of the button.
632
@param width: The button width - non square normal buttons .
633
@param height: The button height.
634
@type initial: 3-float tuple
635
@param initial: The initial vector value.
636
@type tooltip: string
637
@param tooltip: The button's tooltip (the string that appears when the mouse
638
is kept over the button).
639
@rtype: Blender Button
640
@return: The Button created.
641
@note: The normal button will not work if the Register's event function is None.
642
@note: Using the same button variable with more then 1 button at a time will corrupt memory.
645
def Number(name, event, x, y, width, height, initial, min, max, tooltip = None):
647
Create a new Number Button object.
649
@param name: The string to display on the button.
651
@param event: The event number to pass to the button event function when
655
@param x: The lower left x (horizontal) coordinate of the button.
656
@param y: The lower left y (vertical) coordinate of the button.
659
@param width: The button width.
660
@param height: The button height.
661
@type initial: int or float
662
@type min: int or float
663
@type max: int or float
664
@param initial: The initial value.
665
@param min: The minimum value.
666
@param max: The maximum value.
667
@type tooltip: string
668
@param tooltip: The button's tooltip (the string that appears when the mouse
669
is kept over the button).
670
@rtype: Blender Button
671
@return: The Button created.
675
This example draws a single floating point value::
676
from Blender import Draw
677
b= Draw.Create(0.0) # Data for floating point button
679
print 'My Button event:', evt
682
b= Draw.Number('value: ', 1000, 0,0, 200, 20, b.val, 0,10, 'some text tip')
684
Draw.Register(gui, None, bevent) # we are not going to worry about keyboard and mouse events
688
def String(name, event, x, y, width, height, initial, length, tooltip = None):
690
Create a new String Button object.
692
@param name: The string to display on the button.
694
@param event: The event number to pass to the button event function when
698
@param x: The lower left x (horizontal) coordinate of the button.
699
@param y: The lower left y (vertical) coordinate of the button.
702
@param width: The button width.
703
@param height: The button height.
704
@type initial: string
705
@param initial: The string to display initially.
707
@param length: The maximum input length.
708
@type tooltip: string
709
@param tooltip: The button's tooltip (the string that appears when the mouse
710
is kept over the button).
711
@rtype: Blender Button
712
@return: The Button created.
629
def ColorPicker(event, x, y, width, height, initial, tooltip = None, callback = None):
631
Create a new Color Picker Button object.
633
@param event: The event number to pass to the button event function when
637
@param x: The lower left x (horizontal) coordinate of the button.
638
@param y: The lower left y (vertical) coordinate of the button.
641
@param width: The button width.
642
@param height: The button height.
643
@type initial: 3-float tuple
644
@param initial: The initial color value. All values must be between 0 and 1
645
@type tooltip: string
646
@param tooltip: The button's tooltip (the string that appears when the mouse
647
is kept over the button).
648
@type callback: function
649
@param callback: an optional argument so this button can have its own
650
callback function. the function will run whenever this button is pressed.
651
This function must accept 2 arguments (event, val).
652
@rtype: Blender Button
653
@return: The Button created.
654
@note: The color picker will not work if the Register's event function is None.
655
@note: Using the same button variable with more then 1 button at a time will corrupt memory.
658
def Normal(event, x, y, width, height, initial, tooltip = None, callback = None):
660
Create a new Normal button, this allows you to set a 3d vector by rotating a sphere.
662
@param event: The event number to pass to the button event function when
666
@param x: The lower left x (horizontal) coordinate of the button.
667
@param y: The lower left y (vertical) coordinate of the button.
670
@param width: The button width - non square normal buttons .
671
@param height: The button height.
672
@type initial: 3-float tuple
673
@param initial: The initial vector value.
674
@type tooltip: string
675
@param tooltip: The button's tooltip (the string that appears when the mouse
676
is kept over the button).
677
@type callback: function
678
@param callback: an optional argument so this button can have its own
679
callback function. the function will run whenever this button is pressed.
680
This function must accept 2 arguments (event, val).
681
@rtype: Blender Button
682
@return: The Button created.
683
@note: The normal button will not work if the Register's event function is None.
684
@note: Using the same button variable with more then 1 button at a time will corrupt memory.
687
def Number(name, event, x, y, width, height, initial, min, max, tooltip = None, callback = None):
689
Create a new Number Button object.
691
@param name: The string to display on the button.
693
@param event: The event number to pass to the button event function when
697
@param x: The lower left x (horizontal) coordinate of the button.
698
@param y: The lower left y (vertical) coordinate of the button.
701
@param width: The button width.
702
@param height: The button height.
703
@type initial: int or float
704
@type min: int or float
705
@type max: int or float
706
@param initial: The initial value.
707
@param min: The minimum value.
708
@param max: The maximum value.
709
@type tooltip: string
710
@param tooltip: The button's tooltip (the string that appears when the mouse
711
is kept over the button).
712
@type callback: function
713
@param callback: an optional argument so this button can have its own
714
callback function. the function will run whenever this button is pressed.
715
This function must accept 2 arguments (event, val).
716
@rtype: Blender Button
717
@return: The Button created.
721
This example draws a single floating point value::
722
from Blender import Draw
723
b= Draw.Create(0.0) # Data for floating point button
725
print 'My Button event:', evt
728
b= Draw.Number('value: ', 1000, 0,0, 200, 20, b.val, 0,10, 'some text tip')
730
Draw.Register(gui, None, bevent) # we are not going to worry about keyboard and mouse events
734
def String(name, event, x, y, width, height, initial, length, tooltip = None, callback = None):
736
Create a new String Button object.
738
@param name: The string to display on the button.
740
@param event: The event number to pass to the button event function when
744
@param x: The lower left x (horizontal) coordinate of the button.
745
@param y: The lower left y (vertical) coordinate of the button.
748
@param width: The button width.
749
@param height: The button height.
750
@type initial: string
751
@param initial: The string to display initially.
753
@param length: The maximum input length.
754
@type tooltip: string
755
@param tooltip: The button's tooltip (the string that appears when the mouse
756
is kept over the button).
757
@type callback: function
758
@param callback: an optional argument so this button can have its own
759
callback function. the function will run whenever this button is pressed.
760
This function must accept 2 arguments (event, val).
761
@rtype: Blender Button
762
@return: The Button created.
715
765
def GetStringWidth(string, fontsize = 'normal'):
717
Get the width in pixels of a string.
719
@param string: A string.
720
@type fontsize: string
721
@param fontsize: The size of the font: 'large', 'normal', 'small' or 'tiny'.
723
@return: The width of I{string} with the chosen I{fontsize}.
767
Get the width in pixels of a string.
769
@param string: A string.
770
@type fontsize: string
771
@param fontsize: The size of the font: 'large', 'normal', 'small' or 'tiny'.
773
@return: The width of I{string} with the chosen I{fontsize}.
726
776
def Text(string, fontsize = 'normal'):
728
Draw a string on the screen.
730
Text location is set using the OpenGL raster location functions L{BGL.glRasterPos} before the text is drawn.
731
This sets the text location from the lower left corner of the current window.
733
Text color is set using the OpenGL color functions L{BGL.glColor} before the text is drawn.
736
@param string: The text string to draw.
737
@type fontsize: string
738
@param fontsize: The size of the font: 'large', 'normal', 'small' or 'tiny'.
740
@return: The width of I{string} drawn with the chosen I{fontsize}.
741
@note: For drawing text in the 3d view see the workaround in L{BGL.glRasterPos}
778
Draw a string on the screen.
780
Text location is set using the OpenGL raster location functions L{BGL.glRasterPos} before the text is drawn.
781
This sets the text location from the lower left corner of the current window.
783
Text color is set using the OpenGL color functions L{BGL.glColor} before the text is drawn.
786
@param string: The text string to draw.
787
@type fontsize: string
788
@param fontsize: The size of the font: 'large', 'normal', 'small' or 'tiny'.
790
@return: The width of I{string} drawn with the chosen I{fontsize}.
791
@note: For drawing text in the 3d view see the workaround in L{BGL.glRasterPos}
794
def Label(string, x, y, w, h):
796
Draw a text lable on the screen.
799
@param string: The text string to draw.
744
804
def Image(image, x, y, zoomx=1.0, zoomy=1.0, clipx=0, clipy=0, clipw=-1, cliph=-1):
746
Draw an image on the screen.
748
The image is drawn at the location specified by the coordinates (x,y). A
749
pair of optional zoom factors (in horizontal and vertical directions) can
750
be applied to the image as it is drawn, and an additional clipping rectangle
751
can be applied to extract a particular sub-region of the image to draw.
753
Note that the clipping rectangle is given in image space coordinates. In
754
image space, the origin is located at the bottom left, with x coordinates
755
increasing to the right and y coordinates increasing upwards. No matter
756
where the clipping rectangle is placed in image space, the lower-left pixel
757
drawn on the screen is always placed at the coordinates (x,y). The
758
clipping rectangle is itself clipped to the dimensions of the image. If
759
either the width or the height of the clipping rectangle are negative then
760
the corresponding dimension (width or height) is set to include as much of
761
the image as possible.
763
For drawing images with alpha blending with the background you will need to enable blending as shown in the example.
769
from Blender import BGL, Image, Draw
771
myimage = Image.Load('myimage.png')
774
BGL.glEnable( BGL.GL_BLEND ) # Only needed for alpha blending images with background.
775
BGL.glBlendFunc(BGL.GL_SRC_ALPHA, BGL.GL_ONE_MINUS_SRC_ALPHA)
777
Draw.Image(myimage, 50, 50)
779
BGL.glDisable( BGL.GL_BLEND )
781
if evt == Draw.ESCKEY:
784
Draw.Register(gui, event, None)
786
@type image: Blender.Image
787
@param image: The image to draw.
789
@param x: The lower left x (horizontal) position of the origin of the image.
791
@param y: The lower left y (vertical) position of the origin of the image.
793
@param zoomx: The x (horizontal) zoom factor to use when drawing the image.
795
@param zoomy: The y (vertical) zoom factor to use when drawing the image.
797
@param clipx: The lower left x (horizontal) origin of the clipping rectangle
798
within the image. A value of 0 indicates the left of the
801
@param clipy: The lower left y (vertical) origin of the clipping rectangle
802
within the image. A value of 0 indicates the bottom of the
805
@param clipw: The width of the clipping rectangle within the image. If this
806
value is negative then the clipping rectangle includes as much
807
of the image as possible in the x (horizontal) direction.
809
@param cliph: The height of the clipping rectangle within the image. If this
810
value is negative then the clipping rectangle includes as much
811
of the image as possible in the y (vertical) direction.
806
Draw an image on the screen.
808
The image is drawn at the location specified by the coordinates (x,y). A
809
pair of optional zoom factors (in horizontal and vertical directions) can
810
be applied to the image as it is drawn, and an additional clipping rectangle
811
can be applied to extract a particular sub-region of the image to draw.
813
Note that the clipping rectangle is given in image space coordinates. In
814
image space, the origin is located at the bottom left, with x coordinates
815
increasing to the right and y coordinates increasing upwards. No matter
816
where the clipping rectangle is placed in image space, the lower-left pixel
817
drawn on the screen is always placed at the coordinates (x,y). The
818
clipping rectangle is itself clipped to the dimensions of the image. If
819
either the width or the height of the clipping rectangle are negative then
820
the corresponding dimension (width or height) is set to include as much of
821
the image as possible.
823
For drawing images with alpha blending with the background you will need to enable blending as shown in the example.
827
from Blender import BGL, Image, Draw
829
myimage = Image.Load('myimage.png')
832
BGL.glEnable( BGL.GL_BLEND ) # Only needed for alpha blending images with background.
833
BGL.glBlendFunc(BGL.GL_SRC_ALPHA, BGL.GL_ONE_MINUS_SRC_ALPHA)
835
Draw.Image(myimage, 50, 50)
837
BGL.glDisable( BGL.GL_BLEND )
839
if evt == Draw.ESCKEY:
842
Draw.Register(gui, event, None)
844
@type image: Blender.Image
845
@param image: The image to draw.
847
@param x: The lower left x (horizontal) position of the origin of the image.
849
@param y: The lower left y (vertical) position of the origin of the image.
851
@param zoomx: The x (horizontal) zoom factor to use when drawing the image.
853
@param zoomy: The y (vertical) zoom factor to use when drawing the image.
855
@param clipx: The lower left x (horizontal) origin of the clipping rectangle
856
within the image. A value of 0 indicates the left of the
859
@param clipy: The lower left y (vertical) origin of the clipping rectangle
860
within the image. A value of 0 indicates the bottom of the
863
@param clipw: The width of the clipping rectangle within the image. If this
864
value is negative then the clipping rectangle includes as much
865
of the image as possible in the x (horizontal) direction.
867
@param cliph: The height of the clipping rectangle within the image. If this
868
value is negative then the clipping rectangle includes as much
869
of the image as possible in the y (vertical) direction.
818
This object represents a button in Blender's GUI.
819
@type val: int or float, string or 3-float tuple (depends on button type).
820
@ivar val: The button's value.
876
This object represents a button in Blender's GUI.
877
@type val: int or float, string or 3-float tuple (depends on button type).
878
@ivar val: The button's value.