From 13295564836 at 163.com Sat May 6 20:34:29 2023 From: 13295564836 at 163.com (=?GBK?B?1cXQoca9?=) Date: Sun, 7 May 2023 08:34:29 +0800 (CST) Subject: [Tkinter-discuss] Maybe a bug about tk.Text and tk.Label Message-ID: <33238c83.1c4.187f3a1a52e.Coremail.13295564836@163.com> 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. -------------- next part -------------- An HTML attachment was scrubbed... URL: From bouncingcats at gmail.com Mon May 8 00:48:00 2023 From: bouncingcats at gmail.com (David) Date: Mon, 8 May 2023 04:48:00 +0000 Subject: [Tkinter-discuss] Maybe a bug about tk.Text and tk.Label In-Reply-To: <33238c83.1c4.187f3a1a52e.Coremail.13295564836@163.com> References: <33238c83.1c4.187f3a1a52e.Coremail.13295564836@163.com> Message-ID: On Sun, 7 May 2023 at 23:01, ??? <13295564836 at 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. From klappnase at web.de Mon May 8 04:27:55 2023 From: klappnase at web.de (Michael Lange) Date: Mon, 8 May 2023 10:27:55 +0200 Subject: [Tkinter-discuss] Maybe a bug about tk.Text and tk.Label In-Reply-To: <33238c83.1c4.187f3a1a52e.Coremail.13295564836@163.com> References: <33238c83.1c4.187f3a1a52e.Coremail.13295564836@163.com> Message-ID: <20230508102755.b4037881d759b052cf756f4c@web.de> Hi, On Sun, 7 May 2023 08:34:29 +0800 (CST) ??? <13295564836 at 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 From aapost at posteo.net Mon May 8 02:48:27 2023 From: aapost at posteo.net (aapost at posteo.net) Date: Mon, 8 May 2023 06:48:27 +0000 Subject: [Tkinter-discuss] Maybe a bug about tk.Text and tk.Label In-Reply-To: <33238c83.1c4.187f3a1a52e.Coremail.13295564836@163.com> References: <33238c83.1c4.187f3a1a52e.Coremail.13295564836@163.com> Message-ID: <9cb93a72-acf6-9938-85cd-c00b01165e89@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. -------------- next part -------------- An HTML attachment was scrubbed... URL: From Vasilis.Vlachoudis at cern.ch Wed May 31 10:44:35 2023 From: Vasilis.Vlachoudis at cern.ch (Vasilis Vlachoudis) Date: Wed, 31 May 2023 14:44:35 +0000 Subject: [Tkinter-discuss] Treeview: stop temporarily TreeviewSelect messages Message-ID: Hi all, during the filling of a ttk.Treeview, widget I want to temporarily disable the <> (to restore the previously selected items), and re-enable it at the end. However, when I unbind the <> event the messages are still send. See the following demo code. I would expect that during the filling no <> message will be send, however I get hundreds of messages at the end import tkinter as tk from tkinter import ttk def tvselect(event): ??????print("SELECTION CHANGED") def fill(event=None): ??????t.unbind("<>") ??????for i in range(1000): ????????????item = t.insert("",tk.END,text=f"Item {i}") ????????????if i&1==0: t.selection_add(item) ??????t.bind("<>", tvselect) if __name__ == "__main__": ??????root = tk.Tk() ??????t = ttk.Treeview(root) ??????t.bind("<>", tvselect) ??????t.pack(expand=tk.YES,fill=tk.BOTH) ??????b = tk.Button(root, text="Press me", command=fill) ??????b.pack() ??????root.mainloop() -------------- next part -------------- An HTML attachment was scrubbed... URL: From klappnase at web.de Wed May 31 18:34:48 2023 From: klappnase at web.de (Michael Lange) Date: Thu, 1 Jun 2023 00:34:48 +0200 Subject: [Tkinter-discuss] Treeview: stop temporarily TreeviewSelect messages In-Reply-To: References: Message-ID: <20230601003448.7b88b488aa38a846587aded9@web.de> Hi Vasilis, On Wed, 31 May 2023 14:44:35 +0000 Vasilis Vlachoudis wrote: > during the filling of a ttk.Treeview, widget I want to temporarily > disable the <> (to restore the previously selected > items), and re-enable it at the end. However, when I unbind the > <> event the messages are still send. See the following > demo code. I would expect that during the filling no <> > message will be send, however I get hundreds of messages at the end > the problem appears to be that the binding is restored before the calls in the "for" loop in your fill() function are processed. If we add a strategic update() to your function it seems to work as expected: def fill(event=None): t.unbind("<>") for i in range(1000): item = t.insert("",tk.END,text=f"Item {i}") if i&1==0: t.selection_add(item) t.update() t.bind("<>", tvselect) update_idletasks() doesn't seem to be sufficient here. Have a nice day, Michael