-
Notifications
You must be signed in to change notification settings - Fork 32
/
SwitchViews.py
59 lines (46 loc) · 1.86 KB
/
SwitchViews.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# coding: utf-8
import ui, time
back = ui.ButtonItem()
back.image = ui.Image.named("ionicons-arrow-left-b-32")
forward = ui.ButtonItem()
forward.image = ui.Image.named("ionicons-arrow-right-b-32")
space = ui.ButtonItem()
space.image = ui.Image.named("space.png")
class SwitchViews(ui.View):
def __init__(self):
self.present()
self.view_names = ["switchview1", "SwitchViews"]
self.view_index = -1
self.view_array = []
# load and hide views
for i in range(len(self.view_names)):
self.view_index += 1
self.view_array.append(ui.load_view(self.view_names[self.view_index]))
self.add_subview(self.view_array[self.view_index])
self.view_array[self.view_index].hidden = True
# initialize some actions
self.view_array[0]["btn_Okay"].action = self.all_action
self.view_array[0]["btn_Cancel"].action = self.all_action
self.view_array[1]["button1"].action = self.all_action
# show empty white view
self.background_color = "white"
back.action = self.bt_back
forward.action = self.bt_forward
self.left_button_items = [space, back]
self.right_button_items = [space, space, forward]
# show view 'SwitchViews'
self.switch_views()
def bt_back(self, sender):
self.view_index = (self.view_index - 1) % len(self.view_array)
self.switch_views()
def bt_forward(self, sender):
self.view_index = (self.view_index + 1) % len(self.view_array)
self.switch_views()
def switch_views(self):
for i in range(len(self.view_array)):
self.view_array[i].hidden = True
self.view_array[self.view_index].hidden = False
self.name = self.view_names[self.view_index]
def all_action(self, sender):
print("action from " + sender.name)
SwitchViews()