From f01a0e29b066d4c81a2a0c96d3e6c7901899ca2b Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Sun, 8 Aug 2010 14:12:53 +0100 Subject: [PATCH] tidyup of controldemo --- examples/controls/ControlDemo.py | 52 +++++++++++++++++++++++--------- 1 file changed, 38 insertions(+), 14 deletions(-) diff --git a/examples/controls/ControlDemo.py b/examples/controls/ControlDemo.py index 84b5133dd..dae2866f8 100644 --- a/examples/controls/ControlDemo.py +++ b/examples/controls/ControlDemo.py @@ -1,11 +1,11 @@ - """ ControlDemo Example Bill Winder added HorizontalSlider demo. - Bill Winder added AreaSlider demo. + Bill Winder added AreaSlider demo. """ import pyjd # dummy in pyjs from pyjamas.ui.RootPanel import RootPanel +from pyjamas.ui.CaptionPanel import CaptionPanel from pyjamas.ui.Label import Label from pyjamas.ui.Controls import VerticalDemoSlider from pyjamas.ui.Controls import VerticalDemoSlider2 @@ -20,6 +20,9 @@ from pyjamas.ui import HasAlignment class SliderClass(VerticalPanel): + """ example of control which pairs up two other controls. + should really be made into a control itself. + """ def __init__(self, p2): VerticalPanel.__init__(self) @@ -49,6 +52,9 @@ def onControlValueChanged(self, sender, old_value, new_value): self.label.setValue(new_value, 0) class HSliderClass(VerticalPanel): + """ example of control which pairs up two other controls. + should really be made into a control itself. + """ def __init__(self, p2): VerticalPanel.__init__(self) @@ -78,6 +84,9 @@ def onControlValueChanged(self, sender, old_value, new_value): self.label.setValue(new_value, 0) class ASliderClass(VerticalPanel): + """ example of control which pairs up two other controls. + should really be made into a control itself. + """ def __init__(self, p2): VerticalPanel.__init__(self) @@ -110,7 +119,7 @@ def onControlValueChanged(self, sender, old_value_xy, new_value_xy): if (sender == self.label_x): self.b.setControlPos([new_value_xy, self.b.value_y]) - self.b.setValue([new_value_xy, self.b.value_y], 0) + self.b.setValue([new_value_xy, self.b.value_y], 0) elif (sender == self.label_y): @@ -130,28 +139,43 @@ def onControlValueChanged(self, sender, old_value_xy, new_value_xy): class ControlDemo: def onModuleLoad(self): - p = HorizontalPanel() - p.setSpacing(10) - p.setVerticalAlignment(HasAlignment.ALIGN_BOTTOM) + v = VerticalPanel(Spacing=10) + + p = HorizontalPanel(Spacing=10, + VerticalAlignment=HasAlignment.ALIGN_BOTTOM) sc = SliderClass(False) - p.add(sc) + p.add(CaptionPanel("clickable only", sc)) sc = SliderClass(True) - p.add(sc) + p.add(CaptionPanel("draggable", sc)) sc = SliderClass(True) - p.add(sc) + p.add(CaptionPanel("draggable", sc)) + + v.add(CaptionPanel("Vertical Sliders with inputboxes", p)) + + p = HorizontalPanel() + p.setSpacing(10) + p.setVerticalAlignment(HasAlignment.ALIGN_BOTTOM) sc = HSliderClass(False) - p.add(sc) + p.add(CaptionPanel("clickable only", sc)) sc = HSliderClass(True) - p.add(sc) + p.add(CaptionPanel("draggable", sc)) + + v.add(CaptionPanel("Horizontal Sliders with inputboxes", p)) + + p = HorizontalPanel() + p.setSpacing(10) + p.setVerticalAlignment(HasAlignment.ALIGN_BOTTOM) sc = ASliderClass(False) - p.add(sc) + p.add(CaptionPanel("clickable only", sc)) sc = ASliderClass(True) - p.add(sc) + p.add(CaptionPanel("draggable", sc)) + + v.add(CaptionPanel("2D Controls: Inputboxes are draggable as well", p)) - RootPanel().add(p) + RootPanel().add(v) if __name__ == '__main__':