Skip to content
Snippets Groups Projects
Commit 87869d15 authored by Egli Adrian (IT-SCI-API-PFI)'s avatar Egli Adrian (IT-SCI-API-PFI)
Browse files

PIL (tk window) position and size

parent b09d90c1
No related branches found
No related tags found
No related merge requests found
...@@ -199,16 +199,16 @@ if True: ...@@ -199,16 +199,16 @@ if True:
demo_flatland_000 = Demo(Scenario_Generator.load_scenario('./env-data/railway/example_flatland_000.pkl')) demo_flatland_000 = Demo(Scenario_Generator.load_scenario('./env-data/railway/example_flatland_000.pkl'))
demo_flatland_000.renderer.resize() demo_flatland_000.renderer.resize()
demo_flatland_000.run_demo(300) demo_flatland_000.run_demo(60)
demo_flatland_000 = None demo_flatland_000 = None
demo_flatland_000 = Demo(Scenario_Generator.load_scenario('./env-data/railway/example_flatland_001.pkl')) demo_flatland_000 = Demo(Scenario_Generator.load_scenario('./env-data/railway/example_flatland_001.pkl'))
demo_flatland_000.renderer.resize() demo_flatland_000.renderer.resize()
demo_flatland_000.run_demo(300) demo_flatland_000.run_demo(60)
demo_flatland_000 = None demo_flatland_000 = None
demo_flatland_000 = Demo(Scenario_Generator.load_scenario('./env-data/railway/example_network_003.pkl')) demo_flatland_000 = Demo(Scenario_Generator.load_scenario('./env-data/railway/example_network_003.pkl'))
demo_flatland_000.renderer.resize() demo_flatland_000.renderer.resize()
demo_flatland_000.run_demo(1800) demo_flatland_000.run_demo(60)
demo_flatland_000 = None demo_flatland_000 = None
...@@ -28,14 +28,17 @@ class PILGL(GraphicsLayer): ...@@ -28,14 +28,17 @@ class PILGL(GraphicsLayer):
self.screen_height = min(self.screen_height,m.height) self.screen_height = min(self.screen_height,m.height)
self.screen_width = min(self.screen_width,m.width) self.screen_width = min(self.screen_width,m.width)
w = 0.95*self.screen_width/(self.width + 1 + self.linewidth) w = (self.screen_width-self.width-10)/(self.width + 1 + self.linewidth)
h = 0.95*self.screen_height/(self.height + 1 + self.linewidth) h = (self.screen_height-self.height-10)/(self.height + 1 + self.linewidth)
self.nPixCell = int(max(1,np.floor(min(w,h)))) self.nPixCell = int(max(1,np.ceil(min(w,h))))
# Total grid size at native scale # Total grid size at native scale
self.widthPx = self.width * self.nPixCell + self.linewidth self.widthPx = self.width * self.nPixCell + self.linewidth
self.heightPx = self.height * self.nPixCell + self.linewidth self.heightPx = self.height * self.nPixCell + self.linewidth
self.xPx = int((self.screen_width - self.widthPx) / 2.0)
self.yPx = int((self.screen_height - self.heightPx) / 2.0)
self.layers = [] self.layers = []
self.draws = [] self.draws = []
...@@ -99,6 +102,7 @@ class PILGL(GraphicsLayer): ...@@ -99,6 +102,7 @@ class PILGL(GraphicsLayer):
self.window = tk.Tk() self.window = tk.Tk()
self.window.title("Flatland") self.window.title("Flatland")
self.window.configure(background='grey') self.window.configure(background='grey')
self.window.geometry('%dx%d+%d+%d' % (self.widthPx, self.heightPx, self.xPx, self.yPx))
self.window_open = True self.window_open = True
def close_window(self): def close_window(self):
......
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