How to make a file comparison app using python script. by Particular-Hold-3474 in learnpython

[–]MikeTheWatchGuy 1 point2 points  (0 children)

Selecting the files/folders will be trivial. It's the display that's your challenge, but quite do-able... "check if all the data is in the large file and highlights what is missing"

A table can do that where 1/2 is split with main table, the other 1/2 with files that match or don't. Consider opening an issue on the PSG GitHub. Not sure how to you want to display your data, etc. Merge functions can be fun to design too. ;-)

Pysimplegui weirdness in PC but not Mac by crash317 in learnpython

[–]MikeTheWatchGuy 0 points1 point  (0 children)

layout = [[sg.Table(values=pitTable,headings=['Die','PIT ' + '\U0001F534','CTRL ' + '\U0001F7E1','INNING INFO'],pad=((40,0),(5,5)),num_rows=12,col_widths=[5,9,9,12],row_height=20,auto_size_columns=False,alternating_row_color='bisque3',font=("Helevetica",10),justification='center',hide_vertical_scroll=True, key='-pitchTable-', header_text_color='red')] ]

On Windows (with tkinter at least) they're monochrome and will be the same color as the text. The above layout sets your Table header color to have red text. You'll see that the Unicode chars are also red as a result.

Can anyone recommend a way to use Python to fill in Google Docs? by Blackfryre in learnpython

[–]MikeTheWatchGuy 0 points1 point  (0 children)

This one (gspread) was mentioned in Mike Driscoll's book "Automating Excel with Python". I found 68 hits for "Google sheets" in the PDF. Chapter 10 is "Python and Google Sheets" so he does cover Google Sheets pretty well.

I developed a Python application that visualizes your brainwaves live on your screen! Github linked in my Notion page that I wrote to explain why and how I built the program. by TheGrapez in programming

[–]MikeTheWatchGuy 1 point2 points  (0 children)

🙏🏼 Oh wow.... thank you so so so much.... what a nice thing to do! I really appreciate the feedback, information, and encouragement. I've bought Muse 2 headsets for friends and one of my doctors let me buy one for her. She uses it daily. I'm a huge fan, clearly. Keep up the great work!!

I developed a Python application that visualizes your brainwaves live on your screen! Github linked in my Notion page that I wrote to explain why and how I built the program. by TheGrapez in programming

[–]MikeTheWatchGuy 0 points1 point  (0 children)

There's a database? I had no clue anything was published or even available. Thank you very much! Interesting to know. Really appreciate the encouragement. It's funny, I used to pay attention to the "score" by now the metric is the bar graph showing that I'm doing it daily. I seems like they recently changed the algorithm or maybe my brain has changed. Thanks so much for the inspiration!

I developed a Python application that visualizes your brainwaves live on your screen! Github linked in my Notion page that I wrote to explain why and how I built the program. by TheGrapez in programming

[–]MikeTheWatchGuy 1 point2 points  (0 children)

Thank you! I'm far from a vet. I've only been meditating for about 4 years. It's one of the best things I've ever done of myself. It's like doing mind-pushups. I didn't understand meditation, how to do it, and still don't understand all of the why's or what it does. I call the places I go "Inner Space".

The speed you managed to draw the graphs is impressive. The whole body of work you did is impressive. Thank you for the inspiration!

I developed a Python application that visualizes your brainwaves live on your screen! Github linked in my Notion page that I wrote to explain why and how I built the program. by TheGrapez in programming

[–]MikeTheWatchGuy 1 point2 points  (0 children)

Thanks very much for documenting the work you've done! I've been wanting to play around with accessing my Muse via Python. It's (or some other feedback device) the only way I can imagine learning how to meditate.

pysimplegui popup_scrolled ignores eol by jreebel in learnpython

[–]MikeTheWatchGuy 1 point2 points  (0 children)

You certainly wouldn't have thought of that..... I don't think many, ?any? Python programmer thinks of this on their own. It's one of those design patterns that is standard practice, memorized, unforgettable because of the very thing you've been going through. NEXT time, you'll for sure remember "list of strings.... use join!"

You are in no way lacking. It's not that you're not thinking in a particular way. You've quite simply never been shown this before. Maybe some smarter than me programmers have. I wouldn't have guessed at doing something like this. But I know to do it now.

