From fb66cc8d7343d3c178e3c9c15246220b335513bc Mon Sep 17 00:00:00 2001 From: Sergey Linev Date: Tue, 4 Feb 2025 15:51:15 +0100 Subject: [PATCH] [pyroot] handle ProcessEvents() return value It is interrupt flag, which can be triggered from canvas context menu. Has similar effect as prssing space button --- .../python/ROOT/_pythonization/_tcanvas.py | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/bindings/pyroot/pythonizations/python/ROOT/_pythonization/_tcanvas.py b/bindings/pyroot/pythonizations/python/ROOT/_pythonization/_tcanvas.py index 17b7f839b6cc5..af9d9e94d8d85 100644 --- a/bindings/pyroot/pythonizations/python/ROOT/_pythonization/_tcanvas.py +++ b/bindings/pyroot/pythonizations/python/ROOT/_pythonization/_tcanvas.py @@ -1,23 +1,21 @@ from . import pythonization def wait_press_windows(): - import ROOT + from ROOT import gSystem import msvcrt import time - done = False - while not done: - k = '' - ROOT.gSystem.ProcessEvents() + while not gSystem.ProcessEvents(): if msvcrt.kbhit(): k = msvcrt.getch() - done = k[0] == 32 + if k[0] == 32: + break else: time.sleep(0.01) def wait_press_posix(): - import ROOT + from ROOT import gSystem import sys import select import tty @@ -30,8 +28,7 @@ def wait_press_posix(): try: - while True: - ROOT.gSystem.ProcessEvents() + while not gSystem.ProcessEvents(): c = '' if select.select([sys.stdin], [], [], 0) == ([sys.stdin], [], []): c = sys.stdin.read(1)