Text in a WxPandaWindow

I can show text in a Panda-dedicated window, but the same code doesn’t seem to work for showing text in a WxPandaWindow. How can I make it work? Thanks in advance.

Here’s my working code for showing text in a Panda-dedicated window.

from direct.showbase.ShowBase import ShowBase
from panda3d.core import TextNode

class MyApp(ShowBase):
    def __init__(self):
        ShowBase.__init__(self)

        text = TextNode('test')
        text.setText("test text")
        text.setTextColor(1,0,0,1)
        textNodePath = render2d.attachNewNode(text)
        textNodePath.setPos(-1,0,0)
        textNodePath.setScale(0.5)

app = MyApp()
app.run()

And here’s my nonfunctional code for trying to show text in a WxPandaWindow.

import wx
from panda3d.core import loadPrcFileData 
loadPrcFileData("startup", "window-type none") 
import direct.directbase.DirectStart 
base.startWx() 
from direct.wxwidgets.WxPandaWindow import WxPandaWindow 
from panda3d.core import TextNode

class MainWindow(wx.Frame): 
    def __init__(self, parent): 
        wx.Frame.__init__(self, parent, -1, 'Test', size=(640,480)) 
        panel = WxPandaWindow(parent=self) 

        text = TextNode('test')
        text.setText("test text")
        text.setTextColor(1,0,0,1)
        textNodePath = render2d.attachNewNode(text)
        textNodePath.setPos(-1,0,0)
        textNodePath.setScale(0.5)

        self.Centre() 
        self.Show(True) 
        
mw = MainWindow(None) 
run()