Skip to content

Commit

Permalink
deploy: 56a8d0f
Browse files Browse the repository at this point in the history
  • Loading branch information
brentyi committed Oct 3, 2023
1 parent ace3323 commit 8deaf26
Show file tree
Hide file tree
Showing 11 changed files with 80 additions and 7 deletions.
Binary file modified .doctrees/client_handles.doctree
Binary file not shown.
Binary file modified .doctrees/environment.pickle
Binary file not shown.
Binary file modified .doctrees/gui_handles.doctree
Binary file not shown.
Binary file modified .doctrees/server.doctree
Binary file not shown.
59 changes: 59 additions & 0 deletions _modules/viser/_gui_handles/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -245,9 +245,13 @@ <h1>Source code for viser._gui_handles</h1><div class="highlight"><pre>
<span></span><span class="kn">from</span> <span class="nn">__future__</span> <span class="kn">import</span> <span class="n">annotations</span>

<span class="kn">import</span> <span class="nn">dataclasses</span>
<span class="kn">import</span> <span class="nn">re</span>
<span class="kn">import</span> <span class="nn">threading</span>
<span class="kn">import</span> <span class="nn">time</span>
<span class="kn">import</span> <span class="nn">urllib.parse</span>
<span class="kn">import</span> <span class="nn">uuid</span>
<span class="kn">import</span> <span class="nn">warnings</span>
<span class="kn">from</span> <span class="nn">pathlib</span> <span class="kn">import</span> <span class="n">Path</span>
<span class="kn">from</span> <span class="nn">typing</span> <span class="kn">import</span> <span class="p">(</span>
<span class="n">TYPE_CHECKING</span><span class="p">,</span>
<span class="n">Callable</span><span class="p">,</span>
Expand All @@ -262,13 +266,16 @@ <h1>Source code for viser._gui_handles</h1><div class="highlight"><pre>
<span class="n">Union</span><span class="p">,</span>
<span class="p">)</span>

<span class="kn">import</span> <span class="nn">imageio.v3</span> <span class="k">as</span> <span class="nn">iio</span>
<span class="kn">import</span> <span class="nn">numpy</span> <span class="k">as</span> <span class="nn">onp</span>
<span class="kn">from</span> <span class="nn">typing_extensions</span> <span class="kn">import</span> <span class="n">Protocol</span>

