Re-drawing as information changes in GUI.

A scrollbar does “emit” it’s data by changing that 0 before the tool tip to 1.

Thing is that it is emmitting to the output window. What I would like to do is see that change in the window that I am looking at as I am making it.

Putting a Blender.Redraw() sends me back to the text window.

Can I update the screen as the value from the slider bar changes?

from Blender.Draw import *
from Blender.BGL import *

def gui():
    global Tscroll
    glClearColor(.7 , .27, .188, 10)
    glClear(GL_COLOR_BUFFER_BIT)
    glRasterPos2i(50, Tscroll.val)
    Text (Ttext)

    Button("Exit", 1, 400, 500, 150, 25, "In Parenthesis on Button Line")
    Tscroll = Slider('test: ',5, 200, 50, 500, 20, Tscroll.val, 175, 275, 1, "cc")
	
def event(evt, val):
   # print "event : ", evt , val
    if (evt == ESCKEY and not val): Exit()

    if (evt == 11):
      print "Up"
    if (evt == 10):
		print "Down"

def bevent(evt):
   # print "bevent : ", evt

    if (evt == 5):

        	print "slider value = ", Tscroll.val
		
    if (evt == 1): Exit()

Tscroll = Create(20)
Ttext = repr (Tscroll.val )
Register(gui, event, bevent)

Hi,

Its interesting that you can move the position of the ‘Ttext’ text BUT not change its contents!!??!!

I had a fiddle with your script.

I’ve been using the gl commands
DrawglBOX(x1, y1, x2, y2) and glTEXT(x, y, “your text here”), but when I added them to your script they caused an error - Not sure why, my script worked fine 2 secs before that.

Cheers Stephen

Updated code in the message below.

Scratch that comment about DrawglBOX and glText .

They are funcs I wrote to make GUI drawing easier :expressionless:

You might find them handy.

Cheers Stephen


from Blender.Draw import *
from Blender.BGL import *

Tscroll = Create(180)
TSlidval = Create(str(Tscroll.val))
Ttext = str(Tscroll.val)

def gui():
    global Tscroll, TSlidval
    glClearColor(.7 , .27, .188, 10)
    glClear(GL_COLOR_BUFFER_BIT)
    glRasterPos2i(50, Tscroll.val)
    #Text(Ttext)
    
    glTEXT(50, Tscroll.val, Ttext)
    DrawglBOX(40,170,80,290)
    
    Button("Exit", 1, 100, 200, 150, 25, "In Parenthesis on Button Line")
    Tscroll = Slider('test: ',5, 200, 50, 500, 20, Tscroll.val, 175, 275, 0, "cc")
    TSlidval  = String("Slider Value: ", 10, 333, 234, 153, 27, TSlidval.val, 8, "What the slider says!")

   
def event(evt, val):
    
   # print "event : ", evt , val
    if (evt == ESCKEY and not val): Exit()

    if (evt == 11):
      print "Up"
      
    if (evt == 10):
      print "Down"

def bevent(evt):
   # print "bevent : ", evt

    if (evt == 5):
        Ttext = str(Tscroll.val )
        print "slider value = ", Tscroll.val
        TSlidval.val = str(Tscroll.val)
        Redraw()

    if (evt == 10):
        Ttext = str(TSlidval.val )
        print "slider value = ", TSlidval.val
        Tscroll.val = int(TSlidval.val)
        Redraw()

    if (evt == 1): Exit()

def glTEXT(x1, y1, TEXT):
    glRasterPos2i(x1, y1)
    Text(TEXT)
    
def DrawglBOX(x1,y1,x2,y2):
    glColor3f (0.0, 0.0, 0.0);
    glLineWidth (1);
    glBegin (GL_LINE_LOOP);
    glVertex2f (x1, y1);
    glVertex2f (x2, y1);
    glVertex2f (x2, y2);
    glVertex2f (x1, y2);
    glEnd ();

    
Register(gui, event, bevent)


I changed that Text (Ttext) to Text (Tscroll.val) and now the text updates.

Back to my original problem, do Ya’ll suppose that it is possible to have the screen redraw every time the scrollbar value changes ?

Daniel Dunbar’s doc string browser has a sliderbar that does what I am trying to do. I assumed he did that because he wanted a vertical bar. Do I need to follow that example?

there’s a parameter to do just that in the Slider function. It’s the one just before the ToolTip. If it evaluate to TRUE, it will send an event when the user moves the slider. If it evaluates to FALSE, it will only send an event when the user stops moving the slider.

in short, use this


Tscroll = Slider('test: ',5, 200, 50, 500, 20, Tscroll.val, 175, 275, 1, "cc")

Martin

That’s what you said earlier, and maybe I am being really dumb but when I change that to 1 the slider bar emits at the output window but I have not been able to find a way to make the window that I am generating with my python script update until I let go of the sliderbar(mousebutton).

http://www.door3.org/Here_NotHere.png

seems to be a problem where the GUI is not/cannot be refreshed while the user still holds the slider button :expressionless:

Martin