Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 76 lines (61 sloc) 2.589 kb
851f2fc add toggle example
lkcl authored
1 """ testint our demo slider
2 """
7cd38e0 #34 - use **kwargs on CustomButton and ToggleButton
lkcl authored
3 import pyjd # dummy in pyjs
851f2fc add toggle example
lkcl authored
4
5 from pyjamas.ui.Label import Label
6 from pyjamas.ui.Button import Button
7 from pyjamas.ui.ButtonBase import ButtonBase
8 from pyjamas.ui.RootPanel import RootPanel
9 from pyjamas.ui.ToggleButton import ToggleButton
631dce5 debian packaging
lkcl authored
10 from pyjamas.ui.PushButton import PushButton
851f2fc add toggle example
lkcl authored
11 from pyjamas import DOM
e6c5cd0 extend toggle example
lkcl authored
12 from pyjamas.ui.Image import Image
13 from pyjamas.ui.VerticalPanel import VerticalPanel
14 from pyjamas.ui.HorizontalPanel import HorizontalPanel
851f2fc add toggle example
lkcl authored
15
16 class Toggle:
17 def onModuleLoad(self):
64eff55 C Anthony Risinger find * -name '*.py' | xargs sed -i -r 's,\s+$,,'
xtfxme authored
18
851f2fc add toggle example
lkcl authored
19 self.label = Label("Not set yet")
64eff55 C Anthony Risinger find * -name '*.py' | xargs sed -i -r 's,\s+$,,'
xtfxme authored
20
851f2fc add toggle example
lkcl authored
21 self.button = Button("Probe button", self)
e6c5cd0 extend toggle example
lkcl authored
22 self.image_up = Image("./images/logo.png")
23 self.image_up3 = Image("./images/logo.png")
24 self.image_down = Image("./images/logo.png")
25 self.image_down3 = Image("./images/logo.png")
26 self.toggle = ToggleButton(self.image_up, self.image_down, self)
933740d button event handling sorted out for firefox, safari, IE. they are diff...
lkcl authored
27 self.toggle2 = ToggleButton("up", "down", getattr(self, "onToggleUD"))
685fce9 add pushbutton to toggle example
lkcl authored
28 self.push = PushButton(self.image_up3, self.image_down3)
64eff55 C Anthony Risinger find * -name '*.py' | xargs sed -i -r 's,\s+$,,'
xtfxme authored
29
e6c5cd0 extend toggle example
lkcl authored
30 self.vpanel = VerticalPanel()
31 self.togglePanel = HorizontalPanel()
32 self.togglePanel.setSpacing(10)
64eff55 C Anthony Risinger find * -name '*.py' | xargs sed -i -r 's,\s+$,,'
xtfxme authored
33
e6c5cd0 extend toggle example
lkcl authored
34 self.togglePanel.add(self.toggle)
35 self.togglePanel.add(self.toggle2)
685fce9 add pushbutton to toggle example
lkcl authored
36 self.togglePanel.add(self.push)
64eff55 C Anthony Risinger find * -name '*.py' | xargs sed -i -r 's,\s+$,,'
xtfxme authored
37
e6c5cd0 extend toggle example
lkcl authored
38 self.vpanel.add(self.label)
39 self.vpanel.add(self.button)
40 self.vpanel.add(self.togglePanel)
64eff55 C Anthony Risinger find * -name '*.py' | xargs sed -i -r 's,\s+$,,'
xtfxme authored
41
e6c5cd0 extend toggle example
lkcl authored
42 RootPanel().add(self.vpanel)
43 self.i = False
64eff55 C Anthony Risinger find * -name '*.py' | xargs sed -i -r 's,\s+$,,'
xtfxme authored
44
933740d button event handling sorted out for firefox, safari, IE. they are diff...
lkcl authored
45 def onToggleUD(self, sender):
46 self.label.setText(" Toggle2 isdown: "+str(self.toggle2.isDown()))
47
5b10b7b remove sender=None
lkcl authored
48 def onClick(self, sender):
851f2fc add toggle example
lkcl authored
49 if sender == self.button:
64eff55 C Anthony Risinger find * -name '*.py' | xargs sed -i -r 's,\s+$,,'
xtfxme authored
50 if self.i:
e6c5cd0 extend toggle example
lkcl authored
51 self.i = False
52 text = ">>>>UP<<<<"
851f2fc add toggle example
lkcl authored
53 self.toggle.setCurrentFace(self.toggle.getUpFace())
54 else:
e6c5cd0 extend toggle example
lkcl authored
55 self.i = True
56 text = ">>>DOWN<<<"
851f2fc add toggle example
lkcl authored
57 self.toggle.setCurrentFace(self.toggle.getDownFace())
e6c5cd0 extend toggle example
lkcl authored
58 #self.label.setText("self.toggle.style_name: "+
59 # self.toggle.style_name+", self.toggle.getStyleName():"+
60 # self.toggle.getStyleName()+" ")
61 self.label.setText(text)
62 elif sender == self.toggle:
63 text = ">>>DOWN<<<"
64 if self.i: text = ">>>>UP<<<<"
65 self.i = not self.i
79e7305 #152 - added and fixed up Toggle at same time
lkcl authored
66 self.label.setText(text+" isdown: "+str(self.toggle.isDown()))
851f2fc add toggle example
lkcl authored
67
68
69 if __name__ == "__main__":
7cd38e0 #34 - use **kwargs on CustomButton and ToggleButton
lkcl authored
70 pyjd.setup("./public/Toggle.html")
851f2fc add toggle example
lkcl authored
71 app = Toggle()
72 app.onModuleLoad()
7cd38e0 #34 - use **kwargs on CustomButton and ToggleButton
lkcl authored
73 pyjd.run()
851f2fc add toggle example
lkcl authored
74
75
Something went wrong with that request. Please try again.