From 8883bf9bddab965106746e0200fadc1af970f6e8 Mon Sep 17 00:00:00 2001 From: rdb Date: Tue, 15 Dec 2020 11:45:52 +0100 Subject: [PATCH] dgui: Fix ability to create OnscreenGeom/Image/Text without ShowBase --- direct/src/gui/OnscreenGeom.py | 5 +++-- direct/src/gui/OnscreenImage.py | 5 +++-- direct/src/gui/OnscreenText.py | 5 +++-- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/direct/src/gui/OnscreenGeom.py b/direct/src/gui/OnscreenGeom.py index e1a35a77d1..076d18a77f 100644 --- a/direct/src/gui/OnscreenGeom.py +++ b/direct/src/gui/OnscreenGeom.py @@ -47,8 +47,9 @@ class OnscreenGeom(DirectObject, NodePath): """ # We ARE a node path. Initially, we're an empty node path. NodePath.__init__(self) - if parent == None: - parent = aspect2d + if parent is None: + from direct.showbase import ShowBaseGlobal + parent = ShowBaseGlobal.aspect2d self.setGeom(geom, parent = parent, sort = sort, color = color) diff --git a/direct/src/gui/OnscreenImage.py b/direct/src/gui/OnscreenImage.py index 3d8a9b0633..fc3487cc72 100644 --- a/direct/src/gui/OnscreenImage.py +++ b/direct/src/gui/OnscreenImage.py @@ -54,8 +54,9 @@ class OnscreenImage(DirectObject, NodePath): # We ARE a node path. Initially, we're an empty node path. NodePath.__init__(self) - if parent == None: - parent = aspect2d + if parent is None: + from direct.showbase import ShowBaseGlobal + parent = ShowBaseGlobal.aspect2d self.setImage(image, parent = parent, sort = sort) # Adjust pose diff --git a/direct/src/gui/OnscreenText.py b/direct/src/gui/OnscreenText.py index 4491c918e9..1a35152f40 100644 --- a/direct/src/gui/OnscreenText.py +++ b/direct/src/gui/OnscreenText.py @@ -104,8 +104,9 @@ class OnscreenText(NodePath): direction: this can be set to 'ltr' or 'rtl' to override the direction of the text. """ - if parent == None: - parent = aspect2d + if parent is None: + from direct.showbase import ShowBaseGlobal + parent = ShowBaseGlobal.aspect2d # make a text node textNode = TextNode('')