Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] Error code in example code for Desktop Floating Widget - Timer #6646

Open
9 tasks
zxrobinson opened this issue Jan 9, 2024 · 1 comment
Open
9 tasks
Labels
Bug Something's not right documentation Docs need updating Port - TK PySimpleGUI

Comments

@zxrobinson
Copy link

zxrobinson commented Jan 9, 2024

Type of Issue (Enhancement, Error, Bug, Question)

Bug


Operating System

Ubuntu Linux 23.10

PySimpleGUI Port (tkinter, Qt, Wx, Web)

tkinter


Versions

Version information can be obtained by calling sg.main_get_debug_data()
Or you can print each version shown in ()

Python version (sg.sys.version)

3.11.6

PySimpleGUI Version (sg.__version__)

4.60.5

GUI Version (tkinter (sg.tclversion_detailed), PySide2, WxPython, Remi)

8.6.13


Your Experience In Months or Years (optional)

2 Years Python programming experience

40 Years Programming experience overall

Have used another Python GUI Framework? (tkinter, Qt, etc) (yes/no is fine)
No

Anything else you think would be helpful?


Troubleshooting

These items may solve your problem. Please check those you've done by changing - [ ] to - [X]

  • Searched main docs for your problem www.PySimpleGUI.org
  • Looked for Demo Programs that are similar to your goal. It is recommend you use the Demo Browser! Demos.PySimpleGUI.org
  • None of your GUI code was generated by an AI algorithm like GPT
  • If not tkinter - looked for Demo Programs for specific port
  • For non tkinter - Looked at readme for your specific port if not PySimpleGUI (Qt, WX, Remi)
  • Run your program outside of your debugger (from a command line)
  • Searched through Issues (open and closed) to see if already reported Issues.PySimpleGUI.org
  • Have upgraded to the latest release of PySimpleGUI on PyPI (lastest official version)
  • Tried using the PySimpleGUI.py file on GitHub. Your problem may have already been fixed but not released

Detailed Description

I'm simply trying to help with your Timer example on the https://github.com/PySimpleGUI page.

When I copied the code into Visual Studio Code, saved it and ran it using the version of Python above, I got the following errors:

  File "/home/user/projects/python-gui/timer-example.py", line 46
    event = window[event).GetText()
                        ^
SyntaxError: closing parenthesis ')' does not match opening parenthesis '['

  File "/home/user/projects/python-gui/timer-example.py", line 57
    element = window['button')
                             ^
SyntaxError: closing parenthesis ')' does not match opening parenthesis '['
/home/user/projects/python-gui/timer-example.py:50: SyntaxWarning: "is" with a literal. Did you mean "=="?
  if event is 'Reset':

I believe that there was an open square bracket-close parenthesis match problem as well. I fixed these for myself, but thought you should know that they're in the code on the webpage...

Code To Duplicate

None

Screenshot, Sketch, or Drawing


Watcha Makin?

@pysimpleissue pysimpleissue bot closed this as completed Jan 9, 2024
@pysimpleissue pysimpleissue bot added Fill issue form or you will be REJECTED You MUST use the supplied template to submit a request. PySimpleGUI Issues Bot Has Detected an Error labels Jan 9, 2024
@jason990420 jason990420 changed the title [ Enhancement/Bug/Question] NOTE - you can also call sg.main() or sg.main_open_github_issue() to post an issue [Bug] Error code in example code for Desktop Floating Widget - Timer Jan 10, 2024
@pysimpleissue pysimpleissue bot removed Fill issue form or you will be REJECTED You MUST use the supplied template to submit a request. PySimpleGUI Issues Bot Has Detected an Error labels Jan 10, 2024
@pysimpleissue pysimpleissue bot reopened this Jan 10, 2024
Repository owner deleted a comment from pysimpleissue bot Jan 10, 2024
Repository owner deleted a comment from pysimpleissue bot Jan 10, 2024
@jason990420
Copy link
Collaborator

Maybe the link for the wrong code is

desktop-floating-widget---timer

    if event is 'Reset':
        start_time = int(round(time.time() * 100))
        current_time = 0
        paused_time = start_time
    elif event == 'Pause':
        paused = True
        paused_time = int(round(time.time() * 100))
        element = window['button')          # <----- here
        element.update(text='Run')
    elif event == 'Run':
        paused = False
        start_time = start_time + int(round(time.time() * 100)) - paused_time
        element = window['button')          # <----- and here
        element.update(text='Pause')

@jason990420 jason990420 added Bug Something's not right documentation Docs need updating Port - TK PySimpleGUI labels Jan 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something's not right documentation Docs need updating Port - TK PySimpleGUI
Projects
None yet
Development

No branches or pull requests

2 participants