Skip to content

Commit 459c60a

Browse files
committed
[pyroot] handle ProcessEvents() return value
It is interrupt flag, which can be triggered from canvas context menu. Has similar effect as prssing space button
1 parent c391582 commit 459c60a

File tree

1 file changed

+8
-11
lines changed
  • bindings/pyroot/pythonizations/python/ROOT/_pythonization

1 file changed

+8
-11
lines changed

bindings/pyroot/pythonizations/python/ROOT/_pythonization/_tcanvas.py

+8-11
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,21 @@
11
from . import pythonization
22

33
def wait_press_windows():
4-
import ROOT
4+
from ROOT import gSystem
55
import msvcrt
66
import time
77

8-
done = False
9-
while not done:
10-
k = ''
11-
ROOT.gSystem.ProcessEvents()
8+
while not gSystem.ProcessEvents():
129
if msvcrt.kbhit():
1310
k = msvcrt.getch()
14-
done = k[0] == 32
11+
if k[0] == 32:
12+
break
1513
else:
1614
time.sleep(0.01)
1715

1816

1917
def wait_press_posix():
20-
import ROOT
18+
from ROOT import gSystem
2119
import sys
2220
import select
2321
import tty
@@ -30,8 +28,7 @@ def wait_press_posix():
3028

3129
try:
3230

33-
while True:
34-
ROOT.gSystem.ProcessEvents()
31+
while not gSystem.ProcessEvents():
3532
c = ''
3633
if select.select([sys.stdin], [], [], 0) == ([sys.stdin], [], []):
3734
c = sys.stdin.read(1)
@@ -48,14 +45,14 @@ def _TCanvas_Update(self, *args, **kwargs):
4845
Invoke normal Draw, but then run event loop until key is pressed
4946
"""
5047

51-
import ROOT
48+
from ROOT import gROOT
5249
import os
5350
import sys
5451

5552
self._Update(*args, **kwargs)
5653

5754
# no special handling in batch mode
58-
if ROOT.gROOT.IsBatch():
55+
if gROOT.IsBatch():
5956
return
6057

6158
# no special handling in case of notebooks

0 commit comments

Comments
 (0)