<span class="kn">from</span> <span class="nn">._icons</span> <span class="kn">import</span> <span class="n">base64_from_icon</span>
<span class="kn">from</span> <span class="nn">._icons_enum</span> <span class="kn">import</span> <span class="n">Icon</span>
<span class="kn">from</span> <span class="nn">._message_api</span> <span class="kn">import</span> <span class="n">_encode_image_base64</span>
<span class="kn">from</span> <span class="nn">._messages</span> <span class="kn">import</span> <span class="p">(</span>
<span class="n">GuiAddDropdownMessage</span><span class="p">,</span>
<span class="n">GuiAddMarkdownMessage</span><span class="p">,</span>
<span class="n">GuiAddTabGroupMessage</span><span class="p">,</span>
<span class="n">GuiCloseModalMessage</span><span class="p">,</span>
<span class="n">GuiRemoveMessage</span><span class="p">,</span>
Expand Down Expand Up @@ -782,6 +789,38 @@ <h1>Source code for viser._gui_handles</h1><div class="highlight"><pre>



<span class="k">def</span> <span class="nf">_get_data_url</span><span class="p">(</span><span class="n">url</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> <span class="n">image_root</span><span class="p">:</span> <span class="n">Optional</span><span class="p">[</span><span class="n">Path</span><span class="p">])</span> <span class="o">-&gt;</span> <span class="nb">str</span><span class="p">:</span>
<span class="k">if</span> <span class="ow">not</span> <span class="n">url</span><span class="o">.</span><span class="n">startswith</span><span class="p">(</span><span class="s2">&quot;http&quot;</span><span class="p">)</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">image_root</span><span class="p">:</span>
<span class="n">warnings</span><span class="o">.</span><span class="n">warn</span><span class="p">(</span>
<span class="s2">&quot;No `image_root` provided. All relative paths will be scoped to viser&#39;s installation path.&quot;</span><span class="p">,</span>
<span class="n">stacklevel</span><span class="o">=</span><span class="mi">2</span><span class="p">,</span>
<span class="p">)</span>
<span class="k">if</span> <span class="n">url</span><span class="o">.</span><span class="n">startswith</span><span class="p">(</span><span class="s2">&quot;http&quot;</span><span class="p">):</span>
<span class="k">return</span> <span class="n">url</span>
<span class="k">if</span> <span class="n">image_root</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span>
<span class="n">image_root</span> <span class="o">=</span> <span class="n">Path</span><span class="p">(</span><span class="vm">__file__</span><span class="p">)</span><span class="o">.</span><span class="n">parent</span>
<span class="k">try</span><span class="p">:</span>
<span class="n">image</span> <span class="o">=</span> <span class="n">iio</span><span class="o">.</span><span class="n">imread</span><span class="p">(</span><span class="n">image_root</span> <span class="o">/</span> <span class="n">url</span><span class="p">)</span>
<span class="n">data_uri</span> <span class="o">=</span> <span class="n">_encode_image_base64</span><span class="p">(</span><span class="n">image</span><span class="p">,</span> <span class="s2">&quot;png&quot;</span><span class="p">)</span>
<span class="n">url</span> <span class="o">=</span> <span class="n">urllib</span><span class="o">.</span><span class="n">parse</span><span class="o">.</span><span class="n">quote</span><span class="p">(</span><span class="sa">f</span><span class="s2">&quot;</span><span class="si">{</span><span class="n">data_uri</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span><span class="si">}</span><span class="s2">&quot;</span><span class="p">)</span>
<span class="k">return</span> <span class="sa">f</span><span class="s2">&quot;data:</span><span class="si">{</span><span class="n">data_uri</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="si">}</span><span class="s2">;base64,</span><span class="si">{</span><span class="n">url</span><span class="si">}</span><span class="s2">&quot;</span>
<span class="k">except</span> <span class="p">(</span><span class="ne">IOError</span><span class="p">,</span> <span class="ne">FileNotFoundError</span><span class="p">):</span>
<span class="n">warnings</span><span class="o">.</span><span class="n">warn</span><span class="p">(</span>
<span class="sa">f</span><span class="s2">&quot;Failed to read image </span><span class="si">{</span><span class="n">url</span><span class="si">}</span><span class="s2">, with image_root set to </span><span class="si">{</span><span class="n">image_root</span><span class="si">}</span><span class="s2">.&quot;</span><span class="p">,</span>
<span class="n">stacklevel</span><span class="o">=</span><span class="mi">2</span><span class="p">,</span>
<span class="p">)</span>
<span class="k">return</span> <span class="n">url</span>


<span class="k">def</span> <span class="nf">_parse_markdown</span><span class="p">(</span><span class="n">markdown</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> <span class="n">image_root</span><span class="p">:</span> <span class="n">Optional</span><span class="p">[</span><span class="n">Path</span><span class="p">])</span> <span class="o">-&gt;</span> <span class="nb">str</span><span class="p">:</span>
<span class="n">markdown</span> <span class="o">=</span> <span class="n">re</span><span class="o">.</span><span class="n">sub</span><span class="p">(</span>
<span class="sa">r</span><span class="s2">&quot;\!\[([^]]*)\]\(([^]]*)\)&quot;</span><span class="p">,</span>
<span class="k">lambda</span> <span class="n">match</span><span class="p">:</span> <span class="sa">f</span><span class="s2">&quot;![</span><span class="si">{</span><span class="n">match</span><span class="o">.</span><span class="n">group</span><span class="p">(</span><span class="mi">1</span><span class="p">)</span><span class="si">}</span><span class="s2">](</span><span class="si">{</span><span class="n">_get_data_url</span><span class="p">(</span><span class="n">match</span><span class="o">.</span><span class="n">group</span><span class="p">(</span><span class="mi">2</span><span class="p">),</span><span class="w"> </span><span class="n">image_root</span><span class="p">)</span><span class="si">}</span><span class="s2">)&quot;</span><span class="p">,</span>
<span class="n">markdown</span><span class="p">,</span>
<span class="p">)</span>
<span class="k">return</span> <span class="n">markdown</span>


