Skip to content

Commit 94bc65a

Browse files
committed
Fix: Prevent GUI instantiation in headless environment for GraphicsWindow
1 parent c8f6dba commit 94bc65a

1 file changed

Lines changed: 6 additions & 7 deletions

File tree

graphics/interactive_3d_renderer.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -329,8 +329,10 @@ def __init__(
329329
self,
330330
width: int = 400,
331331
height: int = 300,
332-
title: int = "Tkinter Graphics Window",
332+
title: str = "Tkinter Graphics Window",
333333
) -> None:
334+
if not (os.environ.get("DISPLAY") or os.name == "nt"):
335+
raise RuntimeError("No display detected. GUI cannot be initialized")
334336
self.root = tk.Tk()
335337
self.root.title(title)
336338
self.width = width
@@ -501,9 +503,6 @@ def render(self) -> None:
501503
Launch the interactive 3D cube renderer.
502504
A window will appear; use keyboard controls to move and rotate camera.
503505
"""
504-
# Only run GUI if display is available
505-
if os.environ.get("DISPLAY") or os.name == "nt":
506-
win = GraphicsWindow()
507-
win.mainloop()
508-
else:
509-
print("No display detected. Skipping GUI launch.")
506+
507+
win = GraphicsWindow()
508+
win.mainloop()

0 commit comments

Comments
 (0)