from GUI import Window, Button, application
from TestScrollableViews import TestScrollableView

class TestWindow(Window):

    def __init__(self, **kwds):
        Window.__init__(self, **kwds)
        self.view = TestScrollableView(container = self,
            width = 300, height = 300, scrolling = 'hv')
        buttons = self.create_buttons()
        x = self.view.right + 5
        y = 5
        for b in buttons:
            b.position = (x, y)
            self.add(b)
            y = b.bottom + 5
        self.shrink_wrap()
    
    def create_buttons(self):
        return [
            Button("Scroll Left", action = ('scroll', -16, 0)),
            Button("Scroll Right", action = ('scroll', 16, 0)),
            Button("Scroll Up", action = ('scroll', 0, -16)),
            Button("Scroll Down", action = ('scroll', 0, 16)),
            Button("Small Extent", action = ('extent', 100, 100)),
            Button("Medium Extent", action = ('extent', 500, 500)),
            Button("Large Extent", action = ('extent', 1000, 1000)),
        ]
    
    def scroll(self, dx, dy):
        self.view.scroll_by(dx, dy)
    
    def extent(self, w, h):
        self.view.extent = (0, 0, w, h)
        print "Extent =", self.view.extent

win = TestWindow()
win.show()

instructions = """
There should be a scrolling view containing a diagonal row of red
triangles on a white background. All scrolling controls should work
properly.

Buttons down the right side can be used to simulate clicking on the
scroll arrows and to change the extent. Ensure that the scroll bars
are updated accordingly when these buttons are used.
"""

print instructions
application().run()
