Orientation · Lesson 03 of 05

Explore Data and Source with the inspector

Distinguish node values from attributes, then create, move and modify interface elements through live Source.

3:31 · English6 sectionsPrerequisites: The bound page from lesson 02 and the optional published Inspector included in the setup instructions.
Course contents
WATCH THE LESSON3:31 · English
Download MP4 ↓English captions ↓

Animated Inspector lesson: explore Data and Source, distinguish values from attributes, then create, drag and style an element in the running page. Real Inspector and browser captures with synchronized English narration. AI-generated English narration, captions and runnable examples included.

Read the transcript / on-screen steps

00:00:00 In this lesson we will explore the running page with the Inspector.

00:00:04 First, we will distinguish Data from Source, and a node value from its attributes.

00:00:09 Then we will create an element, drag it to another container, and change its

00:00:13 appearance.

00:00:14 Every change will appear alongside the Inspector, in the actual browser.

00:00:20 We continue with the border container and fields from lesson two, using the

00:00:25 downloadable Inspector example.

00:00:27 It adds a notes section and readable Source labels, so we can identify the elements

00:00:32 in the tree.

00:00:33 The optional Inspector is installed in the tools folder; the downloaded development

00:00:38 host provides an Open Inspector button.

00:00:41 Start Uvicorn with automatic reload.

00:00:43 Open the local address in the browser.

00:00:46 Now click Open Inspector.

00:00:48 The Inspector is enlarged on the left, while the same running page stays on the

00:00:53 right.

00:00:55 Select the Data tab, expand demo, and select message.

00:00:59 This node has a value, Welcome to Gramlot, and a named attribute, note.

00:01:03 The value supplies the heading and the message input, through their pointers.

00:01:08 Type Hello from Inspector in Value, then press Enter to confirm.

00:01:13 The heading and input now show the new value, without saving Python or reloading the

00:01:18 browser.

00:01:20 Keep the same Data node selected.

00:01:22 The note field is an attribute attached to this node, not another copy of its value.

00:01:28 Change that attribute to Metadata, not the greeting, and press Enter.

00:01:32 The note has changed, but the heading still says Hello from Inspector.

00:01:37 Our heading reads the node value; it does not read the note attribute.

00:01:42 Switch to Source.

00:01:44 Expand main, page, layout, and header; then select greeting.

00:01:48 The value here is the pointer, caret demo dot message, rather than the text it

00:01:53 resolves to.

00:01:54 The attributes describe the element: its tag, colour binding, and margin.

00:01:59 Data supplies the changing values, while Source describes the interface that uses

00:02:04 them.

00:02:06 Select page and use Add child element.

00:02:09 Choose the HTML tag p and confirm Add.

00:02:12 Select the new paragraph and set its value to Created in the Inspector.

00:02:17 Press Enter.

00:02:18 The paragraph appears in the running page.

00:02:20 We changed Source, and the renderer created the element without a browser refresh.

00:02:27 Drag the paragraph node onto notes in the Source tree.

00:02:31 The paragraph is now inside the green Notes section.

00:02:35 Its position in the Source tree determines where it belongs in the interface.

00:02:39 We moved the declaration, and the rendered element followed.

00:02:44 Select the moved paragraph and choose Add attribute.

00:02:48 Name the attribute style.

00:02:50 Enter color, colon, crimson, semicolon, font weight, colon, bold, then press Enter.

00:02:55 The same paragraph is now crimson and bold.

00:02:58 Its value still supplies the text; the style attribute changes its appearance.

00:03:05 We have explored Data and Source, and distinguished node values from attributes.

00:03:10 We have changed a greeting, created an element, moved it, and changed its

00:03:14 appearance.

00:03:15 The interface follows Source, with reactive pointers connecting it to Data.

00:03:19 These edits changed the running stores; they did not rewrite the Python file.

00:03:24 To keep the result after a reload, put the corresponding declarations into the saved

00:03:29 Page.

What we will learn

Explore Data and Source in the running application. Distinguish a node value from its named attributes, then create a paragraph, move it into a different container and change its appearance.

The animated workspace keeps the enlarged, real Inspector on the left and the running page on the right. Typed edits, confirmation with Enter and the drag gesture are synchronized with the narration.

Follow the recorded example

Use stages/03_inspector.py from the runnable examples download. It continues the border container and fields from lesson 02, with a compact layout and a Notes section. The optional published Inspector is installed separately and opened through the development host’s Open Inspector button. Recordings use Gramlot 0.3.8 and Python adapter 0.2.12.

The node_label names identify page, layout, header, greeting and notes in Source. They make the declarations easy to recognize in the Inspector. The note attribute on demo.message is introduced specifically to distinguish an attribute from the node’s value.

Data: edit a value, then an attribute

In Data, expand demo and select message. Its value is Welcome to Gramlot. Change Value to Hello from Inspector and press Enter: the heading and Message input update together, without saving Python or refreshing the browser.

The same node has a note attribute. Change it to Metadata, not the greeting and confirm. The heading stays Hello from Inspector because ^demo.message reads the node value, not its note attribute. A node’s value and its named attributes are separate properties.

Source: inspect the declaration

In Source, expand main → page → layout → header and select greeting. Its value is ^demo.message, the pointer written in the Page, rather than the resolved greeting. Its color attribute contains ^demo.color.

Source describes the element and its properties; Data contains the values those pointers read. A node value can also contain a Bag of children, as it does for the layout containers.

Create, move and style an element live

Select page and use Add child element. Choose the HTML tag p, confirm Add, then select the new paragraph. Set its Value to Created in the Inspector and press Enter. The paragraph appears in the running page.

Drag p_0 onto notes in the Source tree. The paragraph moves inside the green Notes section. Select it, add a style attribute with color: crimson; font-weight: bold, and confirm: the paragraph becomes crimson and bold while its text stays the same.

What we have learned

Changes to the stores’ structure, values and attributes drive the corresponding interface updates. Source describes what is rendered; reactive pointers connect that description to Data. The Inspector lets us observe and edit those same stores.

These are edits to the running page. They do not automatically rewrite the Python file. To preserve a result after a reload, express the corresponding declarations in the saved Page.

Your turn

Try it yourself

  1. Change demo.message in Data and verify that both heading and Message input follow it.
  2. Change the note attribute and explain why the greeting does not change.
  3. Create a paragraph in Source, drag it into notes, then make it crimson and bold.
  4. Reproduce the intended change in the Python Page so that it survives a reload.

Check your understanding

Does changing the note attribute of demo.message change the node value?

Show the answer and expected result

No. The value and its named attributes are separate. The heading reads the value through ^demo.message, so editing note leaves the greeting unchanged. Live Inspector edits also leave the Python source file unchanged.

Working examples and reference