From rikudou__sennin at live.com Sat Dec 2 16:18:14 2017 From: rikudou__sennin at live.com (adil gourinda) Date: Sat, 2 Dec 2017 21:18:14 +0000 Subject: [Tkinter-discuss] Checkbutton and Radiobutton in 3rd state Message-ID: In "tkinter.Chechbutton()" and "tkinter.Radiobutton()" widgets if the "tristatevalue" option is set to an empty string the indicator appears the first time in the 3rd state in which it is gray, but if I check the button multiple times I can't put the indicator again in the 3rd state, and if I set the "tristatevalue" to other value the indicator doesn't appear in the 3rd state Thank you for your help -------------- next part -------------- An HTML attachment was scrubbed... URL: From klappnase at web.de Mon Dec 4 09:05:43 2017 From: klappnase at web.de (Michael Lange) Date: Mon, 4 Dec 2017 15:05:43 +0100 Subject: [Tkinter-discuss] Checkbutton and Radiobutton in 3rd state In-Reply-To: References: Message-ID: <20171204150543.fab87ebe8cadb20cb8b27a7e@web.de> Hi, On Sat, 2 Dec 2017 21:18:14 +0000 adil gourinda wrote: > In "tkinter.Chechbutton()" and "tkinter.Radiobutton()" widgets if > the "tristatevalue" option is set to an empty string the indicator > appears the first time in the 3rd state in which it is gray, but if I > check the button multiple times I can't put the indicator again in the > 3rd state, and if I set the "tristatevalue" to other value the > indicator doesn't appear in the 3rd state > Thank you for your help the third state can be accessed if the value of the button's variable is changed from outside of the widget itself, as in the following example (please note the difference in the checkbutton's appearance between the toggle() and toggle2() functions): ############################### from Tkinter import * root=Tk() v = StringVar(value='2') cb = Checkbutton(root, text='foobar', variable=v, onvalue='1', offvalue='0', tristatevalue='2') cb.pack(padx=100, pady=100) def toggle(ev): v.set('2')# tristatevalue -> third state is displayed cb.bind('', toggle) def toggle2(ev): v.set('3')# undefined value -> button appears unchecked cb.bind('', toggle2) root.mainloop() ############################### Best regards Michael .-.. .. ...- . .-.. --- -. --. .- -. -.. .--. .-. --- ... .--. . .-. Not one hundred percent efficient, of course ... but nothing ever is. -- Kirk, "Metamorphosis", stardate 3219.8 From rikudou__sennin at live.com Sun Dec 17 13:49:38 2017 From: rikudou__sennin at live.com (adil gourinda) Date: Sun, 17 Dec 2017 18:49:38 +0000 Subject: [Tkinter-discuss] Contribution to Tkinter's Documentation Message-ID: Hi Because the official Tkinter's documentation is not complete I have to learn Tcl/Tk language,learning a new language and translate its syntax take a great efforts. So to make things easier for Python's users ,I made this project "Tcl/Tk--|direct translation|-->Tkinter"(https://wiki.tcl.tk/49306) and as I said in my project's description: "My objective is to make a direct translation from Tcl/Tk to Tkinter...". The work is not yet complete but I want the Python's community to benefit from it and participate in its developpement(I can share with you the translation's rules, they are my inventions :-) ) Honestly I feel comfort in Tcl/Tk wiki except some limitations: -to change the name of a page you can't do it directly you have to create new page with new title -problem in indented text And it was also an opportunity to discover "Tcl" language(It is not bad). Thanks for your attention. Gourinda Adil -------------- next part -------------- An HTML attachment was scrubbed... URL: From c.buhtz at posteo.jp Sun Dec 17 17:53:16 2017 From: c.buhtz at posteo.jp (c.buhtz at posteo.jp) Date: Sun, 17 Dec 2017 23:53:16 +0100 Subject: [Tkinter-discuss] TKinter and Python asyncio Message-ID: <3z0KFr6Wpjz9rxM@submission02.posteo.de> Hello, is it a bad idea to combine tkinter and asyncio package in Python3.5? Or is it even possible? I am also not sure if asynchronus programming is the solution of my problem: I try to create a Newsfeed-Reader (RSS & Atom). So I when the application refresh all feeds it will cause downloading e.g. 100 separate files/feeds. And I am not absolutly sure about the differences between multihtreading and asynchrone programming. From c.buhtz at posteo.jp Mon Dec 18 08:50:02 2017 From: c.buhtz at posteo.jp (c.buhtz at posteo.jp) Date: Mon, 18 Dec 2017 14:50:02 +0100 Subject: [Tkinter-discuss] Tkinter: using OS-default symbols and icons Message-ID: <3z0j8d38Thz9rxR@submission02.posteo.de> When using Tkinter in Python3 and creating Toolbars (using Frame and Button) I need icons for the buttons. Is there a plattform independed way to use the OS-default symbols? e.g. the symbol set that is configured in the desktop environment (xfce, kde, gnome, ...) or the symbols on the different MS Windows version? From bha100710 at gmail.com Mon Dec 18 10:07:14 2017 From: bha100710 at gmail.com (Bhaskar Chaudhary) Date: Mon, 18 Dec 2017 20:37:14 +0530 Subject: [Tkinter-discuss] TKinter and Python asyncio In-Reply-To: <3z0KFr6Wpjz9rxM@submission02.posteo.de> References: <3z0KFr6Wpjz9rxM@submission02.posteo.de> Message-ID: No its not at all a bad idea to combine tkinter with asyncio. Asyncio is a good thing to use whenever you have an I/O bound task which is likely to take too much time and interfere with the main loop. asyncio uses a single-threaded approach and starts an event loop using a call to asyncio.get_event_loop(). This loop switches tasks at optimal times. Most often this switching occurs when the program experiences I/O blocking, but asyncio can also be used to handle event driven code or to schedule a code to run at a specific future time. This is what makes it extremely useful for handling real-time updates where messages arrive at unpredictable times. Further Asyncio is much more scalable than threading which is often slow and has limitations on the amount of context switching that can be done. Also with multiple threads - it is difficult to ensure thread-safety. (read about race conditions). On 12/18/17, c.buhtz at posteo.jp wrote: > Hello, > > is it a bad idea to combine tkinter and asyncio package in Python3.5? > Or is it even possible? > > I am also not sure if asynchronus programming is the solution of my > problem: I try to create a Newsfeed-Reader (RSS & Atom). So I when the > application refresh all feeds it will cause downloading e.g. 100 > separate files/feeds. > > And I am not absolutly sure about the differences between > multihtreading and asynchrone programming. > _______________________________________________ > Tkinter-discuss mailing list > Tkinter-discuss at python.org > https://mail.python.org/mailman/listinfo/tkinter-discuss > From c.buhtz at posteo.jp Mon Dec 18 15:21:37 2017 From: c.buhtz at posteo.jp (c.buhtz at posteo.jp) Date: Mon, 18 Dec 2017 21:21:37 +0100 Subject: [Tkinter-discuss] TKinter and Python asyncio In-Reply-To: References: <3z0KFr6Wpjz9rxM@submission02.posteo.de> Message-ID: <3z0srL2JyYz9rxQ@submission02.posteo.de> Dear Bhaskar, thank you for your answer. On 2017-12-18 20:37 Bhaskar Chaudhary wrote: > No its not at all a bad idea to combine tkinter with asyncio. Asyncio > is a good thing to use whenever you have an I/O bound task which is > likely to take too much time and interfere with the main loop. I think here is my point. Tkinter has a loop and asyncio has a loop. How can I combine this? I couldn't finde a Tkinter-asyncio-example on the internet. From bha100710 at gmail.com Mon Dec 18 17:48:12 2017 From: bha100710 at gmail.com (Bhaskar Chaudhary) Date: Tue, 19 Dec 2017 04:18:12 +0530 Subject: [Tkinter-discuss] TKinter and Python asyncio In-Reply-To: <3z0srL2JyYz9rxQ@submission02.posteo.de> References: <3z0KFr6Wpjz9rxM@submission02.posteo.de> <3z0srL2JyYz9rxQ@submission02.posteo.de> Message-ID: Hi Check out this code: https://github.com/fluentpython/asyncio-tkinter Download the entire code from above and run tkapp2.py which uses asyncio with Tkinter - to count frequency of word in a large file - which freezes the GUI when run linearly but when run with asyncio handles it without blocking. Look at the implementation of method named `do_count` which uses asyncio. I believe this is from some PyCon talk but I am not sure. regards Bhaskar On 12/19/17, c.buhtz at posteo.jp wrote: > Dear Bhaskar, > > thank you for your answer. > > On 2017-12-18 20:37 Bhaskar Chaudhary wrote: >> No its not at all a bad idea to combine tkinter with asyncio. Asyncio >> is a good thing to use whenever you have an I/O bound task which is >> likely to take too much time and interfere with the main loop. > > I think here is my point. Tkinter has a loop and asyncio has a loop. > How can I combine this? > I couldn't finde a Tkinter-asyncio-example on the internet. > _______________________________________________ > Tkinter-discuss mailing list > Tkinter-discuss at python.org > https://mail.python.org/mailman/listinfo/tkinter-discuss > From c.buhtz at posteo.jp Tue Dec 19 17:21:16 2017 From: c.buhtz at posteo.jp (c.buhtz at posteo.jp) Date: Tue, 19 Dec 2017 23:21:16 +0100 Subject: [Tkinter-discuss] TKinter and Python asyncio In-Reply-To: References: <3z0KFr6Wpjz9rxM@submission02.posteo.de> <3z0srL2JyYz9rxQ@submission02.posteo.de> Message-ID: <3z1XS23SZ1z9rxR@submission02.posteo.de> On 2017-12-19 04:18 Bhaskar Chaudhary wrote: > Check out this code: > https://github.com/fluentpython/asyncio-tkinter > > Download the entire code from above and run tkapp2.py The example doesn't run on Python3.6. It is quite old and maybe use some deprecated concepts? The code itself is quite complex. It is not suitable to demonstrate how to combine asyncio with Tkinter the right way. I am searching the web the last days for an example. But unsuccessful. I would recommend to create a minimal example to explain this. I opened a question on stackoverflow for this. From klappnase at web.de Tue Dec 19 18:23:01 2017 From: klappnase at web.de (Michael Lange) Date: Wed, 20 Dec 2017 00:23:01 +0100 Subject: [Tkinter-discuss] TKinter and Python asyncio In-Reply-To: <3z1XS23SZ1z9rxR@submission02.posteo.de> References: <3z0KFr6Wpjz9rxM@submission02.posteo.de> <3z0srL2JyYz9rxQ@submission02.posteo.de> <3z1XS23SZ1z9rxR@submission02.posteo.de> Message-ID: <20171220002301.e8775e06730d6ccdff2ea227@web.de> On Tue, 19 Dec 2017 23:21:16 +0100 wrote: > On 2017-12-19 04:18 Bhaskar Chaudhary wrote: > > Check out this code: > > https://github.com/fluentpython/asyncio-tkinter > > > > Download the entire code from above and run tkapp2.py > > The example doesn't run on Python3.6. It is quite old and maybe use > some deprecated concepts? > > The code itself is quite complex. That's what I have been thinking, too. From what I saw there it looks to me like it might be much easier to just download the files from within a separate thread. I don't know what exactly you want to achieve of course, but from your first post my impression was that using threads should not be overly difficult. I might be wrong there, of course. > It is not suitable to demonstrate > how to combine asyncio with Tkinter the right way. Unfortunately I have no experience with asyncio at all, so I have no idea if things could be handled considerably easier using it instead of threads. Best regards Michael .-.. .. ...- . .-.. --- -. --. .- -. -.. .--. .-. --- ... .--. . .-. "What terrible way to die." "There are no good ways." -- Sulu and Kirk, "That Which Survives", stardate unknown From c.buhtz at posteo.jp Tue Dec 19 18:40:47 2017 From: c.buhtz at posteo.jp (c.buhtz at posteo.jp) Date: Wed, 20 Dec 2017 00:40:47 +0100 Subject: [Tkinter-discuss] TKinter and Python asyncio In-Reply-To: <20171220002301.e8775e06730d6ccdff2ea227@web.de> References: <3z0KFr6Wpjz9rxM@submission02.posteo.de> <3z0srL2JyYz9rxQ@submission02.posteo.de> <3z1XS23SZ1z9rxR@submission02.posteo.de> <20171220002301.e8775e06730d6ccdff2ea227@web.de> Message-ID: <3z1ZCh5l3Sz9rxG@submission02.posteo.de> On 2017-12-20 00:23 Michael Lange wrote: > to me like it might be much easier to just download the files from > within a separate thread. I don't know what exactly you want to > achieve of course, but from your first post my impression was that > using threads should not be overly difficult. I might be wrong there, > of course. I need to download between 100 or 200 xml-like files from different locations. More specific: I use "feedparser" to get rss/atom feeds. From bha100710 at gmail.com Wed Dec 20 02:36:54 2017 From: bha100710 at gmail.com (Bhaskar Chaudhary) Date: Wed, 20 Dec 2017 13:06:54 +0530 Subject: [Tkinter-discuss] TKinter and Python asyncio In-Reply-To: <3z1ZCh5l3Sz9rxG@submission02.posteo.de> References: <3z0KFr6Wpjz9rxM@submission02.posteo.de> <3z0srL2JyYz9rxQ@submission02.posteo.de> <3z1XS23SZ1z9rxR@submission02.posteo.de> <20171220002301.e8775e06730d6ccdff2ea227@web.de> <3z1ZCh5l3Sz9rxG@submission02.posteo.de> Message-ID: Here's a very simple example I borrowed from http://blog.iharder.net/2017/02/03/python-asyncio-and-tkinter-together-with-tcp-and-udp/: Here is the raw code: https://pastebin.com/raw/ZGeDULR9 This listens for tcp messages on port 9999 and prints it to a Tkinter label as and when the message arrives. I tested this on Python 3.6.3 on Linux. To test it, here's how you send a TCP message on Linux command line: echo 'some random message' > /dev/tcp/127.0.0.1/9999 Also note that in the above example - the async i/o loop is run in a separate thread. But that is just one thread to handle and it is much better tan handling one new thread for every new request. As regards Michael Lange comment - while threads are easier to grasp initially - they are not very scalable. Imagine having hundreds of thread fetching messages simultaneously - context switching at that level would be a nightmare. Better than thread would be spawning a new process - but that too has its limit. Spawning a new process is what Apache webserver does for handling each request - but that means several thousands of processes run for a busy server. That soon exhausted a lot of CPU and became impractical for servers with say a 10000 simultaneous visitors. Then came NGINX server - which manages requests asynchronously - exactly like using asyncio. Much more scalable and soon high traffic sites dumped Apache in favor of NGINX. Bottom line - if scalability is not your concern - threading or spawning a new process could be OK but asyncio is a better approach for the kind of thing you are trying to do. On 12/20/17, c.buhtz at posteo.jp wrote: > On 2017-12-20 00:23 Michael Lange wrote: >> to me like it might be much easier to just download the files from >> within a separate thread. I don't know what exactly you want to >> achieve of course, but from your first post my impression was that >> using threads should not be overly difficult. I might be wrong there, >> of course. > > I need to download between 100 or 200 xml-like files from different > locations. More specific: I use "feedparser" to get rss/atom feeds. > _______________________________________________ > Tkinter-discuss mailing list > Tkinter-discuss at python.org > https://mail.python.org/mailman/listinfo/tkinter-discuss > From c.buhtz at posteo.jp Wed Dec 20 15:25:55 2017 From: c.buhtz at posteo.jp (c.buhtz at posteo.jp) Date: Wed, 20 Dec 2017 21:25:55 +0100 Subject: [Tkinter-discuss] TKinter and Python asyncio In-Reply-To: References: <3z0KFr6Wpjz9rxM@submission02.posteo.de> <3z0srL2JyYz9rxQ@submission02.posteo.de> <3z1XS23SZ1z9rxR@submission02.posteo.de> <20171220002301.e8775e06730d6ccdff2ea227@web.de> <3z1ZCh5l3Sz9rxG@submission02.posteo.de> Message-ID: <3z25rm6Sc8z9rxd@submission02.posteo.de> X-Post: Dear Bhaskar, thank you very much for your answer and the links. On 2017-12-20 13:06 Bhaskar Chaudhary wrote: > Here's a very simple example I borrowed from > http://blog.iharder.net/2017/02/03/python-asyncio-and-tkinter-together-with-tcp-and-udp/: > > This listens for tcp messages on port 9999 and prints it to a Tkinter > label as and when the message arrives. > [..] > Also note that in the above example - the async i/o loop is run in a > separate thread. But that is just one thread to handle and it is much > better tan handling one new thread for every new request. It also came to my (and others) minds to separate each loop in it's own thread. But I am for a way from being a professional in that topics. I created a minimal working example to ask that question on StackOVerflow, too. There is no multithreading in that example. Now I modified that example "based" on your solution. But the GUI is still freezing why my tasks are working. Your solution is a bit to complex for me and use some techniques (the server think) I don't know. Could you please throw an eye on the current state of my code? From bha100710 at gmail.com Thu Dec 21 02:43:59 2017 From: bha100710 at gmail.com (Bhaskar Chaudhary) Date: Thu, 21 Dec 2017 13:13:59 +0530 Subject: [Tkinter-discuss] TKinter and Python asyncio In-Reply-To: <3z25rm6Sc8z9rxd@submission02.posteo.de> References: <3z0KFr6Wpjz9rxM@submission02.posteo.de> <3z0srL2JyYz9rxQ@submission02.posteo.de> <3z1XS23SZ1z9rxR@submission02.posteo.de> <20171220002301.e8775e06730d6ccdff2ea227@web.de> <3z1ZCh5l3Sz9rxG@submission02.posteo.de> <3z25rm6Sc8z9rxd@submission02.posteo.de> Message-ID: Hi In a slight modification to your code, I created the asyncio event_loop in the main thread and passed it as an argument to the asyncio thread. Now Tkinter won't freeze while the urls are fetched. I have added the modified code as an answer to your stack overflow question here: https://stackoverflow.com/a/47920128/2348704 regards On 12/21/17, c.buhtz at posteo.jp wrote: > X-Post: > > > Dear Bhaskar, > > thank you very much for your answer and the links. > > On 2017-12-20 13:06 Bhaskar Chaudhary wrote: >> Here's a very simple example I borrowed from >> http://blog.iharder.net/2017/02/03/python-asyncio-and-tkinter-together-with-tcp-and-udp/: >> >> This listens for tcp messages on port 9999 and prints it to a Tkinter >> label as and when the message arrives. >> [..] >> Also note that in the above example - the async i/o loop is run in a >> separate thread. But that is just one thread to handle and it is much >> better tan handling one new thread for every new request. > > It also came to my (and others) minds to separate each loop in it's own > thread. But I am for a way from being a professional in that topics. > > I created a minimal working example to ask that question on > StackOVerflow, too. There is no multithreading in that example. > > > Now I modified that example "based" on your solution. But the GUI is > still freezing why my tasks are working. Your solution is a bit to > complex for me and use some techniques (the server think) I don't know. > > Could you please throw an eye on the current state of my code? > > _______________________________________________ > Tkinter-discuss mailing list > Tkinter-discuss at python.org > https://mail.python.org/mailman/listinfo/tkinter-discuss > From rrr at onionmail.info Sat Dec 30 20:54:00 2017 From: rrr at onionmail.info (R) Date: Sun, 31 Dec 2017 01:54:00 +0000 Subject: [Tkinter-discuss] Tkinter: using OS-default symbols and icons In-Reply-To: <3z0j8d38Thz9rxR@submission02.posteo.de> References: <3z0j8d38Thz9rxR@submission02.posteo.de> Message-ID: c.buhtz at posteo.jp: > When using Tkinter in Python3 and creating Toolbars (using Frame and > Button) I need icons for the buttons. > > Is there a plattform independed way to use the OS-default symbols? e.g. > the symbol set that is configured in the desktop environment (xfce, > kde, gnome, ...) or the symbols on the different MS Windows version? I believe there is an OS indy way to do it From rrr at onionmail.info Sat Dec 30 20:50:00 2017 From: rrr at onionmail.info (R) Date: Sun, 31 Dec 2017 01:50:00 +0000 Subject: [Tkinter-discuss] why from _tkinter import * ? why the underscore Message-ID: why from _tkinter import * ? why the underscore in _tkinter ? From rrr at onionmail.info Sat Dec 30 20:58:00 2017 From: rrr at onionmail.info (R) Date: Sun, 31 Dec 2017 01:58:00 +0000 Subject: [Tkinter-discuss] Contribution to Tkinter's Documentation In-Reply-To: References: Message-ID: what is needed urgently are working code examples. enough blabber on syntax we get everywhere From rikudou__sennin at outlook.com Sun Dec 31 11:08:52 2017 From: rikudou__sennin at outlook.com (adil gourinda) Date: Sun, 31 Dec 2017 16:08:52 +0000 Subject: [Tkinter-discuss] Contribution to Tkinter's Documentation In-Reply-To: References: , Message-ID: which parts of Tkinter you find difficult to understand ? ________________________________ From: Tkinter-discuss on behalf of R Sent: Sunday, December 31, 2017 1:58:00 AM To: tkinter-discuss at python.org Subject: Re: [Tkinter-discuss] Contribution to Tkinter's Documentation what is needed urgently are working code examples. enough blabber on syntax we get everywhere _______________________________________________ Tkinter-discuss mailing list Tkinter-discuss at python.org https://mail.python.org/mailman/listinfo/tkinter-discuss -------------- next part -------------- An HTML attachment was scrubbed... URL: From rrr at onionmail.info Sun Dec 31 20:46:00 2017 From: rrr at onionmail.info (R) Date: Mon, 01 Jan 2018 01:46:00 +0000 Subject: [Tkinter-discuss] Contribution to Tkinter's Documentation In-Reply-To: References: Message-ID: adil gourinda: > which parts of Tkinter you find difficult to understand ? well I kinda struggle with setup tools and such things. usually it all breaks down before I can even launch a tk app. From rikudou__sennin at outlook.com Sun Dec 31 14:22:12 2017 From: rikudou__sennin at outlook.com (adil gourinda) Date: Sun, 31 Dec 2017 19:22:12 +0000 Subject: [Tkinter-discuss] why from _tkinter import * ? why the underscore In-Reply-To: References: Message-ID: where have you seen that example? ________________________________ From: Tkinter-discuss on behalf of R Sent: Sunday, December 31, 2017 1:50:00 AM To: tkinter-discuss at python.org Subject: [Tkinter-discuss] why from _tkinter import * ? why the underscore why from _tkinter import * ? why the underscore in _tkinter ? _______________________________________________ Tkinter-discuss mailing list Tkinter-discuss at python.org https://mail.python.org/mailman/listinfo/tkinter-discuss -------------- next part -------------- An HTML attachment was scrubbed... URL: