Re: Maybe a bug about tk.Text and tk.Label

"[email protected]" <[email protected]> Mon, 8 May 2023 06:48:27 +0000
Newsgroups gmane.comp.python.tkinter
Message-ID <[email protected]>
This is a multi-part message in MIME format.
--===============9040714613787009184==
Content-Type: multipart/alternative;
 boundary="------------jgMCGPmNEiVfsJdQ2a2bebIR"
Content-Language: en-US

This is a multi-part message in MIME format.
--------------jgMCGPmNEiVfsJdQ2a2bebIR
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit

On 5/6/23 20:34, 张小平 wrote:
> When i use Text or Label to show  this :
> [
> [1, "PAGE", {"id":"w"}],
> [2, "Text", {"caption":"This is first GUI Page,totally different form 
> HTML."}]
> ]
> It shows this:
> {1 PAGE {{'id': 'w'}}} {2 Text {{'caption': 'This is first GUI 
> Page,totally different form HTML.'}}}
> Have you met this?  Why?  Is it a bug about Text or Label?
> All code:
> https://gitee.com/zhaoyun004/my-gui-browser/tree/master/Will
> python b.by  , then input  "source"  and Enter to see the source code.
> I write these to try to create a Python Browser, not use HTML, but 
> Python List , Dict format.
>

You are passing the data structure to the text widget (a mix of 
dict/list). If you want the text widget to display it as a string you 
can do str(self.sources[0])

text.insert(INSERT, str(self.sources[0]))

tkinter is a layer on top of tcl/tk, and it doesn't see the structure 
itself in the same way as python.



--------------jgMCGPmNEiVfsJdQ2a2bebIR
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: 8bit

<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body>
    <div class="moz-cite-prefix">On 5/6/23 20:34, 张小平 wrote:<br>
    </div>
    <blockquote type="cite"
      cite="mid:[email protected]">
      <meta http-equiv="content-type" content="text/html; charset=UTF-8">
      <div
        style="line-height:1.7;color:#000000;font-size:14px;font-family:Arial">
        <div style="margin:0;">When i use Text or Label to show  this :</div>
        <pre class=""><div class="line" id="LC14"><span class="p">[</span> 
</div><div class="line" id="LC15">    <span class="p">[</span><span class="mi">1</span><span class="p">,</span> <span class="s">"PAGE"</span><span class="p">,</span> <span class="p">{</span><span class="s">"id"</span><span class="p">:</span><span class="s">"w"</span><span class="p">}],</span>
</div><div class="line" id="LC16">    <span class="p">[</span><span class="mi">2</span><span class="p">,</span> <span class="s">"Text"</span><span class="p">,</span> <span class="p">{</span><span class="s">"caption"</span><span class="p">:</span><span class="s">"This is first GUI Page,totally different form HTML."</span><span class="p">}]</span>
</div><div class="line" id="LC17"><span class="p">]</span>
</div></pre>
        <div>It shows this:</div>
        <div>{1 PAGE {{'id': 'w'}}} {2 Text {{'caption': 'This is first
          GUI Page,totally different form HTML.'}}}<br>
        </div>
        <div>Have you met this?  Why?  Is it a bug about Text or Label?
          <br>
        </div>
        <div>All code:<br>
        </div>
        <div><a
            href="https://gitee.com/zhaoyun004/my-gui-browser/tree/master/Will"
_src="https://gitee.com/zhaoyun004/my-gui-browser/tree/master/Will"
            moz-do-not-send="true" class="moz-txt-link-freetext">https://gitee.com/zhaoyun004/my-gui-browser/tree/master/Will</a>
          <br>
        </div>
        <div>python b.by  , then input  "source"  and Enter to see the
          source code.</div>
        <div>I write these to try to create a Python Browser, not use
          HTML, but Python List , Dict format.  <br>
        </div>
        <br>
      </div>
    </blockquote>
    <p><br>
    </p>
    <p>You are passing the data structure to the text widget (a mix of
      dict/list). If you want the text widget to display it as a string
      you can do str(self.sources[0])</p>
    <p>text.insert(INSERT, str(self.sources[0]))<br>
    </p>
    <p>tkinter is a layer on top of tcl/tk, and it doesn't see the
      structure itself in the same way as python.</p>
    <p><br>
    </p>
    <p><br>
    </p>
  </body>
</html>

--------------jgMCGPmNEiVfsJdQ2a2bebIR--

--===============9040714613787009184==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
Tkinter-discuss mailing list
[email protected]
https://mail.python.org/mailman/listinfo/tkinter-discuss

--===============9040714613787009184==--