<div class="viewcode-block" id="GuiMarkdownHandle">
<a class="viewcode-back" href="../../../gui_handles/#viser.GuiMarkdownHandle">[docs]</a>
<span class="nd">@dataclasses</span><span class="o">.</span><span class="n">dataclass</span>
Expand All @@ -793,6 +832,26 @@ <h1>Source code for viser._gui_handles</h1><div class="highlight"><pre>
<span class="n">_visible</span><span class="p">:</span> <span class="nb">bool</span>
<span class="n">_container_id</span><span class="p">:</span> <span class="nb">str</span> <span class="c1"># Parent.</span>
<span class="n">_order</span><span class="p">:</span> <span class="nb">float</span>
<span class="n">_image_root</span><span class="p">:</span> <span class="n">Optional</span><span class="p">[</span><span class="n">Path</span><span class="p">]</span>
<span class="n">_content</span><span class="p">:</span> <span class="n">Optional</span><span class="p">[</span><span class="nb">str</span><span class="p">]</span>

<span class="nd">@property</span>
<span class="k">def</span> <span class="nf">content</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="nb">str</span><span class="p">:</span>
<span class="w"> </span><span class="sd">&quot;&quot;&quot;Current content of this markdown element. Synchronized automatically when assigned.&quot;&quot;&quot;</span>
<span class="k">assert</span> <span class="bp">self</span><span class="o">.</span><span class="n">_content</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span>
<span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_content</span>

<span class="nd">@content</span><span class="o">.</span><span class="n">setter</span>
<span class="k">def</span> <span class="nf">content</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">content</span><span class="p">:</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="kc">None</span><span class="p">:</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_content</span> <span class="o">=</span> <span class="n">content</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_gui_api</span><span class="o">.</span><span class="n">_get_api</span><span class="p">()</span><span class="o">.</span><span class="n">_queue</span><span class="p">(</span>
<span class="n">GuiAddMarkdownMessage</span><span class="p">(</span>
<span class="n">order</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_order</span><span class="p">,</span>
<span class="nb">id</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_id</span><span class="p">,</span>
<span class="n">markdown</span><span class="o">=</span><span class="n">_parse_markdown</span><span class="p">(</span><span class="n">content</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_image_root</span><span class="p">),</span>
<span class="n">container_id</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_container_id</span><span class="p">,</span>
<span class="p">)</span>
<span class="p">)</span>

<span class="nd">@property</span>
<span class="k">def</span> <span class="nf">order</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="nb">float</span><span class="p">:</span>
Expand Down
4 changes: 2 additions & 2 deletions client_handles/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -423,12 +423,12 @@ <h1>Client Handles<a class="headerlink" href="#client-handles" title="Link to th

