#
#   PyGUI - Slider test
#

from GUI import Slider, Window, run

def slid(slider, orient, number):
    name = "%s%s" % (orient.upper(), number)
    def action():
        print "Slider %s value = %s" % (name, slider.value)
    return action

def test(orient, pos, pad):
    win = Window(title = "%s Sliders" % orient.upper(), position = pos,
        auto_position = False)
    sl1 = Slider(orient = orient, max_value = 100)
    sl2 = Slider(orient = orient, max_value = 100, ticks = 6, live = False)
    sl3 = Slider(orient = orient, max_value = 100, ticks = 6, discrete = True)
    sl2.value = 50
    sl3.value = 100
    sl1.action = slid(sl1, orient, 1)
    sl2.action = slid(sl2, orient, 2)
    sl3.action = slid(sl3, orient, 3)
    sliders = [sl1, sl2, sl3]
    if orient == 'h':
        win.place_column(sliders, left = 20, top = 20, spacing = 20, sticky = 'ew')
        sl2.vstretch = True
        sl3.vmove = True
    else:
        win.place_row(sliders, left = 20, top = 20, spacing = 20, sticky = 'ns')
        sl2.hstretch = True
        sl3.hmove = True
    win.shrink_wrap((20, 20))
    win.show()

instructions = """
There should be two windows, one containing horizontal sliders and
one containing vertical sliders. In each window, there should be
three sliders, one without tick marks, one with tick marks but
unconstrained values, and one with values constrained to tick marks.

Moving a slider should cause a value in the range 0 to 100 to be
reported. The initial values of the sliders should be 0, 50, 100.
The middle slider should report its value only when the mouse is
released; the others should report their values continuously while
the mouse is dragged.
"""

print instructions
test('h', (20, 60), (30, 30))
test('v', (200, 60), (60, 30))
run()
