pythonnative 0.6.0__py3-none-any.whl → 0.7.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
pythonnative/__init__.py CHANGED
@@ -5,28 +5,16 @@ Public API::
5
5
  import pythonnative as pn
6
6
 
7
7
  @pn.component
8
- def counter(initial=0):
9
- count, set_count = pn.use_state(initial)
8
+ def App():
9
+ count, set_count = pn.use_state(0)
10
10
  return pn.Column(
11
- pn.Text(f"Count: {count}", font_size=24),
11
+ pn.Text(f"Count: {count}", style={"font_size": 24}),
12
12
  pn.Button("+", on_click=lambda: set_count(count + 1)),
13
- spacing=12,
13
+ style={"spacing": 12},
14
14
  )
15
-
16
- class MainPage(pn.Page):
17
- def __init__(self, native_instance):
18
- super().__init__(native_instance)
19
-
20
- def render(self):
21
- return pn.Column(
22
- counter(initial=0),
23
- counter(initial=10),
24
- spacing=16,
25
- padding=16,
26
- )
27
15
  """
28
16
 
29
- __version__ = "0.6.0"
17
+ __version__ = "0.7.0"
30
18
 
31
19
  from .components import (
32
20
  ActivityIndicator,
@@ -57,10 +45,11 @@ from .hooks import (
57
45
  use_context,
58
46
  use_effect,
59
47
  use_memo,
48
+ use_navigation,
60
49
  use_ref,
61
50
  use_state,
62
51
  )
63
- from .page import Page
52
+ from .page import create_page
64
53
  from .style import StyleSheet, ThemeContext
65
54
 
66
55
  __all__ = [
@@ -85,7 +74,7 @@ __all__ = [
85
74
  "WebView",
86
75
  # Core
87
76
  "Element",
88
- "Page",
77
+ "create_page",
89
78
  # Hooks
90
79
  "component",
91
80
  "create_context",
@@ -93,6 +82,7 @@ __all__ = [
93
82
  "use_context",
94
83
  "use_effect",
95
84
  "use_memo",
85
+ "use_navigation",
96
86
  "use_ref",
97
87
  "use_state",
98
88
  "Provider",
pythonnative/cli/pn.py CHANGED
@@ -48,25 +48,17 @@ def init_project(args: argparse.Namespace) -> None:
48
48
  f.write("""import pythonnative as pn
49
49
 
50
50
 
51
- class MainPage(pn.Page):
52
- def __init__(self, native_instance):
53
- super().__init__(native_instance)
54
- self.state = {"count": 0}
55
-
56
- def increment(self):
57
- self.set_state(count=self.state["count"] + 1)
58
-
59
- def render(self):
60
- return pn.ScrollView(
61
- pn.Column(
62
- pn.Text("Hello from PythonNative!", font_size=24, bold=True),
63
- pn.Text(f"Tapped {self.state['count']} times"),
64
- pn.Button("Tap me", on_click=self.increment),
65
- spacing=12,
66
- padding=16,
67
- alignment="fill",
68
- )
51
+ @pn.component
52
+ def MainPage():
53
+ count, set_count = pn.use_state(0)
54
+ return pn.ScrollView(
55
+ pn.Column(
56
+ pn.Text("Hello from PythonNative!", style={"font_size": 24, "bold": True}),
57
+ pn.Text(f"Tapped {count} times"),
58
+ pn.Button("Tap me", on_click=lambda: set_count(count + 1)),
59
+ style={"spacing": 12, "padding": 16, "align_items": "stretch"},
69
60
  )
61
+ )
70
62
  """)
71
63
 
72
64
  # Create config