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] one_line_progress_meter does not return False when pressing X on Windows #5034

Closed
4 of 7 tasks
mrtnbm opened this issue Dec 18, 2021 · 15 comments
Closed
4 of 7 tasks
Labels
documentation Docs need updating Port - TK PySimpleGUI question Further information is requested

Comments

@mrtnbm
Copy link

mrtnbm commented Dec 18, 2021

Type of Issue (Bug)

BUG: one_line_progress_meter does not return False and does not close the window when pressing X on Windows. The 'X' button isn not working at all.


Operating System

Windows 10 - 64 Bit

PySimpleGUI Port (tkinter, Qt, Wx, Web)

tkinter


Versions

'4.55.1 Released 7-Nov-2021'

Python version (sg.sys.version)

'3.9.4 (tags/v3.9.4:1f2e308, Apr 4 2021, 13:27:16) [MSC v.1928 64 bit (AMD64)]'

PySimpleGUI Version (sg.__version__)

4.55.1

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

'8.6.9'


Your Experience In Months or Years (optional)

Years Python programming experience

Years Programming experience overall

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

Anything else you think would be helpful?


Troubleshooting

  • Searched main docs for your problem www.PySimpleGUI.org
  • Looked for Demo Programs that are similar to your goal Demos.PySimpleGUI.org
  • 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
  • Tried using the PySimpleGUI.py file on GitHub. Your problem may have already been fixed but not released

Detailed Description

One Line Progress Meter cannot be closed with the "X" Button in the Win10 titlebar. The functionality only works with the Cancel button.

Code To Duplicate

import time
import PySimpleGUI as sg

for i in range(1, 200):
    time.sleep(0.1)
    if not sg.one_line_progress_meter(title="test", current_value=i, max_value=200,
                                      no_button=False):
        print('returned false')
        break

Screenshot, Sketch, or Drawing


Watcha Makin?

If you care to share something about your project, it would be awesome to hear what you're building.

@jason990420 jason990420 added question Further information is requested Port - TK PySimpleGUI labels Dec 18, 2021
@jason990420
Copy link
Collaborator

jason990420 commented Dec 18, 2021

For the window of sg.one_line_progress_meter, it is defined as disable_close=True, so this window cannot be closed by clicking Close button of window, Only Cancel button work for it.

Extra statement to call sg.one_line_progress_meter_cancel() required to close this window.

import time
import PySimpleGUI as sg

for i in range(1, 200):
    time.sleep(0.1)
    if not sg.one_line_progress_meter(title="test", current_value=i, max_value=200, no_button=False):
        print('returned false')
        break
sg.one_line_progress_meter_cancel()

@mrtnbm
Copy link
Author

mrtnbm commented Dec 18, 2021

Thanks for your reply.
Unfortunately, your code example still does not work for me, the Windows title bar button 'X' has no functionality when trying to press it. Furthermore, the function one_line_progress_meter_cancel() is not documented in https://pysimplegui.readthedocs.io/en/latest/#progress-meters, that's why I didn't knew about it.

@jason990420
Copy link
Collaborator

Just add one more statement to your code to close the progress meter window.
The Close button of window is defined not functional.

@mrtnbm
Copy link
Author

mrtnbm commented Dec 18, 2021

Thanks for your fast reply.
Sorry, I don't know exactly how I would add the functionality of the Windows titlebar button or Close button.

@jason990420
Copy link
Collaborator

jason990420 commented Dec 18, 2021

OK, following code show the hack way

  • Find the window for one_line_progress_meter
  • Set the attribute DisableClose of quick-meter window to False
import time
import PySimpleGUI as sg

sg.one_line_progress_meter(title="test", current_value=0, max_value=200, no_button=False)
key='OK for 1 meter'
meter = sg.QuickMeter.active_meters[key]
meter.window.DisableClose = False

for i in range(1, 200):
    time.sleep(0.1)
    if not sg.one_line_progress_meter(title="test", current_value=i, max_value=200, no_button=False):
        print('returned false')
        break

sg.one_line_progress_meter_cancel()

@mrtnbm
Copy link
Author

mrtnbm commented Dec 18, 2021

Thank you very much! It works now.

Have a nice day.

@mrtnbm mrtnbm closed this as completed Dec 18, 2021
@PySimpleGUI PySimpleGUI added the documentation Docs need updating label Dec 20, 2021
@PySimpleGUI
Copy link
Owner

Let's open this as a documentation issue. There's a reason I changed this behavior and want to make sure it's documented that using the X will cause problems in some situations which is why it's no longer an option.

@PySimpleGUI PySimpleGUI reopened this Dec 20, 2021
@mrtnbm
Copy link
Author

mrtnbm commented Dec 20, 2021

Thanks for your fast help and kind words also on StackOverflow! I donated in order that this project will continue in the next years. Good luck!

@PySimpleGUI
Copy link
Owner

Thank you SO SO MUCH Martin! The help, the kind words from you, it's all part of what makes this project the special thing that it's been and I hope will continue to be. I really appreciate you going the extra mile to come and open an issue! That's really taking support way beyond what most would do on StackOverflow, and wow, it's really appreciated.

@wushuangpojun
Copy link

wushuangpojun commented Jan 5, 2023

OK, following code show the hack way

  • Find the window for one_line_progress_meter
  • Set the attribute of quick-meter window to DisableClose``False
import time
import PySimpleGUI as sg

sg.one_line_progress_meter(title="test", current_value=0, max_value=200, no_button=False)
key='OK for 1 meter'
meter = sg.QuickMeter.active_meters[key]
meter.window.DisableClose = False

for i in range(1, 200):
    time.sleep(0.1)
    if not sg.one_line_progress_meter(title="test", current_value=i, max_value=200, no_button=False):
        print('returned false')
        break

sg.one_line_progress_meter_cancel()

Why does my direct use of sg. QuickMeter cause Python to not respond?

@jason990420
Copy link
Collaborator

Why does my direct use of sg. QuickMeter cause Python to not respond?

It didn't tell us how you direct use of sg.QuickMeter.

Better have one new issue to describe your issue in detail .

@PySimpleGUI
Copy link
Owner

QuickMeter is not meant to be user accessible. It should have been named as _QuickMeter but I didn't think to do this at the time I created it. You should only be using one_line_progress_meter. The class is not in the call reference since it wasn't meant to be exposed.

@wushuangpojun
Copy link

wushuangpojun commented Jan 9, 2023

Why does my direct use of sg. QuickMeter cause Python to not respond?

It didn't tell us how you direct use of sg.QuickMeter.

Better have one new issue to describe your issue in detail .

For example,I use it like this

import PySimpleGUI as sg
for i in range(20):
    sg.QuickMeter("A",i+1,20,"*** B ***")

@jason990420
Copy link
Collaborator

The instance of the class QuickMeter just create a window (GUI), but no event loop to handle any event, of course, it will be no response.

@wushuangpojun
Copy link

The instance of the class QuickMeter just create a window (GUI), but no event loop to handle any event, of course, it will be no response.

Oh, I see.
Thank you very much! Have a nice day.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Docs need updating Port - TK PySimpleGUI question Further information is requested
Projects
None yet
Development

No branches or pull requests

4 participants