[Tkinter-discuss] Maybe a bug about tk.Text and tk.Label

aapost at posteo.net aapost at posteo.net
Mon May 8 02:48:27 EDT 2023


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.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.python.org/pipermail/tkinter-discuss/attachments/20230508/5aa8941f/attachment.html>


More information about the Tkinter-discuss mailing list