Skip to content

Commit

Permalink
tidyup of controldemo
Browse files Browse the repository at this point in the history
  • Loading branch information
Luke Leighton committed Aug 8, 2010
1 parent 9197850 commit f01a0e2
Showing 1 changed file with 38 additions and 14 deletions.
52 changes: 38 additions & 14 deletions examples/controls/ControlDemo.py
@@ -1,11 +1,11 @@

""" ControlDemo Example """ ControlDemo Example
Bill Winder <wgwinder@gmail.com> added HorizontalSlider demo. 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 import pyjd # dummy in pyjs
from pyjamas.ui.RootPanel import RootPanel from pyjamas.ui.RootPanel import RootPanel
from pyjamas.ui.CaptionPanel import CaptionPanel
from pyjamas.ui.Label import Label from pyjamas.ui.Label import Label
from pyjamas.ui.Controls import VerticalDemoSlider from pyjamas.ui.Controls import VerticalDemoSlider
from pyjamas.ui.Controls import VerticalDemoSlider2 from pyjamas.ui.Controls import VerticalDemoSlider2
Expand All @@ -20,6 +20,9 @@
from pyjamas.ui import HasAlignment from pyjamas.ui import HasAlignment


class SliderClass(VerticalPanel): class SliderClass(VerticalPanel):
""" example of control which pairs up two other controls.
should really be made into a control itself.
"""
def __init__(self, p2): def __init__(self, p2):
VerticalPanel.__init__(self) VerticalPanel.__init__(self)


Expand Down Expand Up @@ -49,6 +52,9 @@ def onControlValueChanged(self, sender, old_value, new_value):
self.label.setValue(new_value, 0) self.label.setValue(new_value, 0)


class HSliderClass(VerticalPanel): class HSliderClass(VerticalPanel):
""" example of control which pairs up two other controls.
should really be made into a control itself.
"""
def __init__(self, p2): def __init__(self, p2):
VerticalPanel.__init__(self) VerticalPanel.__init__(self)


Expand Down Expand Up @@ -78,6 +84,9 @@ def onControlValueChanged(self, sender, old_value, new_value):
self.label.setValue(new_value, 0) self.label.setValue(new_value, 0)


class ASliderClass(VerticalPanel): class ASliderClass(VerticalPanel):
""" example of control which pairs up two other controls.
should really be made into a control itself.
"""
def __init__(self, p2): def __init__(self, p2):
VerticalPanel.__init__(self) VerticalPanel.__init__(self)


Expand Down Expand Up @@ -110,7 +119,7 @@ def onControlValueChanged(self, sender, old_value_xy, new_value_xy):
if (sender == self.label_x): if (sender == self.label_x):


self.b.setControlPos([new_value_xy, self.b.value_y]) 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): elif (sender == self.label_y):


Expand All @@ -130,28 +139,43 @@ def onControlValueChanged(self, sender, old_value_xy, new_value_xy):
class ControlDemo: class ControlDemo:
def onModuleLoad(self): def onModuleLoad(self):


p = HorizontalPanel() v = VerticalPanel(Spacing=10)
p.setSpacing(10)
p.setVerticalAlignment(HasAlignment.ALIGN_BOTTOM) p = HorizontalPanel(Spacing=10,
VerticalAlignment=HasAlignment.ALIGN_BOTTOM)


sc = SliderClass(False) sc = SliderClass(False)
p.add(sc) p.add(CaptionPanel("clickable only", sc))
sc = SliderClass(True) sc = SliderClass(True)
p.add(sc) p.add(CaptionPanel("draggable", sc))
sc = SliderClass(True) 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) sc = HSliderClass(False)
p.add(sc) p.add(CaptionPanel("clickable only", sc))
sc = HSliderClass(True) 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) sc = ASliderClass(False)
p.add(sc) p.add(CaptionPanel("clickable only", sc))
sc = ASliderClass(True) 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__': if __name__ == '__main__':
Expand Down

0 comments on commit f01a0e2

Please sign in to comment.