Button colors


(bowen) #1

How do you specify the colors in a GUI script for buttons, or text?
glColor3f doesn’t do anything…


(jms) #2

That’s works for me:
glColor3f(1.0,1.0,1.0)
gives a white…

jm


(theeth) #3

As far as I know, this only affects the GL functions and not the Blender.Draw buttons, right?

Martin


(bowen) #4

glColor3f does not have any effect on text defined with Blender.Draw Text() or Button() functions…All I want to do is make some buttons that are brown, or terquoise or purple in addition to the grey ones like the edit buttons in blender’s own interface. Not possible?


(LethalSideP) #5

Well, this seems to work fine for me. A small sample follows (I just copied it from a script of mine, then cut it down a little)


import Blender
from Blender.Draw import * #importing modules...

def gui(): #This part draws the GUI
  glClear(GL_BUFFER_COLOR_BIT)
  glClearColor(0.7,0.7,0.7) #Sets the background colour
  glColor3f(0.2, 0.2, 0.2) #Sets the pointer colour
  glRasterPos2i(10, 10) #Sets the pointer position
  Text('This can be whatever the hell you want it to be') #and...creates the text!

def event(evt, val): #this part quits when escape's pressed
  if(evt==ESCKEY and not val):Exit()

Register(gui, event) #this part just makes it all work!


Sorry if the code seems a little complicated or just plain daft to some of you more experienced programmers- I taught myself Python, so it probably seems so inelegant to some of you…

Anyway, I hope this helps.

LethalSideParting


(zr) #6

The glColor state controls the color for Draw.Text(),
but not for the buttons… the methods to change their
draw color&style were never exposed… sorry :confused:


(LethalSideP) #7

Another job for the Blender sources, then!! I’ll add it to my list…


(theeth) #8

well, someone with enough time could have just made a higher level API around the BGL module with their on button definition and mouse handling for the button press. I did something like this for the Dynamica GUI, it’s not really hard to do, but I guess that with the open source, it on’t be needed anymore. In the old days, there was BEX that worked like that too :wink:

Martin