Skip to content

Commit 6f3ec40

Browse files
committed
Update pythonnative_demo
1 parent 727f7c6 commit 6f3ec40

File tree

3 files changed

+79
-27
lines changed

3 files changed

+79
-27
lines changed

apps/pythonnative_demo/app/main.py

Lines changed: 0 additions & 27 deletions
This file was deleted.
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import pythonnative as pn
2+
3+
4+
class MainPage(pn.Page):
5+
def __init__(self, native_instance):
6+
super().__init__(native_instance)
7+
8+
def on_create(self):
9+
super().on_create()
10+
stack_view = pn.StackView(self.native_instance)
11+
# list_data = ["item_{}".format(i) for i in range(100)]
12+
# list_view = pn.ListView(self.native_instance, list_data)
13+
# stack_view.add_view(list_view)
14+
button = pn.Button(self.native_instance, "Button")
15+
button.set_on_click(lambda: self.navigate_to(""))
16+
# button.set_on_click(lambda: print("Button was clicked!"))
17+
stack_view.add_view(button)
18+
self.set_root_view(stack_view)
19+
20+
def on_start(self):
21+
super().on_start()
22+
23+
def on_resume(self):
24+
super().on_resume()
25+
26+
def on_pause(self):
27+
super().on_pause()
28+
29+
def on_stop(self):
30+
super().on_stop()
31+
32+
def on_destroy(self):
33+
super().on_destroy()
34+
35+
def on_restart(self):
36+
super().on_restart()
37+
38+
def on_save_instance_state(self):
39+
super().on_save_instance_state()
40+
41+
def on_restore_instance_state(self):
42+
super().on_restore_instance_state()
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import pythonnative as pn
2+
3+
4+
class SecondPage(pn.Page):
5+
def __init__(self, native_instance):
6+
super().__init__(native_instance)
7+
8+
def on_create(self):
9+
super().on_create()
10+
stack_view = pn.StackView(self.native_instance)
11+
label = pn.Label(self.native_instance, "Second page!")
12+
stack_view.add_view(label)
13+
self.set_root_view(stack_view)
14+
15+
def on_start(self):
16+
super().on_start()
17+
18+
def on_resume(self):
19+
super().on_resume()
20+
21+
def on_pause(self):
22+
super().on_pause()
23+
24+
def on_stop(self):
25+
super().on_stop()
26+
27+
def on_destroy(self):
28+
super().on_destroy()
29+
30+
def on_restart(self):
31+
super().on_restart()
32+
33+
def on_save_instance_state(self):
34+
super().on_save_instance_state()
35+
36+
def on_restore_instance_state(self):
37+
super().on_restore_instance_state()

0 commit comments

Comments
 (0)