-
-
Save kat0h/5f31d7a814c1f9aa6c64ac06bce0706b to your computer and use it in GitHub Desktop.
# This code is licensed under CC0 | |
import PySimpleGUI as sg | |
import pyautogui | |
def get_cursorpos(): | |
return pyautogui.position() | |
def get_winpos(window): | |
return window.CurrentLocation() | |
sg.theme('Default1') | |
layout = [ | |
[sg.T(size=(20, 1), justification='center', key='-mousepos-')], | |
[sg.T(size=(20, 1), justification='center', key='-winpos-')], | |
] | |
window = sg.Window('Pos', layout) | |
while True: | |
event, values = window.read(timeout=1000/60, timeout_key='-timeout-') | |
if event in (None,): | |
break | |
elif event in '-timeout-': | |
cursorpos = get_cursorpos() | |
window['-mousepos-'].update("CursorPos x:{} y:{}".format(cursorpos[0], cursorpos[1])) | |
winpos = get_winpos(window) | |
window['-winpos-'].update("WindowPos x:{} y:{}".format(winpos[0], winpos[1])) |
Thank you. I didn't know the good way to write python and PySimpleGUI.
So your point was very helphul.
Thank you very much!
I made this (https://github.com/kato-k/parroteye) program to learn PySimpleGUI.
I don't make use of what I have learned yet, so I will refrect changes.
(I'm not good at English, so my text may be hard to read)
You're welcome. Your English is great. Your text is not hard to read. I honestly didn't know English wasn't your first language. That's an added level of difficulty.
I'm impressed you have learned something not published anywhere that I know of, using pyautogui and PySimpleGUI together. You also ran an async event loop, an advanced feature.
Hoping my suggestions (there were a LOT of them) were not taken as criticism. Your code WORKED. Nothing I suggested as a serious problem. And as I said in my previous message, it's really easy for someone to suggest improvements to code that's already written. I'm glad you found it useful and are using it as a learning opportunity! Really what I was hoping for.
BTW, it's EASY for someone to come along after you've done all the hard work, and make changes like mine. I did nothing difficult. YOU did all the hard work. I tweaked things.