Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Supported by

[solved] Implement a slider with specific ratings

edited May 2015 in OpenSesame

Hello,

I'd like to implement a slider that includes amounts for an Ultimatum Decision Making task.

Something similar to the one in a previous discussion: http://forum.cogsci.nl/index.php?p=/discussion/40/solved-implementing-a-slider/p1

But with specific amounts along the slider bar - please the rough example here.

image

Thanks in advance!

Comments

  • edited 8:53AM

    Hi,

    First of all, you can also have look on this discussion:

    together they should get you enough information to get started.

    In order to have values along the scale you have to add folllowing features:

    • divide the length of the scale into equal-sized parts, which serve as coordinates to draw your markers on

    • assuming that in those discussions mentioned, mouse position and corresponding values are being recorded, you only have to create a piece of code that dynamically draws the value at a position above that scale that is fixed in the vertical dimension (y is constant), but variable in the horizontal one (x is changing).

    The code could look like this:


    # first problem # coordinates of the entire scale x1 = 100 y1 = 600 x2 = 900 y2 = 600 no_markers = 5 dist_between_markers = (x2-x1)/ float(no_markers) marker_pos = [] # adding all values to a list for i in range(no_markers): marker_pos.append(x1+i*dist_between_markers,y1) canvas.text("Value you want to present",x = x1+i*dist_between_markers,y = y1) # second problem # check earlier discussions for the code that implements the main part of # updating the current value of the scale # Let the current position be [x,y] and the current value: value = <some_value> # very simple canvas.text(str(current_value),x= x, y= y) # the important thing is that this piece of code is placed within a while loop, # so that it is updated on every iteration

    I hope this helps. Let me know if you need more pointers.

    Good luck,

    Eduard

    Buy Me A Coffee

  • edited 8:53AM

    Hi Eduard,
    Thanks a lot! It works great now :)

Sign In or Register to comment.