Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 73 lines (59 sloc) 2.503 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):
18
19 self.label = Label("Not set yet")
20
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)
27 self.toggle2 = ToggleButton("up", "down")
685fce9 add pushbutton to toggle example
lkcl authored
28 self.push = PushButton(self.image_up3, self.image_down3)
e6c5cd0 extend toggle example
lkcl authored
29
30 self.vpanel = VerticalPanel()
31 self.togglePanel = HorizontalPanel()
32 self.togglePanel.setSpacing(10)
33
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)
e6c5cd0 extend toggle example
lkcl authored
37
38 self.vpanel.add(self.label)
39 self.vpanel.add(self.button)
40 self.vpanel.add(self.togglePanel)
41
42 RootPanel().add(self.vpanel)
43 self.i = False
851f2fc add toggle example
lkcl authored
44
5b10b7b remove sender=None
lkcl authored
45 def onClick(self, sender):
851f2fc add toggle example
lkcl authored
46 if sender == self.button:
47 if self.i:
e6c5cd0 extend toggle example
lkcl authored
48 self.i = False
49 text = ">>>>UP<<<<"
851f2fc add toggle example
lkcl authored
50 self.toggle.setCurrentFace(self.toggle.getUpFace())
51 else:
e6c5cd0 extend toggle example
lkcl authored
52 self.i = True
53 text = ">>>DOWN<<<"
851f2fc add toggle example
lkcl authored
54 self.toggle.setCurrentFace(self.toggle.getDownFace())
e6c5cd0 extend toggle example
lkcl authored
55 #self.label.setText("self.toggle.style_name: "+
56 # self.toggle.style_name+", self.toggle.getStyleName():"+
57 # self.toggle.getStyleName()+" ")
58 self.label.setText(text)
59 elif sender == self.toggle:
60 text = ">>>DOWN<<<"
61 if self.i: text = ">>>>UP<<<<"
62 self.i = not self.i
79e7305 #152 - added and fixed up Toggle at same time
lkcl authored
63 self.label.setText(text+" isdown: "+str(self.toggle.isDown()))
851f2fc add toggle example
lkcl authored
64
65
66 if __name__ == "__main__":
7cd38e0 #34 - use **kwargs on CustomButton and ToggleButton
lkcl authored
67 pyjd.setup("./public/Toggle.html")
851f2fc add toggle example
lkcl authored
68 app = Toggle()
69 app.onModuleLoad()
7cd38e0 #34 - use **kwargs on CustomButton and ToggleButton
lkcl authored
70 pyjd.run()
851f2fc add toggle example
lkcl authored
71
72
Something went wrong with that request. Please try again.