<dl class="py method">
<dt class="sig sig-object py" id="viser.ClientHandle.add_gui_markdown">
<span class="sig-name descname"><span class="pre">add_gui_markdown</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">markdown</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">str</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">image_root</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">pathlib.Path</span><span class="w"> </span><span class="p"><span class="pre">|</span></span><span class="w"> </span><span class="pre">None</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">order</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">float</span><span class="w"> </span><span class="p"><span class="pre">|</span></span><span class="w"> </span><span class="pre">None</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#viser.ClientHandle.add_gui_markdown" title="Link to this definition">#</a></dt>
<span class="sig-name descname"><span class="pre">add_gui_markdown</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">content</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">str</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">image_root</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">pathlib.Path</span><span class="w"> </span><span class="p"><span class="pre">|</span></span><span class="w"> </span><span class="pre">None</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">order</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">float</span><span class="w"> </span><span class="p"><span class="pre">|</span></span><span class="w"> </span><span class="pre">None</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#viser.ClientHandle.add_gui_markdown" title="Link to this definition">#</a></dt>
<dd><p>Add markdown to the GUI.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>markdown</strong> (<em>str</em>) – </p></li>
<li><p><strong>content</strong> (<em>str</em>) – </p></li>
<li><p><strong>image_root</strong> (<em>Optional</em><em>[</em><em>pathlib.Path</em><em>]</em>) – </p></li>
<li><p><strong>order</strong> (<em>Optional</em><em>[</em><em>float</em><em>]</em>) – </p></li>
</ul>
Expand Down
6 changes: 4 additions & 2 deletions genindex/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3131,10 +3131,10 @@ <h2>C</h2>
</li>
<li><a href="../icons/#viser.Icon.CIRCUIT_DIODE">CIRCUIT_DIODE (viser.Icon attribute)</a>
</li>
</ul></td>
<td style="width: 33%; vertical-align: top;"><ul>
<li><a href="../icons/#viser.Icon.CIRCUIT_DIODE_ZENER">CIRCUIT_DIODE_ZENER (viser.Icon attribute)</a>
</li>
</ul></td>
<td style="width: 33%; vertical-align: top;"><ul>
<li><a href="../icons/#viser.Icon.CIRCUIT_GROUND">CIRCUIT_GROUND (viser.Icon attribute)</a>
</li>
<li><a href="../icons/#viser.Icon.CIRCUIT_GROUND_DIGITAL">CIRCUIT_GROUND_DIGITAL (viser.Icon attribute)</a>
Expand Down Expand Up @@ -3472,6 +3472,8 @@ <h2>C</h2>
<li><a href="../icons/#viser.Icon.CONTAINER">CONTAINER (viser.Icon attribute)</a>
</li>
<li><a href="../icons/#viser.Icon.CONTAINER_OFF">CONTAINER_OFF (viser.Icon attribute)</a>
</li>
<li><a href="../gui_handles/#viser.GuiMarkdownHandle.content">content (viser.GuiMarkdownHandle property)</a>
</li>
<li><a href="../icons/#viser.Icon.CONTRAST">CONTRAST (viser.Icon attribute)</a>
</li>
Expand Down
12 changes: 12 additions & 0 deletions gui_handles/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -654,6 +654,17 @@ <h1>GUI Handles<a class="headerlink" href="#gui-handles" title="Link to this hea
<dt class="sig sig-object py" id="viser.GuiMarkdownHandle">
<em class="property"><span class="pre">class</span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">viser.</span></span><span class="sig-name descname"><span class="pre">GuiMarkdownHandle</span></span><a class="reference internal" href="../_modules/viser/_gui_handles/#GuiMarkdownHandle"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#viser.GuiMarkdownHandle" title="Link to this definition">#</a></dt>
<dd><p>Use to remove markdown.</p>
<dl class="py property">
<dt class="sig sig-object py" id="viser.GuiMarkdownHandle.content">
<em class="property"><span class="pre">property</span><span class="w"> </span></em><span class="sig-name descname"><span class="pre">content</span></span><a class="headerlink" href="#viser.GuiMarkdownHandle.content" title="Link to this definition">#</a></dt>
<dd><p>Current content of this markdown element. Synchronized automatically when assigned.</p>
<dl class="field-list simple">
<dt class="field-odd">Return type<span class="colon">:</span></dt>
<dd class="field-odd"><p>str</p>
</dd>
</dl>
</dd></dl>

<dl class="py property">
<dt class="sig sig-object py" id="viser.GuiMarkdownHandle.order">
<em class="property"><span class="pre">property</span><span class="w"> </span></em><span class="sig-name descname"><span class="pre">order</span></span><a class="headerlink" href="#viser.GuiMarkdownHandle.order" title="Link to this definition">#</a></dt>
Expand Down Expand Up @@ -886,6 +897,7 @@ <h1>GUI Handles<a class="headerlink" href="#gui-handles" title="Link to this hea
</ul>
</li>
<li><a class="reference internal" href="#viser.GuiMarkdownHandle"><code class="docutils literal notranslate"><span class="pre">GuiMarkdownHandle</span></code></a><ul>
<li><a class="reference internal" href="#viser.GuiMarkdownHandle.content"><code class="docutils literal notranslate"><span class="pre">GuiMarkdownHandle.content</span></code></a></li>
<li><a class="reference internal" href="#viser.GuiMarkdownHandle.order"><code class="docutils literal notranslate"><span class="pre">GuiMarkdownHandle.order</span></code></a></li>
<li><a class="reference internal" href="#viser.GuiMarkdownHandle.remove"><code class="docutils literal notranslate"><span class="pre">GuiMarkdownHandle.remove()</span></code></a></li>
<li><a class="reference internal" href="#viser.GuiMarkdownHandle.visible"><code class="docutils literal notranslate"><span class="pre">GuiMarkdownHandle.visible</span></code></a></li>
Expand Down
Binary file modified objects.inv
Binary file not shown.
2 changes: 1 addition & 1 deletion searchindex.js

Large diffs are not rendered by default.

Loading

0 comments on commit 8deaf26

Please sign in to comment.