-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathedifice.html
859 lines (676 loc) · 51.1 KB
/
edifice.html
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
<!DOCTYPE html>
<html lang="en" data-content_root="./" >
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Edifice Core — Edifice 3.2.2 documentation</title>
<script data-cfasync="false">
document.documentElement.dataset.mode = localStorage.getItem("mode") || "";
document.documentElement.dataset.theme = localStorage.getItem("theme") || "";
</script>
<!--
this give us a css class that will be invisible only if js is disabled
-->
<noscript>
<style>
.pst-js-only { display: none !important; }
</style>
</noscript>
<!-- Loaded before other Sphinx assets -->
<link href="_static/styles/theme.css?digest=8878045cc6db502f8baf" rel="stylesheet" />
<link href="_static/styles/pydata-sphinx-theme.css?digest=8878045cc6db502f8baf" rel="stylesheet" />
<link rel="stylesheet" type="text/css" href="_static/pygments.css?v=a746c00c" />
<link rel="stylesheet" type="text/css" href="_static/copybutton.css?v=76b2166b" />
<link rel="stylesheet" type="text/css" href="_static/css/custom.css?v=84af4edc" />
<!-- So that users can add custom icons -->
<script src="_static/scripts/fontawesome.js?digest=8878045cc6db502f8baf"></script>
<!-- Pre-loaded scripts that we'll load fully later -->
<link rel="preload" as="script" href="_static/scripts/bootstrap.js?digest=8878045cc6db502f8baf" />
<link rel="preload" as="script" href="_static/scripts/pydata-sphinx-theme.js?digest=8878045cc6db502f8baf" />
<script src="_static/documentation_options.js?v=dcedd534"></script>
<script src="_static/doctools.js?v=9bcbadda"></script>
<script src="_static/sphinx_highlight.js?v=dc90522c"></script>
<script src="_static/clipboard.min.js?v=a7894cd8"></script>
<script src="_static/copybutton.js?v=f281be69"></script>
<script>DOCUMENTATION_OPTIONS.pagename = 'edifice';</script>
<link rel="icon" href="_static/EdificePyramid.ico"/>
<link rel="index" title="Index" href="genindex.html" />
<link rel="search" title="Search" href="search.html" />
<link rel="next" title="edifice.App" href="stubs/edifice.App.html" />
<link rel="prev" title="API" href="api.html" />
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<meta name="docsearch:language" content="en"/>
<meta name="docsearch:version" content="" />
</head>
<body data-bs-spy="scroll" data-bs-target=".bd-toc-nav" data-offset="180" data-bs-root-margin="0px 0px -60%" data-default-mode="">
<div id="pst-skip-link" class="skip-link d-print-none"><a href="#main-content">Skip to main content</a></div>
<div id="pst-scroll-pixel-helper"></div>
<button type="button" class="btn rounded-pill" id="pst-back-to-top">
<i class="fa-solid fa-arrow-up"></i>Back to top</button>
<dialog id="pst-search-dialog">
<form class="bd-search d-flex align-items-center"
action="search.html"
method="get">
<i class="fa-solid fa-magnifying-glass"></i>
<input type="search"
class="form-control"
name="q"
placeholder="Search the docs ..."
aria-label="Search the docs ..."
autocomplete="off"
autocorrect="off"
autocapitalize="off"
spellcheck="false"/>
<span class="search-button__kbd-shortcut"><kbd class="kbd-shortcut__modifier">Ctrl</kbd>+<kbd>K</kbd></span>
</form>
</dialog>
<div class="pst-async-banner-revealer d-none">
<aside id="bd-header-version-warning" class="d-none d-print-none" aria-label="Version warning"></aside>
</div>
<header class="bd-header navbar navbar-expand-lg bd-navbar d-print-none">
<div class="bd-header__inner bd-page-width">
<button class="pst-navbar-icon sidebar-toggle primary-toggle" aria-label="Site navigation">
<span class="fa-solid fa-bars"></span>
</button>
<div class="col-lg-3 navbar-header-items__start">
<div class="navbar-item">
<a class="navbar-brand logo" href="index.html">
<img src="_static/EdificePyramid.svg" class="logo__image only-light" alt="Edifice 3.2.2 documentation - Home"/>
<img src="_static/EdificePyramid.svg" class="logo__image only-dark pst-js-only" alt="Edifice 3.2.2 documentation - Home"/>
</a></div>
</div>
<div class="col-lg-9 navbar-header-items">
<div class="me-auto navbar-header-items__center">
<div class="navbar-item">
<nav>
<ul class="bd-navbar-elements navbar-nav">
<li class="nav-item ">
<a class="nav-link nav-internal" href="tutorial.html">
Tutorial
</a>
</li>
<li class="nav-item ">
<a class="nav-link nav-internal" href="examples.html">
Examples
</a>
</li>
<li class="nav-item current active">
<a class="nav-link nav-internal" href="api.html">
API
</a>
</li>
<li class="nav-item ">
<a class="nav-link nav-internal" href="developer_tools.html">
Developer Tools
</a>
</li>
<li class="nav-item ">
<a class="nav-link nav-internal" href="versions.html">
Release Notes
</a>
</li>
</ul>
</nav></div>
</div>
<div class="navbar-header-items__end">
<div class="navbar-item navbar-persistent--container">
<button class="btn search-button-field search-button__button pst-js-only" title="Search" aria-label="Search" data-bs-placement="bottom" data-bs-toggle="tooltip">
<i class="fa-solid fa-magnifying-glass"></i>
<span class="search-button__default-text">Search</span>
<span class="search-button__kbd-shortcut"><kbd class="kbd-shortcut__modifier">Ctrl</kbd>+<kbd class="kbd-shortcut__modifier">K</kbd></span>
</button>
</div>
<div class="navbar-item">
<button class="btn btn-sm nav-link pst-navbar-icon theme-switch-button pst-js-only" aria-label="Color mode" data-bs-title="Color mode" data-bs-placement="bottom" data-bs-toggle="tooltip">
<i class="theme-switch fa-solid fa-sun fa-lg" data-mode="light" title="Light"></i>
<i class="theme-switch fa-solid fa-moon fa-lg" data-mode="dark" title="Dark"></i>
<i class="theme-switch fa-solid fa-circle-half-stroke fa-lg" data-mode="auto" title="System Settings"></i>
</button></div>
<div class="navbar-item"><ul class="navbar-icon-links"
aria-label="Icon Links">
<li class="nav-item">
<a href="https://github.com/pyedifice/pyedifice" title="GitHub" class="nav-link pst-navbar-icon" rel="noopener" target="_blank" data-bs-toggle="tooltip" data-bs-placement="bottom"><i class="fa-brands fa-github fa-lg" aria-hidden="true"></i>
<span class="sr-only">GitHub</span></a>
</li>
</ul></div>
</div>
</div>
<div class="navbar-persistent--mobile">
<button class="btn search-button-field search-button__button pst-js-only" title="Search" aria-label="Search" data-bs-placement="bottom" data-bs-toggle="tooltip">
<i class="fa-solid fa-magnifying-glass"></i>
<span class="search-button__default-text">Search</span>
<span class="search-button__kbd-shortcut"><kbd class="kbd-shortcut__modifier">Ctrl</kbd>+<kbd class="kbd-shortcut__modifier">K</kbd></span>
</button>
</div>
<button class="pst-navbar-icon sidebar-toggle secondary-toggle" aria-label="On this page">
<span class="fa-solid fa-outdent"></span>
</button>
</div>
</header>
<div class="bd-container">
<div class="bd-container__inner bd-page-width">
<dialog id="pst-primary-sidebar-modal"></dialog>
<div id="pst-primary-sidebar" class="bd-sidebar-primary bd-sidebar hide-on-wide">
<div class="sidebar-header-items sidebar-primary__section">
<div class="sidebar-header-items__center">
<div class="navbar-item">
<nav>
<ul class="bd-navbar-elements navbar-nav">
<li class="nav-item ">
<a class="nav-link nav-internal" href="tutorial.html">
Tutorial
</a>
</li>
<li class="nav-item ">
<a class="nav-link nav-internal" href="examples.html">
Examples
</a>
</li>
<li class="nav-item current active">
<a class="nav-link nav-internal" href="api.html">
API
</a>
</li>
<li class="nav-item ">
<a class="nav-link nav-internal" href="developer_tools.html">
Developer Tools
</a>
</li>
<li class="nav-item ">
<a class="nav-link nav-internal" href="versions.html">
Release Notes
</a>
</li>
</ul>
</nav></div>
</div>
<div class="sidebar-header-items__end">
<div class="navbar-item">
<button class="btn btn-sm nav-link pst-navbar-icon theme-switch-button pst-js-only" aria-label="Color mode" data-bs-title="Color mode" data-bs-placement="bottom" data-bs-toggle="tooltip">
<i class="theme-switch fa-solid fa-sun fa-lg" data-mode="light" title="Light"></i>
<i class="theme-switch fa-solid fa-moon fa-lg" data-mode="dark" title="Dark"></i>
<i class="theme-switch fa-solid fa-circle-half-stroke fa-lg" data-mode="auto" title="System Settings"></i>
</button></div>
<div class="navbar-item"><ul class="navbar-icon-links"
aria-label="Icon Links">
<li class="nav-item">
<a href="https://github.com/pyedifice/pyedifice" title="GitHub" class="nav-link pst-navbar-icon" rel="noopener" target="_blank" data-bs-toggle="tooltip" data-bs-placement="bottom"><i class="fa-brands fa-github fa-lg" aria-hidden="true"></i>
<span class="sr-only">GitHub</span></a>
</li>
</ul></div>
</div>
</div>
<div class="sidebar-primary-items__end sidebar-primary__section">
<div class="sidebar-primary-item">
<div id="ethical-ad-placement"
class="flat"
data-ea-publisher="readthedocs"
data-ea-type="readthedocs-sidebar"
data-ea-manual="true">
</div></div>
</div>
</div>
<main id="main-content" class="bd-main" role="main">
<div class="bd-content">
<div class="bd-article-container">
<div class="bd-header-article d-print-none">
<div class="header-article-items header-article__inner">
<div class="header-article-items__start">
<div class="header-article-item">
<nav aria-label="Breadcrumb" class="d-print-none">
<ul class="bd-breadcrumbs">
<li class="breadcrumb-item breadcrumb-home">
<a href="index.html" class="nav-link" aria-label="Home">
<i class="fa-solid fa-home"></i>
</a>
</li>
<li class="breadcrumb-item"><a href="api.html" class="nav-link">API</a></li>
<li class="breadcrumb-item active" aria-current="page"><span class="ellipsis">Edifice Core</span></li>
</ul>
</nav>
</div>
</div>
</div>
</div>
<div id="searchbox"></div>
<article class="bd-article">
<section id="edifice-core">
<h1>Edifice Core<a class="headerlink" href="#edifice-core" title="Link to this heading">#</a></h1>
<section id="class-overview">
<h2>Class overview<a class="headerlink" href="#class-overview" title="Link to this heading">#</a></h2>
<div class="pst-scrollable-table-container"><table class="autosummary longtable table autosummary">
<tbody>
<tr class="row-odd"><td><p><a class="reference internal" href="stubs/edifice.App.html#edifice.App" title="edifice.App"><code class="xref py py-obj docutils literal notranslate"><span class="pre">App</span></code></a>(root_element[, inspector, ...])</p></td>
<td><p>The main application object.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="stubs/edifice.Element.html#edifice.Element" title="edifice.Element"><code class="xref py py-obj docutils literal notranslate"><span class="pre">Element</span></code></a>()</p></td>
<td><p>The base class for Edifice Elements.</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="stubs/edifice.Reference.html#edifice.Reference" title="edifice.Reference"><code class="xref py py-obj docutils literal notranslate"><span class="pre">Reference</span></code></a>()</p></td>
<td><p>Reference to an <a class="reference internal" href="stubs/edifice.Element.html#edifice.Element" title="edifice.Element"><code class="xref py py-class docutils literal notranslate"><span class="pre">Element</span></code></a> for imperative commands.</p></td>
</tr>
</tbody>
</table>
</div>
<div class="pst-scrollable-table-container"><table class="autosummary longtable table autosummary">
<tbody>
<tr class="row-odd"><td><p><a class="reference internal" href="stubs/edifice.component.html#edifice.component" title="edifice.component"><code class="xref py py-obj docutils literal notranslate"><span class="pre">component</span></code></a>(f)</p></td>
<td><p>Decorator which turns a render function of <strong>props</strong> into an <a class="reference internal" href="stubs/edifice.Element.html#edifice.Element" title="edifice.Element"><code class="xref py py-class docutils literal notranslate"><span class="pre">Element</span></code></a>.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="stubs/edifice.child_place.html#edifice.child_place" title="edifice.child_place"><code class="xref py py-obj docutils literal notranslate"><span class="pre">child_place</span></code></a>(element)</p></td>
<td><p>Place a child passed through the special <code class="code docutils literal notranslate"><span class="pre">children</span></code> <strong>props</strong> into the layout of a parent <a class="reference internal" href="stubs/edifice.component.html#edifice.component" title="edifice.component"><code class="xref py py-func docutils literal notranslate"><span class="pre">@component</span></code></a>.</p></td>
</tr>
</tbody>
</table>
</div>
</section>
<section id="edifice-programming-style">
<h2>Edifice Programming Style<a class="headerlink" href="#edifice-programming-style" title="Link to this heading">#</a></h2>
<p>Edifice favors a very opinionated “asynchronous” “declarative” “reactive”
style of Python and Qt which will be familiar to React users or
<a class="reference external" href="https://docs.python.org/3/howto/functional.html">Functional Programming</a>
enthusiasts.</p>
<section id="asynchronous">
<h3>Asynchronous<a class="headerlink" href="#asynchronous" title="Link to this heading">#</a></h3>
<p>The <a class="reference external" href="https://docs.python.org/3/library/asyncio-eventloop.html">asyncio eventloop</a>
is how Edifice programs structure control flow. Your Edifice
application should never (rarely) create a
<a class="reference external" href="https://docs.python.org/3/library/threading.html#threading.Thread">Thread</a>
or
<a class="reference external" href="https://doc.qt.io/qtforpython-6/PySide6/QtCore/QThread.html">QThread</a>
because there is no clean way to cancel or kill a Thread. Instead use
the <a class="reference internal" href="stubs/edifice.use_async.html#edifice.use_async" title="edifice.use_async"><code class="xref py py-func docutils literal notranslate"><span class="pre">use_async()</span></code></a> or <a class="reference internal" href="stubs/edifice.use_async_call.html#edifice.use_async_call" title="edifice.use_async_call"><code class="xref py py-func docutils literal notranslate"><span class="pre">use_async_call()</span></code></a> Hooks for asynchronous concurrency.</p>
<p>If you’re using a library which requires you to call a brief “blocking” function
then use
<a class="reference external" href="https://docs.python.org/3/library/asyncio-eventloop.html#asyncio.loop.run_in_executor">run_in_executor</a>
with a
<a class="reference external" href="https://docs.python.org/3/library/concurrent.futures.html#concurrent.futures.ThreadPoolExecutor">ThreadPoolExecutor</a>.</p>
<p>If you’re using a library which requires you to call a long-running “blocking” function
then use <a class="reference internal" href="run_subprocess_with_callback.html#edifice.run_subprocess_with_callback" title="edifice.run_subprocess_with_callback"><code class="xref py py-func docutils literal notranslate"><span class="pre">run_subprocess_with_callback()</span></code></a>.</p>
</section>
<section id="declarative">
<h3>Declarative<a class="headerlink" href="#declarative" title="Link to this heading">#</a></h3>
<p>There is a lot of imperative and object-oriented Qt API which is meaningless
or unnecessary in Edifice. In a normal Edifice application you will never (rarely)
“inherit” from a class or override a “virtual” method.</p>
<p>You never “add” or “remove” a widget in Edifice, instead you conditionally
render it. When the condition is no longer true the widget will be removed,
see <a class="reference internal" href="#dynamic-rendering"><span class="std std-ref">Dynamic Rendering</span></a>.</p>
<p><a class="reference external" href="https://doc.qt.io/qtforpython-6/api/qtwidgets/qwidget.html">QWidgets</a>
are stateful objects but Edifice is designed to provide a
<em>stateless</em> API for QWidgets. Each <a class="reference internal" href="base_components.html"><span class="doc">Base Element</span></a> wraps
a QWidget and presents it as a pure stateless function which depends only on
its <strong>props</strong>.</p>
<p>In Edifice there are no <code class="code docutils literal notranslate"><span class="pre">QAbstractItemModel</span></code> interfaces
<a class="reference external" href="https://doc.qt.io/qtforpython-6/overviews/qtwidgets-model-view-programming.html#models">“used by views and delegates to access data”</a>
because in Edifice the data is passed as <strong>props</strong> and no other way.</p>
<p>For more information see <a class="reference internal" href="#declaring-element-trees"><span class="std std-ref">Declaring Element Trees</span></a>.</p>
</section>
<section id="reactive">
<h3>Reactive<a class="headerlink" href="#reactive" title="Link to this heading">#</a></h3>
<p>For handling <a class="reference internal" href="base_components.html#events"><span class="std std-ref">Events</span></a>, pass a event-handling function as a <strong>prop</strong>.</p>
<p>Never (rarely) use Signals and Slots. The
<a class="reference external" href="https://doc.qt.io/qtforpython-6/tutorials/basictutorial/signals_and_slots.html">Signals and Slots</a>
tutorial explains that
“Due to the nature of Qt, QObjects require a way to communicate” but
due to the nature of Edifice, QObjects are mostly forbidden to communicate
because it would violate the <em>one-way information flow</em> of <a class="reference internal" href="#model-view-update"><span class="std std-ref">Model-View-Update</span></a>.</p>
<p>Application state is managed with <a class="reference internal" href="stubs/edifice.use_state.html#edifice.use_state" title="edifice.use_state"><code class="xref py py-func docutils literal notranslate"><span class="pre">use_state()</span></code></a> Hooks.</p>
<p>Application side-effects triggered by state changes are performed by
<a class="reference internal" href="stubs/edifice.use_effect.html#edifice.use_effect" title="edifice.use_effect"><code class="xref py py-func docutils literal notranslate"><span class="pre">use_effect()</span></code></a> and <a class="reference internal" href="stubs/edifice.use_async.html#edifice.use_async" title="edifice.use_async"><code class="xref py py-func docutils literal notranslate"><span class="pre">use_async()</span></code></a> Hooks.</p>
</section>
</section>
<section id="rules-of-edifice">
<h2>Rules of Edifice<a class="headerlink" href="#rules-of-edifice" title="Link to this heading">#</a></h2>
<p>Are the same as the <a class="reference external" href="https://react.dev/reference/rules">Rules of React</a>.</p>
<p><strong>Components and Hooks must be pure</strong></p>
<p>Purity in Components and Hooks is a key rule of Edifice that makes your app
predictable, easy to debug, and allows Edifice to automatically optimize your code.</p>
<ul class="simple">
<li><p><strong>Components must be idempotent</strong> – Edifice components are assumed to always
return the same output with respect to their inputs – props, state, and context.</p></li>
<li><p><strong>Side effects must run outside of render</strong> – Side effects should not run in
render.</p></li>
<li><p><strong>Props and state are immutable</strong> – A component’s props and state are
immutable snapshots with respect to a single render. Never mutate them directly.</p></li>
<li><p><strong>Return values and arguments to Hooks are immutable</strong> – Once values are
passed to a Hook, you should not modify them. Like props in an Element,
values become immutable when passed to a Hook.</p></li>
<li><p><strong>Values are immutable after being passed to an Element</strong> – Don’t mutate
values after they’ve been used in an Element. Move the mutation before the
Element is created.</p></li>
</ul>
</section>
<section id="declaring-element-trees">
<h2>Declaring Element Trees<a class="headerlink" href="#declaring-element-trees" title="Link to this heading">#</a></h2>
<p>An edifice application is created by rendering a <a class="reference internal" href="stubs/edifice.Element.html#edifice.Element" title="edifice.Element"><code class="xref py py-class docutils literal notranslate"><span class="pre">Element</span></code></a> with an
<a class="reference internal" href="stubs/edifice.App.html#edifice.App" title="edifice.App"><code class="xref py py-class docutils literal notranslate"><span class="pre">App</span></code></a>.</p>
<p>The rendering for an Edifice application is done by declaring a tree of Elements
starting with a single root <a class="reference internal" href="stubs/edifice.component.html#edifice.component" title="edifice.component"><code class="xref py py-func docutils literal notranslate"><span class="pre">@component</span></code></a>, and then declaring its children.</p>
<p>An Element may be either a
<a class="reference internal" href="base_components.html"><span class="doc">Base Element</span></a>
or a <a class="reference internal" href="stubs/edifice.component.html#edifice.component" title="edifice.component"><code class="xref py py-func docutils literal notranslate"><span class="pre">@component</span></code></a> Element.</p>
<p>A <a class="reference internal" href="stubs/edifice.component.html#edifice.component" title="edifice.component"><code class="xref py py-func docutils literal notranslate"><span class="pre">@component</span></code></a> Element is a render function decorated by
<code class="code docutils literal notranslate"><span class="pre">@component</span></code> which renders an <a class="reference internal" href="stubs/edifice.Element.html#edifice.Element" title="edifice.Element"><code class="xref py py-class docutils literal notranslate"><span class="pre">Element</span></code></a> tree.</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="nd">@component</span>
<span class="k">def</span> <span class="nf">Foo</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">a</span><span class="p">:</span><span class="nb">int</span><span class="p">,</span> <span class="n">b</span><span class="p">:</span><span class="nb">str</span><span class="p">,</span> <span class="n">c</span><span class="p">:</span><span class="nb">float</span><span class="p">):</span> <span class="c1"># a, b, c are the props</span>
</pre></div>
</div>
<p>The properties of an Element, the <strong>props</strong>, are passed as arguments to
the Element:</p>
<p>The <strong>props</strong> are owned by the external caller and must not be modified by
the Element.</p>
<p>Render a <code class="code docutils literal notranslate"><span class="pre">Foo</span></code> with props:</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">Foo</span><span class="p">(</span><span class="n">a</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span> <span class="n">b</span><span class="o">=</span><span class="s2">"2"</span><span class="p">,</span> <span class="n">c</span><span class="o">=</span><span class="mf">3.0</span><span class="p">)</span>
</pre></div>
</div>
<p>A <a class="reference internal" href="stubs/edifice.component.html#edifice.component" title="edifice.component"><code class="xref py py-func docutils literal notranslate"><span class="pre">@component</span></code></a> Element can have internal <strong>state</strong> managed
by the <a class="reference internal" href="stubs/edifice.use_state.html#edifice.use_state" title="edifice.use_state"><code class="xref py py-func docutils literal notranslate"><span class="pre">use_state()</span></code></a> Hook.</p>
<p>Changes in <strong>props</strong> or <strong>state</strong> will automatically trigger a re-render.</p>
<p>Declaring an Element tree in a <a class="reference internal" href="stubs/edifice.component.html#edifice.component" title="edifice.component"><code class="xref py py-func docutils literal notranslate"><span class="pre">@component</span></code></a> Element render function looks
like this.
To declare an Element to be the parent of some other
child Elements in the tree, use the parent as a
<a class="reference external" href="https://docs.python.org/3/reference/datamodel.html#context-managers">with statement context manager</a>.</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="nd">@component</span>
<span class="k">def</span> <span class="nf">MyApp</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="k">with</span> <span class="n">Window</span><span class="p">():</span>
<span class="k">with</span> <span class="n">VBoxView</span><span class="p">():</span>
<span class="k">with</span> <span class="n">HBoxView</span><span class="p">():</span>
<span class="n">Label</span><span class="p">(</span><span class="n">text</span><span class="o">=</span><span class="s2">"Username: "</span><span class="p">)</span>
<span class="n">TextInput</span><span class="p">()</span>
<span class="k">with</span> <span class="n">HBoxView</span><span class="p">():</span>
<span class="n">Label</span><span class="p">(</span><span class="n">text</span><span class="o">=</span><span class="s2">"Email: "</span><span class="p">)</span>
<span class="n">TextInput</span><span class="p">()</span>
</pre></div>
</div>
<p>In HTML/XML/JSX, this would be written as:</p>
<div class="highlight-xml notranslate"><div class="highlight"><pre><span></span><span class="nt"><Window></span>
<span class="w"> </span><span class="nt"><VBoxView></span>
<span class="w"> </span><span class="nt"><HBoxView></span>
<span class="w"> </span><span class="nt"><Label</span><span class="w"> </span><span class="na">text=</span><span class="s">"Username: "</span><span class="w"> </span><span class="nt">/></span>
<span class="w"> </span><span class="nt"><TextInput</span><span class="w"> </span><span class="nt">/></span>
<span class="w"> </span><span class="nt"></HBoxView></span>
<span class="w"> </span><span class="nt"><HBoxView></span>
<span class="w"> </span><span class="nt"><Label</span><span class="w"> </span><span class="na">text=</span><span class="s">"Email: "</span><span class="w"> </span><span class="nt">/></span>
<span class="w"> </span><span class="nt"><TextInput</span><span class="w"> </span><span class="nt">/></span>
<span class="w"> </span><span class="nt"></HBoxView></span>
<span class="w"> </span><span class="nt"></VBoxView></span>
<span class="nt"></Window></span>
</pre></div>
</div>
<p>You describe your entire application as a single root Element,
which has child Elements representing different parts of your application.</p>
<section id="dynamic-rendering">
<h3>Dynamic Rendering<a class="headerlink" href="#dynamic-rendering" title="Link to this heading">#</a></h3>
<p>For dynamism, use conditions and loops in your <a class="reference internal" href="stubs/edifice.component.html#edifice.component" title="edifice.component"><code class="xref py py-func docutils literal notranslate"><span class="pre">@component</span></code></a>
render function.
The conditions and loops can depend on <strong>props</strong> or <strong>state</strong>. For example,
this <a class="reference internal" href="stubs/edifice.component.html#edifice.component" title="edifice.component"><code class="xref py py-func docutils literal notranslate"><span class="pre">@component</span></code></a> will render input fields only while
the <strong>props</strong> indicate that they are wanted.</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="nd">@component</span>
<span class="k">def</span> <span class="nf">MyApp</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">want_username</span><span class="p">:</span><span class="nb">bool</span><span class="p">,</span> <span class="n">want_email</span><span class="p">:</span><span class="nb">bool</span><span class="p">):</span>
<span class="k">with</span> <span class="n">Window</span><span class="p">():</span>
<span class="k">with</span> <span class="n">VBoxView</span><span class="p">():</span>
<span class="k">if</span> <span class="n">want_username</span><span class="p">:</span>
<span class="k">with</span> <span class="n">HBoxView</span><span class="p">():</span>
<span class="n">Label</span><span class="p">(</span><span class="n">text</span><span class="o">=</span><span class="s2">"Username: "</span><span class="p">)</span>
<span class="n">TextInput</span><span class="p">()</span>
<span class="k">if</span> <span class="n">want_email</span><span class="p">:</span>
<span class="k">with</span> <span class="n">HBoxView</span><span class="p">():</span>
<span class="n">Label</span><span class="p">(</span><span class="n">text</span><span class="o">=</span><span class="s2">"Email: "</span><span class="p">)</span>
<span class="n">TextInput</span><span class="p">()</span>
</pre></div>
</div>
</section>
</section>
<section id="model-view-update">
<h2>Model-View-Update<a class="headerlink" href="#model-view-update" title="Link to this heading">#</a></h2>
<p>Edifice, like React, uses the <a class="reference external" href="https://guide.elm-lang.org/architecture/">Elm Architecture</a>,
also known as Model-View-Update.
This means that there is a <em>one-way information flow</em> from Model to View to
Update and then back to Model.</p>
<div class="pst-scrollable-table-container"><table class="table">
<tbody>
<tr class="row-odd"><td><p><strong>Model</strong></p></td>
<td><p>The <strong>state</strong> of the application declared with <a class="reference internal" href="stubs/edifice.use_state.html#edifice.use_state" title="edifice.use_state"><code class="xref py py-func docutils literal notranslate"><span class="pre">use_state()</span></code></a>.</p></td>
</tr>
<tr class="row-even"><td><p><strong>View</strong></p></td>
<td><p>The <a class="reference internal" href="stubs/edifice.component.html#edifice.component" title="edifice.component"><code class="xref py py-func docutils literal notranslate"><span class="pre">@component</span></code></a> render function takes the <strong>state</strong> and renders an Element tree of Qt Widgets.</p></td>
</tr>
<tr class="row-odd"><td><p><strong>Update</strong></p></td>
<td><p>Qt Widget event handlers which change the <strong>state</strong>.</p></td>
</tr>
</tbody>
</table>
</div>
<figure class="align-default">
<a class="reference internal image-reference" href="_images/model-view-update.svg"><img alt="_images/model-view-update.svg" src="_images/model-view-update.svg" style="width: 600px;" />
</a>
</figure>
<p>It is the <em>one-way information flow</em> of Model-View-Update which
differentiates it from Model-View-Controller, and which makes the
Model-View-Update style
of GUI programming scale up well to complicated user interfaces
while remaining well-organized and bug-free.</p>
<p>Compare this to the
<a class="reference external" href="https://doc.qt.io/qtforpython-6/overviews/qtquick-modelviewsdata-modelview.html">Models and Views in Qt Quick</a>
and notice how in Qt Quick the information flow is bidirectional through the <strong>Delegate</strong>.</p>
<figure class="align-default">
<img alt="https://doc.qt.io/qtforpython-6/_images/modelview-overview.png" src="https://doc.qt.io/qtforpython-6/_images/modelview-overview.png" />
</figure>
</section>
<section id="rendering">
<h2>Rendering<a class="headerlink" href="#rendering" title="Link to this heading">#</a></h2>
<p>Conceptually, Edifice (and React) works like this: Every time there is a
change (Update) to the <strong>state</strong> (Model), the render function (View) is
called and it renders the entire <a class="reference internal" href="stubs/edifice.Element.html#edifice.Element" title="edifice.Element"><code class="xref py py-class docutils literal notranslate"><span class="pre">Element</span></code></a> tree of Qt Widgets from scratch.</p>
<p>That sounds expensive and slow, and it would be if it weren’t for
the diffing algorithm.</p>
<section id="the-diffing-algorithm">
<h3>The diffing algorithm<a class="headerlink" href="#the-diffing-algorithm" title="Link to this heading">#</a></h3>
<p>When Elements are rendered,
the Element tree is then compared against the result
of the previous render. The two Element trees are diffed
and the Elements from the previous render
are updated with new props.</p>
<p>The diffing algorithm will compare a parents Element’s children
from the previous render with the children from the new render, to try
to update the old children instead of replacing them.</p>
<p>If a new Element is a different class than the old Element, the old Element
is replaced with the new Element.</p>
<p>If a new Element is the same class as the old Element, they are assumed to
be the same and the old Element will be updated with new <strong>props</strong> and the same
<strong>state</strong>.</p>
<p>If the <strong>props</strong> and <strong>state</strong> of an Element are the same as the previous
render, then the Element from the previous render will be re-used and not
rendered.</p>
<p>When a parent Element has many peer child Elements of the same class,
a more complex procedure (the same as in React)
will determine which Elements to maintain and which to replace.</p>
<p>When comparing the child Elements, the Element’s
<code class="code docutils literal notranslate"><span class="pre">_key</span></code> attribute will
be compared. Elements with the same <code class="code docutils literal notranslate"><span class="pre">_key</span></code> and same class are assumed to be
the same. You can set the key using the <a class="reference internal" href="stubs/stubs/edifice.Element.set_key.html#edifice.Element.set_key" title="edifice.Element.set_key"><code class="xref py py-func docutils literal notranslate"><span class="pre">Element.set_key()</span></code></a> method.</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="k">with</span> <span class="n">HBoxView</span><span class="p">():</span>
<span class="k">if</span> <span class="n">some_condition</span><span class="p">:</span>
<span class="n">MyElement</span><span class="p">(</span><span class="s2">"Hello"</span><span class="p">)</span><span class="o">.</span><span class="n">set_key</span><span class="p">(</span><span class="s2">"hello"</span><span class="p">)</span>
<span class="k">if</span> <span class="n">other_condition</span><span class="p">:</span>
<span class="n">MyElement</span><span class="p">(</span><span class="s2">"World"</span><span class="p">)</span><span class="o">.</span><span class="n">set_key</span><span class="p">(</span><span class="s2">"world"</span><span class="p">)</span>
</pre></div>
</div>
<p>If the <code class="code docutils literal notranslate"><span class="pre">_key</span></code> is not provided, the diffing algorithm will guess which
child Elements are identical based on the order of the children.</p>
<p>Whenever a parent has children which are added and removed,
it is recommended to <a class="reference internal" href="stubs/stubs/edifice.Element.set_key.html#edifice.Element.set_key" title="edifice.Element.set_key"><code class="xref py py-func docutils literal notranslate"><span class="pre">Element.set_key()</span></code></a> on the children
to tell the diffing algorithm which child Elements are identical so that it
doesn’t have to guess.</p>
</section>
</section>
<section id="substitutional-eq-relation">
<h2>Substitutional <code class="code docutils literal notranslate"><span class="pre">__eq__</span></code> relation<a class="headerlink" href="#substitutional-eq-relation" title="Link to this heading">#</a></h2>
<p>The Python
<a class="reference external" href="https://docs.python.org/3/reference/datamodel.html#object.__eq__">__eq__ relation</a>
is important for everything in Edifice. It is used, for example:</p>
<ol class="arabic simple">
<li><p>To compare <strong>props</strong> for deciding when an <a class="reference internal" href="stubs/edifice.Element.html#edifice.Element" title="edifice.Element"><code class="xref py py-class docutils literal notranslate"><span class="pre">Element</span></code></a> must be re-rendered.</p></li>
<li><p>To compare <a class="reference internal" href="stubs/edifice.use_state.html#edifice.use_state" title="edifice.use_state"><code class="xref py py-func docutils literal notranslate"><span class="pre">use_state()</span></code></a> <strong>state</strong> variables for deciding when a <a class="reference internal" href="stubs/edifice.component.html#edifice.component" title="edifice.component"><code class="xref py py-func docutils literal notranslate"><span class="pre">@component</span></code></a> must be re-rendered.</p></li>
<li><p>To compare <strong>dependencies</strong> for deciding when a <a class="reference internal" href="stubs/edifice.use_effect.html#edifice.use_effect" title="edifice.use_effect"><code class="xref py py-func docutils literal notranslate"><span class="pre">use_effect()</span></code></a> must be re-run.</p></li>
</ol>
<p>For the <code class="code docutils literal notranslate"><span class="pre">__eq__</span></code> relation to work properly, it should mean that if two
objects are <code class="code docutils literal notranslate"><span class="pre">__eq__</span></code>, then <em>one can be substituted for the other</em>.</p>
<p>Keep in mind that for Python object types <code class="code docutils literal notranslate"><span class="pre">__eq__</span></code> defaults to
referential identity.</p>
<blockquote>
<div><p>By default, <code class="code docutils literal notranslate"><span class="pre">object</span></code> implements <code class="code docutils literal notranslate"><span class="pre">__eq__()</span></code> by using <code class="code docutils literal notranslate"><span class="pre">is</span></code></p>
</div></blockquote>
<p>Sometimes this referential identity <code class="code docutils literal notranslate"><span class="pre">__eq__</span></code> is what you want,
for example with large objects like images or tensors, because it’s too expensive
to compare the objects by value and you know that you don’t have duplicate values
in your program. But usually you want an <code class="code docutils literal notranslate"><span class="pre">__eq__</span></code> that compares values.</p>
<p>Every value used as a <strong>prop</strong> or <strong>state</strong> or <strong>dependency</strong> in Edifice should
have a <em>substitutional</em> <code class="code docutils literal notranslate"><span class="pre">__eq__</span></code> relation.</p>
</section>
<section id="element-initialization-is-a-render-side-effect">
<h2>Element initialization is a render side-effect<a class="headerlink" href="#element-initialization-is-a-render-side-effect" title="Link to this heading">#</a></h2>
<p>Each <a class="reference internal" href="stubs/edifice.Element.html#edifice.Element" title="edifice.Element"><code class="xref py py-class docutils literal notranslate"><span class="pre">Element</span></code></a> is implemented as the constructor function
for a Python class. The <a class="reference internal" href="stubs/edifice.Element.html#edifice.Element" title="edifice.Element"><code class="xref py py-class docutils literal notranslate"><span class="pre">Element</span></code></a> constructor function also has
the side-effect of inserting itself to the rendered <a class="reference internal" href="stubs/edifice.Element.html#edifice.Element" title="edifice.Element"><code class="xref py py-class docutils literal notranslate"><span class="pre">Element</span></code></a> tree,
as a child of the <code class="code docutils literal notranslate"><span class="pre">with</span></code> context layout Element.</p>
<p>We like this style of declaring Element trees in Python code because</p>
<ol class="arabic simple">
<li><p>The indentation structure of the Python code reflects the
structure of the Element tree.</p></li>
<li><p>We can use Python control flow statements <code class="code docutils literal notranslate"><span class="pre">if</span></code> <code class="code docutils literal notranslate"><span class="pre">for</span></code>
<code class="code docutils literal notranslate"><span class="pre">match</span></code> to dynamically render Elements.</p></li>
</ol>
<p>Because Element initialization is a render side-effect,
we have to be careful about binding Elements to variables
and passing them around. They will insert themselves in the tree at the time
they are initialized. This code will <strong>NOT</strong> declare the intended Element tree.</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="nd">@component</span>
<span class="k">def</span> <span class="nf">MySimpleComp</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">prop1</span><span class="p">,</span> <span class="n">prop2</span><span class="p">,</span> <span class="n">prop3</span><span class="p">):</span>
<span class="n">label3</span> <span class="o">=</span> <span class="n">Label</span><span class="p">(</span><span class="n">text</span><span class="o">=</span><span class="n">prop3</span><span class="p">)</span>
<span class="k">with</span> <span class="n">VBoxView</span><span class="p">():</span>
<span class="n">Label</span><span class="p">(</span><span class="n">text</span><span class="o">=</span><span class="n">prop1</span><span class="p">)</span>
<span class="n">Label</span><span class="p">(</span><span class="n">text</span><span class="o">=</span><span class="n">prop2</span><span class="p">)</span>
<span class="n">label3</span> <span class="c1"># This will NOT render here as intended</span>
</pre></div>
</div>
<p>To solve this, defer the construction of the Element with a lambda function.
This code will declare the same intended Element tree as the code above.</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="nd">@component</span>
<span class="k">def</span> <span class="nf">MySimpleComp</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">prop1</span><span class="p">,</span> <span class="n">prop2</span><span class="p">,</span> <span class="n">prop3</span><span class="p">):</span>
<span class="n">label3</span> <span class="o">=</span> <span class="k">lambda</span><span class="p">:</span> <span class="n">Label</span><span class="p">(</span><span class="n">text</span><span class="o">=</span><span class="n">prop3</span><span class="p">)</span>
<span class="k">with</span> <span class="n">VBoxView</span><span class="p">():</span>
<span class="n">Label</span><span class="p">(</span><span class="n">text</span><span class="o">=</span><span class="n">prop1</span><span class="p">)</span>
<span class="n">Label</span><span class="p">(</span><span class="n">text</span><span class="o">=</span><span class="n">prop2</span><span class="p">)</span>
<span class="n">label3</span><span class="p">()</span>
</pre></div>
</div>
<p>If these component Elements are render functions, then why couldn’t we just write
a normal render function with no decorator instead?</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="c1"># No decorator</span>
<span class="k">def</span> <span class="nf">MySimpleComp</span><span class="p">(</span><span class="n">prop1</span><span class="p">,</span> <span class="n">prop2</span><span class="p">,</span> <span class="n">prop3</span><span class="p">):</span>
<span class="k">with</span> <span class="n">VBoxView</span><span class="p">():</span>
<span class="n">Label</span><span class="p">(</span><span class="n">text</span><span class="o">=</span><span class="n">prop1</span><span class="p">)</span>
<span class="n">Label</span><span class="p">(</span><span class="n">text</span><span class="o">=</span><span class="n">prop2</span><span class="p">)</span>
<span class="n">Label</span><span class="p">(</span><span class="n">text</span><span class="o">=</span><span class="n">prop3</span><span class="p">)</span>
</pre></div>
</div>
<p>The difference is, with the <a class="reference internal" href="stubs/edifice.component.html#edifice.component" title="edifice.component"><code class="xref py py-func docutils literal notranslate"><span class="pre">@component</span></code></a> decorator, an
actual <a class="reference internal" href="stubs/edifice.Element.html#edifice.Element" title="edifice.Element"><code class="xref py py-class docutils literal notranslate"><span class="pre">Element</span></code></a> object is created,
which means that subsequent renders will be skipped if the <strong>props</strong> didn’t change.
Also we need an <a class="reference internal" href="stubs/edifice.component.html#edifice.component" title="edifice.component"><code class="xref py py-func docutils literal notranslate"><span class="pre">@component</span></code></a> to
be able to use Hooks such as <a class="reference internal" href="stubs/edifice.use_state.html#edifice.use_state" title="edifice.use_state"><code class="xref py py-func docutils literal notranslate"><span class="pre">use_state()</span></code></a>, because those are bound to
an <a class="reference internal" href="stubs/edifice.Element.html#edifice.Element" title="edifice.Element"><code class="xref py py-class docutils literal notranslate"><span class="pre">Element</span></code></a>.</p>
</section>
</section>
</article>
<footer class="prev-next-footer d-print-none">
<div class="prev-next-area">
<a class="left-prev"
href="api.html"
title="previous page">
<i class="fa-solid fa-angle-left"></i>
<div class="prev-next-info">
<p class="prev-next-subtitle">previous</p>
<p class="prev-next-title">API</p>
</div>
</a>
<a class="right-next"
href="stubs/edifice.App.html"
title="next page">
<div class="prev-next-info">
<p class="prev-next-subtitle">next</p>
<p class="prev-next-title">edifice.App</p>
</div>
<i class="fa-solid fa-angle-right"></i>
</a>
</div>
</footer>
</div>
<dialog id="pst-secondary-sidebar-modal"></dialog>
<div id="pst-secondary-sidebar" class="bd-sidebar-secondary bd-toc"><div class="sidebar-secondary-items sidebar-secondary__inner">
<div class="sidebar-secondary-item">
<div
id="pst-page-navigation-heading-2"
class="page-toc tocsection onthispage">
<i class="fa-solid fa-list"></i> On this page
</div>
<nav class="bd-toc-nav page-toc" aria-labelledby="pst-page-navigation-heading-2">
<ul class="visible nav section-nav flex-column">
<li class="toc-h2 nav-item toc-entry"><a class="reference internal nav-link" href="#class-overview">Class overview</a><ul class="nav section-nav flex-column">
</ul>
</li>
<li class="toc-h2 nav-item toc-entry"><a class="reference internal nav-link" href="#edifice-programming-style">Edifice Programming Style</a><ul class="nav section-nav flex-column">
<li class="toc-h3 nav-item toc-entry"><a class="reference internal nav-link" href="#asynchronous">Asynchronous</a></li>
<li class="toc-h3 nav-item toc-entry"><a class="reference internal nav-link" href="#declarative">Declarative</a></li>
<li class="toc-h3 nav-item toc-entry"><a class="reference internal nav-link" href="#reactive">Reactive</a></li>
</ul>
</li>
<li class="toc-h2 nav-item toc-entry"><a class="reference internal nav-link" href="#rules-of-edifice">Rules of Edifice</a></li>
<li class="toc-h2 nav-item toc-entry"><a class="reference internal nav-link" href="#declaring-element-trees">Declaring Element Trees</a><ul class="nav section-nav flex-column">
<li class="toc-h3 nav-item toc-entry"><a class="reference internal nav-link" href="#dynamic-rendering">Dynamic Rendering</a></li>
</ul>
</li>
<li class="toc-h2 nav-item toc-entry"><a class="reference internal nav-link" href="#model-view-update">Model-View-Update</a></li>
<li class="toc-h2 nav-item toc-entry"><a class="reference internal nav-link" href="#rendering">Rendering</a><ul class="nav section-nav flex-column">
<li class="toc-h3 nav-item toc-entry"><a class="reference internal nav-link" href="#the-diffing-algorithm">The diffing algorithm</a></li>
</ul>
</li>
<li class="toc-h2 nav-item toc-entry"><a class="reference internal nav-link" href="#substitutional-eq-relation">Substitutional <code class="code docutils literal notranslate"><span class="pre">__eq__</span></code> relation</a></li>
<li class="toc-h2 nav-item toc-entry"><a class="reference internal nav-link" href="#element-initialization-is-a-render-side-effect">Element initialization is a render side-effect</a></li>
</ul>
</nav></div>
</div></div>
</div>
<footer class="bd-footer-content">
</footer>
</main>
</div>
</div>
<!-- Scripts loaded after <body> so the DOM is not blocked -->
<script defer src="_static/scripts/bootstrap.js?digest=8878045cc6db502f8baf"></script>
<script defer src="_static/scripts/pydata-sphinx-theme.js?digest=8878045cc6db502f8baf"></script>
<footer class="bd-footer">
<div class="bd-footer__inner bd-page-width">
<div class="footer-items__start">
<div class="footer-item">
<p class="sphinx-version">
Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 8.1.3.
<br/>
</p>
</div>
</div>
<div class="footer-items__end">
<div class="footer-item">
<p class="theme-version">
<!-- # L10n: Setting the PST URL as an argument as this does not need to be localized -->
Built with the <a href="https://pydata-sphinx-theme.readthedocs.io/en/stable/index.html">PyData Sphinx Theme</a> 0.16.1.
</p></div>
</div>
</div>
</footer>
</body>
</html>