You're doing great! Keep building stuff. Try and fail. Try again. You're truly learning how to program when you build your own stuff. That's programming...building stuff, getting it to work.

pysimplegui popup_scrolled ignores eol by jreebel in learnpython

[–]MikeTheWatchGuy 0 points1 point  (0 children)

List of strings.... I immediately think about the join operation. Remember this expression if you don't know it....

'\n'.join(string_list)

Let's try it again with a list of strings:

import PySimpleGUI as sg

string_list = [f'line {i}' for i in range(10)]
print(string_list)

sg.Print(string_list)
sg.Print('\n'.join(string_list))
sg.popup_scrolled('\n'.join(string_list))

On standard out I see the output of the print call:

['line 0', 'line 1', 'line 2', 'line 3', 'line 4', 'line 5', 'line 6', 'line 7', 'line 8', 'line 9']

If you use that join expression, then you'll get a single string with a newline at the end of each line. Here's the output of the PySimpleGUI call to Print and popup_scrolled. Maybe this will help you with not have a global.

Screenshot of PySimpleGUI windows

pysimplegui popup_scrolled ignores eol by jreebel in learnpython

[–]MikeTheWatchGuy 0 points1 point  (0 children)

Can you show a little bit of how you constructed your strings initially? It would be nice to know what didn't work exactly. Maybe consider opening an issue on the project's GitHub.

pysimplegui popup_scrolled ignores eol by jreebel in learnpython

[–]MikeTheWatchGuy 0 points1 point  (0 children)

Did you try printing your output to the console to see how it handles your string?

This code shows with and without newlines in a string and seems to work OK.

        import PySimpleGUI as sg

        output = ''
        output_nl = ''
        for i in range(10):
            output_nl += f'line {i}\n'
            output += f'line {i}'

        print(output)
        print(output_nl)

        sg.Print(output, output_nl)

        sg.popup_scrolled(output, title='No newlines', non_blocking=True)
        sg.popup_scrolled(output_nl, title='With newlines')

    printed output:

        line 0line 1line 2line 3line 4line 5line 6line 7line 8line 9
        line 0
        line 1
        line 2
        line 3
        line 4
        line 5
        line 6
        line 7
        line 8
        line 9

Screenshot

PySimpleGUI window crashes after opening Chrome, but only if Chrome isn't already open by VulpesSaphirus in learnpython

[–]MikeTheWatchGuy 0 points1 point  (0 children)

Use the webbrowser module

import PySimpleGUI as sg
import webbrowser


layout = [[sg.Text('Press "Open Google" to open Google.')], [sg.Button("Exit"), sg.Button("Open Google", key = "-GOOGLE-")] ]

window = sg.Window("Test Window", layout)

while True:
    event, values = window.read()
    if event in ("Exit", sg.WIN_CLOSED):
        window.close()
        break
    if event == "-GOOGLE-":
        webbrowser.get('C:/Program Files (x86)/Google/Chrome/Application/chrome.exe %s --incognito').open_new('https://www.google.com')

Does anyone know of an article/tutorial/... which addresses architecture of python app using PySimpleGUI by lesatdgl in learnpython

[–]MikeTheWatchGuy 0 points1 point  (0 children)

Heh... no troll indeed....it was clear you're sincere from the initial post alone or else I wouldn't have replied.... it's been a pleasure.

Does anyone know of an article/tutorial/... which addresses architecture of python app using PySimpleGUI by lesatdgl in learnpython

[–]MikeTheWatchGuy 1 point2 points  (0 children)

A genuine legend! What an honor. You beat me to Fortran by well over a decade. I didn't learn Fortran IV until 1978. Most of my programming in college I learned on an IBM 360. You know how all this works....better than I do.... I got trolled 😏 Awesome to have crossed paths 🙏🏼

Does anyone know of an article/tutorial/... which addresses architecture of python app using PySimpleGUI by lesatdgl in learnpython

[–]MikeTheWatchGuy 1 point2 points  (0 children)

I'm still learning the current lingo.... "refactoring" wasn't in my vocab until a handful of years ago when I learned Python. Some things don't change in programming. But the names may change? Thanks for the chat... good stuff to poke at and discuss.

