Skip to content
Snippets Groups Projects
Commit 479b37b5 authored by u214892's avatar u214892
Browse files

switch for Tk.Toplevel

parent 1f946b87
No related branches found
No related tags found
No related merge requests found
......@@ -9,6 +9,10 @@ import pkg_resources
from benchmarker import Benchmarker
from importlib_resources import path
from flatland.utils import graphics_pil
graphics_pil.unattended_switch = True
for entry in [entry for entry in importlib_resources.contents('examples') if
not pkg_resources.resource_isdir('examples', entry)
and entry.endswith(".py")
......
......@@ -8,11 +8,11 @@ import pkg_resources
from importlib_resources import path
from benchmarks.benchmark_utils import swap_attr
from flatland.utils import graphics_pil
def profile(resource, entry):
with path(resource, entry) as file_in:
# TODO remove input() from examples
print("*****************************************************************")
print("Profiling {}".format(entry))
......@@ -25,6 +25,8 @@ def profile(resource, entry):
cProfile.run('my_func()', sort='time')
graphics_pil.unattended_switch = True
for entry in [entry for entry in importlib_resources.contents('examples') if
not pkg_resources.resource_isdir('examples', entry)
and entry.endswith(".py")
......
......@@ -7,14 +7,21 @@ import pkg_resources
from importlib_resources import path
from benchmarks.benchmark_utils import swap_attr
from flatland.utils import graphics_pil
graphics_pil.unattended_switch = True
for entry in [entry for entry in importlib_resources.contents('examples') if
not pkg_resources.resource_isdir('examples', entry)
and entry.endswith(".py")
and '__init__' not in entry
and 'example_basic_elements_test' not in entry
and 'demo.py' not in entry
]:
with path('examples', entry) as file_in:
print("")
print("")
print("")
print("*****************************************************************")
print("Running {}".format(entry))
print("*****************************************************************")
......
......@@ -33,6 +33,9 @@ from flatland.core.grid.rail_env_grid import RailEnvTransitions # noqa: E402
class PILGL(GraphicsLayer):
# hack: in continuous integration, we run multiple
unattended_switch = False
def __init__(self, width, height, jupyter=False):
self.yxBase = (0, 0)
self.linewidth = 4
......@@ -157,9 +160,14 @@ class PILGL(GraphicsLayer):
def open_window(self):
assert self.window_open is False, "Window is already open!"
# use tk.Toplevel() instead of tk.Tk()
# https://stackoverflow.com/questions/26097811/image-pyimage2-doesnt-exist
self.window_root = tk.Tk()
if self.unattended_switch:
# use tk.Toplevel() instead of tk.Tk() since we run all examples from the same python script
# https://stackoverflow.com/questions/26097811/image-pyimage2-doesnt-exist
tk.Toplevel()
else:
tk.Tk()
self.window_root = tk.Toplevel()
self.window_root.withdraw()
self.window = tk.Toplevel(self.window_root)
self.window.title("Flatland")
......
......@@ -97,7 +97,8 @@ commands =
; run examples from subfolder to ensure that resources are accessed via resources and not via relative paths
sh -c 'mkdir -p {envtmpdir}/c236d3c240d61a0969d4cb59e2180ce5'
; pipe echo into python since some examples expect input to close the window after the example is run
sh -c 'cd {envtmpdir}/c236d3c240d61a0969d4cb59e2180ce5 && python {toxinidir}/benchmarks/run_all_examples.py'
; sh -c 'cd {envtmpdir}/c236d3c240d61a0969d4cb59e2180ce5 && python {toxinidir}/benchmarks/run_all_examples.py'
sh -c 'python {toxinidir}/benchmarks/run_all_examples.py'
[testenv:notebooks]
basepython = python
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment