Panda3D Chat Room

Hi, I am trying to make a game with Panda3D with a chatroom directly below the game window. I have the server/client code written and can receive messages. One thing I am stuck on is how to use DirectGUI to make a chat window with scrolling messages. I can’t find anything in the doc that can give a hint on how to do this. Any help will be appreciated, Thank You!

Hmm… when you say that you want “scrolling messages”, do you mean that you want the player to be able to scroll back through previous messages, or simply that you want messages to come in, be pushed up (or down) by new messages, and eventually be lost?

If you want players to be able to scroll, I might suggest the use of a DirectScrolledFrame (see here). That might contain either a TextNode, it text being updated with each new message, or a series of TextNodes/DirectLabels, one per message. (I’m not sure of whether there would be any efficiency/performance issues with either approach; I’ll leave that for others to comment on, if called for.)

Yes, I want the player to scroll back to old messages. Sorry but I have no idea how to attach a textnode on a directscrolledframe, thank you for your help though!

DirectScrolledFrame, like other DirectGUI elements, is just a NodePath when it comes down to it: Given a NodePath containing your TextNode, you should be able to attach that NodePath to the ScrolledFrame (or rather, to its canvas), just as you might attach any NodePath to any other.

In short, something like this, if I’m not much mistaken:

self.myFrame = DirectScrolledFrame(<your parameters here>)

self.myTextNode = TextNode("my text node")
self.myTextNodeNP = NodePath(self.myTextNode)

self.myTextNodeNP.reparentTo(self.myFrame.getCanvas())

(Note that with the above, we haven’t yet added any text to the TextNode, so nothing will yet be visible. For testing purposes I’d suggest just adding some temporary text!)

thank you that solved my problem!

My pleasure; I’m glad to have been of service. :slight_smile: