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

2023-05-08 Thread aap...@posteo.net

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.



___
Tkinter-discuss mailing list
Tkinter-discuss@python.org
https://mail.python.org/mailman/listinfo/tkinter-discuss


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

2023-05-08 Thread Michael Lange
Hi,

On Sun, 7 May 2023 08:34:29 +0800 (CST)
张小平 <13295564...@163.com> 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.'}}}
>

you mean if you pass the list directly to the Label's text option?
In this case, the "magic" of tkinter apparently converts the Python list
into a proper Tcl list which is what you see here.
If you want the Python list to be displayed as label text, you need to
enclose it in quotation marks, as in

s = '''[
[1,"PAGE",{"id":"w"}],
[2,"Text",{"caption":"This is first GUI Page,totally different form
HTML."}] ]'''
Label(parent, text=s, justify='left')

Have a nice day,

Michael
___
Tkinter-discuss mailing list
Tkinter-discuss@python.org
https://mail.python.org/mailman/listinfo/tkinter-discuss


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

2023-05-07 Thread David
On Sun, 7 May 2023 at 23:01, 张小平 <13295564...@163.com> 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

Best practice for solving your issue is explained here:
  http://www.sscce.org/
I suggest you read it and follow the instructions.
___
Tkinter-discuss mailing list
Tkinter-discuss@python.org
https://mail.python.org/mailman/listinfo/tkinter-discuss


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

2023-05-07 Thread 张小平
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. 


___
Tkinter-discuss mailing list
Tkinter-discuss@python.org
https://mail.python.org/mailman/listinfo/tkinter-discuss