Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

tidyup of controldemo

  • Loading branch information...
commit f01a0e29b066d4c81a2a0c96d3e6c7901899ca2b 1 parent 9197850
Luke Leighton authored
Showing with 38 additions and 14 deletions.
  1. +38 −14 examples/controls/ControlDemo.py
View
52 examples/controls/ControlDemo.py
@@ -1,11 +1,11 @@
-
""" ControlDemo Example
Bill Winder <wgwinder@gmail.com> added HorizontalSlider demo.
- Bill Winder <wgwinder@gmail.com> added AreaSlider demo.
+ Bill Winder <wgwinder@gmail.com> 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__':
Please sign in to comment.
Something went wrong with that request. Please try again.