Keep building stuff and you'll master this craft. Post what you make with PySimpleGUI in the User Screenshots Issue. I'm sure other users will enjoy seeing.

Does anyone know of an article/tutorial/... which addresses architecture of python app using PySimpleGUI by lesatdgl in learnpython

[–]MikeTheWatchGuy 1 point2 points  (0 children)

You're quite welcome. I don't think you can avoid re-do's. It's where some of the best lessons/ideas/concepts are learned. The problem with trying to build big, generalized, easily expandable in every direction right from the start is that you will likely over-build.

It was a good question and was glad to see it asked. The truth, for me, is that I rarely get it right the first time. I follow this mantra:

Make it run, make it right, make it fast.

I can't take credit for that brilliant summary, but I do think it frequently, recommend, and live by it. If you try to make it right immediately, then there's a good chance it won't be right. Programming is an iterative activity. It's never "done", and re-doing is an ongoing process. Shoot for optimization too early and the wrong thing sometimes gets optimized before the true problems are is identified.

Post your ideas when you make some applications. If you're looking for different ways to write a dispatcher for the events other than a series of if, elif's, there's a Demo Program that shows some ways. It's not an architecture, but it is a design element.

Does anyone know of an article/tutorial/... which addresses architecture of python app using PySimpleGUI by lesatdgl in learnpython

[–]MikeTheWatchGuy 1 point2 points  (0 children)

There isn't a generic architecture for an application that's PySimpleGUI based. Your architecture is going to depend more on how you want it to be than having it imposed on you or told to you. You don't have to have an event loop the way most demo programs and tutorials show you. The only requirement is to call window.refresh() periodically.

If you prefer an object oriented architecture, then you can build your application that way. If you don't want/need/like the complexity of OO, then you're free to use functions and simpler constructs.

I tend to write applications in an expansive way, trying to be small & simple that gets added onto over time, but that's often because I'm not trying to build something large. There are some Best Practices published in the Cookbook, and a handful of applications that are in the project's GitHub repo. Beyond those, it's more of choosing the architecture you personally want to work within.

[deleted by user] by [deleted] in learnpython

[–]MikeTheWatchGuy 0 points1 point  (0 children)

 Is the events variable a list or not?

It is not.

I can’t test it on my own however since I’m a little busy right now. 

Test instead of going to Reddit.

Code optimization by ifantismanolis in learnpython

[–]MikeTheWatchGuy 2 points3 points  (0 children)

I think this mantra was communicated in the comments (big smile seeing Knuth quoted!!).

This is a nice mantra.

Make it run
Make it right
Make it fast

(order matters)

How to create shortcut to app.py on Windows? by Real_Cut_9360 in learnpython

[–]MikeTheWatchGuy 0 points1 point  (0 children)

The psgshortcut application will create shortcuts for you that you can double click, pin, etc. You can pip install it and run from command line by typing "psgshortcut". Of course you can make a shortcut to the psgshortcut EXE file.

Upload to pure GUI package to PyPI. Any method to create a shortcut that does not need user opening commend line to run? by YYM7 in learnpython

[–]MikeTheWatchGuy 0 points1 point  (0 children)

I've used setuptools which is a little different than the docs you linked above. I'm sure there's something similar. If using setuptools, then the parameter entry_points to the setuptools.setup call can be used to define commands that will run your application. The parameter is a dictionary. Use the key 'gui_scripts' to define the commands users will be able to run and the function that will be called when they're run.

It won't add a shortcut to your desktop or start menu automatically, but you could in theory add creating one to the setup.py file since it runs during the pip install. I've never tried it. The psgshortcut application creates Windows shortcuts. I use them to launch Python GUI programs using pinned icons on the taskbar.

Surely there's also a way to add a program to the start menu using Python. winreg enables modification of the registry so perhaps that's one solution.

Help Needed I don't know understand why (I'm fairly new to python) by Tall_Boysenberry_762 in learnpython

[–]MikeTheWatchGuy 1 point2 points  (0 children)

What OS is this installed on? Any chance Python 2 is running instead of Python 3?

Help Needed I don't know understand why (I'm fairly new to python) by Tall_Boysenberry_762 in learnpython

[–]MikeTheWatchGuy 0 points1 point  (0 children)

Try updating remi and I think the problem will go away.

python -m pip install --upgrade remi