Skip to content

Commit eca8cb7

Browse files
committed
docs: update website
1 parent a7d19b8 commit eca8cb7

2 files changed

Lines changed: 161 additions & 0 deletions

File tree

docs/vitepress/.vitepress/config.mjs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ export default defineConfig({
7777
{ text: 'Introduction', link: '/guide/versions/' },
7878
{ text: 'From 1 to 2', link: '/guide/versions/trame_v1-2' },
7979
{ text: 'From 2 to 3', link: '/guide/versions/trame_v2-3' },
80+
{ text: 'Features', link: '/guide/versions/features' },
8081
]
8182
},
8283
{
Lines changed: 160 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,160 @@
1+
# Features by versions
2+
3+
## Version 3.9
4+
5+
This version is bringing new classes to help with application or component setup.
6+
7+
Here is an example for on how to use them.
8+
9+
```python
10+
from trame.app import TrameApp
11+
from trame.decorators import change, controller, life_cycle, trigger
12+
from trame.ui.html import DivLayout
13+
from trame.widgets import html
14+
15+
16+
class App(TrameApp):
17+
def __init__(self, name=None):
18+
super().__init__(name)
19+
self._build_ui()
20+
21+
@trigger("exec")
22+
def method_call(self, msg):
23+
print("method_called", msg)
24+
25+
@controller.set("hello")
26+
def method_on_ctrl(self, *args):
27+
print("method_on_ctrl", args)
28+
29+
@change("resolution")
30+
def one_slider(self, resolution, **kwargs):
31+
print("Slider value 1", resolution)
32+
33+
@life_cycle.server_ready
34+
def on_ready(self, *args, **kwargs):
35+
print("on_ready")
36+
37+
def _build_ui(self):
38+
with DivLayout(self.server) as self.ui:
39+
html.Input(
40+
type="range",
41+
min=3,
42+
max=60,
43+
step=1,
44+
v_model_number=("resolution", 6),
45+
)
46+
html.Button("trigger", click="trigger('exec', ['trigger'])")
47+
html.Button("method", click=(self.method_call, "['method']"))
48+
html.Button("ctrl", click=self.ctrl.hello)
49+
50+
51+
if __name__ == "__main__":
52+
app = App()
53+
app.server.start()
54+
```
55+
56+
On top of those classes, some improvements have been made for handling properties and events regardless of them being registered.
57+
Here are some examples on how to make use of them. Also widgets support method decorators like the TrameApp base class.
58+
59+
```python
60+
html.Div(
61+
v_on_click_prevent_stop="...", # => @click.prevent.stop="..."
62+
v_bind_hello_world="...", # => :hello.world="..."
63+
)
64+
```
65+
66+
## Version 3.8
67+
68+
The @TrameApp decorator now support inheritance.
69+
70+
## Version 3.7
71+
72+
DeepReactive available in `client` for vue3 only.
73+
74+
## Version 3.6
75+
76+
New network layer relying on binary message exchange with automatic chunking to enable large data exchange without timeout or proxy disconnection.
77+
78+
## Version 3.5
79+
80+
vue3 is the new default in get_server and docker setup.
81+
82+
## Version 3.4
83+
84+
Infrastructure for enabling namespace isolation via child_server.
85+
86+
## Version 3.3
87+
88+
A new tool is available for serving an application for multiple users from a single process. The documentation is available [here](https://trame.readthedocs.io/en/latest/tools.serve.html) and for it to work, the application needs to expect a server in its constructor.
89+
90+
```bash
91+
# Assuming the code from 3.1 exist in a MyApp.py file
92+
# you can run it with the following command line
93+
94+
python -m trame.tools.serve --exec MyApp:App
95+
```
96+
97+
## Version 3.2
98+
99+
A new tool is available for generating widgets from a YAML description file. The usage documentation is available [here](https://trame.readthedocs.io/en/latest/tools.widgets.html).
100+
101+
102+
## Version 3.1
103+
104+
A new @TrameApp() decorator is available to help creating classes with method decorator. The following example illustrate such usage.
105+
106+
```python
107+
from trame.app import get_server
108+
from trame.decorators import TrameApp, change, controller, life_cycle, trigger
109+
from trame.ui.html import DivLayout
110+
from trame.widgets import html
111+
112+
113+
@TrameApp()
114+
class App:
115+
def __init__(self, name=None):
116+
self.server = get_server(name)
117+
self.ui()
118+
119+
@property
120+
def state(self):
121+
return self.server.state
122+
123+
@property
124+
def ctrl(self):
125+
return self.server.controller
126+
127+
@trigger("exec")
128+
def method_call(self, msg):
129+
print("method_called", msg)
130+
131+
@controller.set("hello")
132+
def method_on_ctrl(self, *args):
133+
print("method_on_ctrl", args)
134+
135+
@change("resolution")
136+
def one_slider(self, resolution, **kwargs):
137+
print("Slider value 1", resolution)
138+
139+
@life_cycle.server_ready
140+
def on_ready(self, *args, **kwargs):
141+
print("on_ready")
142+
143+
def ui(self):
144+
with DivLayout(self.server):
145+
html.Input(
146+
type="range",
147+
min=3,
148+
max=60,
149+
step=1,
150+
v_model_number=("resolution", 6),
151+
)
152+
html.Button("trigger", click="trigger('exec', ['trigger'])")
153+
html.Button("method", click=(self.method_call, "['method']"))
154+
html.Button("ctrl", click=self.ctrl.hello)
155+
156+
157+
if __name__ == "__main__":
158+
app = App()
159+
app.server.start()
160+
```

0 commit comments

Comments
 (0)