base.openWindow

Hi I want to change bgcolor and other things but I do not know how to do that…

self.newWindow = base.openWindow(props=wp, gsg = None)
self.newWindow.setBackgroundColor(1,1,1)

it does not work. I’m sure I’m missing something. Can you tell me what? thanks.

setBackgroundColor should be a method of ShowBase, not of GraphicsWindow. Can you try self.setBackgroundColor(…) (if self is a ShowBase’s instance)?

You can use setClearColor:
panda3d.org/reference/pytho … 229babfbed

works perfectly rdb =D

but look, I still do not understand how self.newWindow could be treated as if it was base (ShowBase()). For instance, how to listen for mouse events? or how to load models just in self.newWindow? it is a bit confusing for me now… only the default window responds to base.accept("").

newWindow is not a ShowBase, and cannot be treated like one. But to listen for events, you only need to inherit from DirectObject (which ShowBase does, but any of your own classes can too). However, you can’t make the window inherit from DirectObject, so you can’t use newWindow.accept(). But you can use self.accept() if your own class inherits from DirectObject.

Sometimes people use base.accept() instead of self.accept() as a convenient shortcut to avoid inheriting from DirectObject.

David

Thank you for trying to help me… =D
but I can’t solve my problem (facepalm), both base.accept and self.accept work only in the default window, I’m writing a new camera control and I can’t get any key pressed or mouse click in newWindow. :confused:

Oh, that’s different. To generate button events for the new window, you need to create a new MouseWatcher and ButtonThrower for that window. Here’s a thread that illustrates doing this.

David

exactly what I needed. MouseWatcher and ButtonThrower were what I missed. I thank you David. =D