RetR0-hex / ArtWork-Downloader-GUI

MIT License
1 stars 0 forks source link

Nicely done! #1

Closed PySimpleGUI closed 3 years ago

PySimpleGUI commented 3 years ago

LOVE the GIF in your readme. Wished that all PySimpleGUI users had one, or at least a JPG. So many more people will stop and look if you've got an image.

I noticed in the GIF a block of text in the multiline that quickly scrolled off the screen. It's supposed to be large letters made from text. If you change the font of your Output element to be a mono-spaced font, then you'll get those kinds of blocks of text correctly displayed. Courier is one choice of mono-spaced font.

I don't believe that it's been explicitly put into the Cookbook, maybe it's there but not in the main doc, but the better way to do stdout output is the Multiline element now. There is a parameter added last year that will re-route stdout to the element so that it functiions like the Output element. The large advantage that it has over the Output element is that you can call the function Multiline.print to do colored printing. It's a really nice feature.

Most all of my newer programs that print, now call this kind of print instead.

This demo was released this week:

image

The Multiline on the right with the color output was achieved using a Multiline. You can also use a function called cprint to do prints to Multilines.

Anyway, just a though, certainly nothing wrong with what you're doing.

Thanks much for the post. Always inspiring to see what users like you make!

RetR0-hex commented 3 years ago

Thanks for writing here, you were the first one to do so... :) Fixed the font problem. but I think the problem I was having with multiline print was that you couldn't do it from multiple different threads. I was getting an error "tkinter is not the same thread" or something like that.

PySimpleGUI commented 3 years ago

Multithreading and PySimpleGUI..... or more precisely, multithreading and tkinter, haunt me. They are my nightmare. I have spent more time debugging this problem than any other in PySimpleGUI. It took YEARS to finally understand what caused it and why it would happen seemingly randomly. The random part is due to when Python calls garbage collect.

I'm going to skip over 5 paragraphs of explanation and get straight to: Doing anything directly in a thread with your GUI is a recipe for disaster. This includes making a call to "print" when the stdout has been re-rerouted using Multiline or Output elements.

The reason even using "print" is a problem is that eventually that call to print is going to end up calling code in the PySimpleGUI.py file that then calls tkinter and that's the point the shit hits the fan. Splat.

The ABSOLUTE SAFEST thing for you to do is to communicate what you want printed out, using a QUEUE, to your mainthread, and then printing that info. This means running your event loop in a polling / async mode. Don't use write_event_value if you want to be safe. The technique I used that was supposed to be "safe" turned out not to be safe. You can try using write_event_value instead of directly manipulating PySimpleGUI from a thread, but it might still not work.

I hope that makes sense. If it doesn't, open an Issue on http://Issues.PySimpleGUI.org and Jason will give you a hand. I'm required to be away from the project support while I focus on the new Udemy course.

RetR0-hex commented 3 years ago

oh yeah... Easy fix using a global info/print queue and then just print that queue in the main GUI thread

PySimpleGUI commented 3 years ago

One of the demo programs shows using a queue like this. I think you understand enough you don't need the demo. If I find it, I'll let you know.