Create Object for x amount of time

I’m sure this is on here somewhere, but I must be searching incorrectly. I want to create an object on a button press, but x amount of seconds, and then have it disappear (destroyed). Any help?

Hi! Something like:

import direct.directbase.DirectStart, direct
def createTmpObject():
  t = direct.gui.OnscreenText.OnscreenText(text='txt', pos=(0, .5))
  taskMgr.doMethodLater(2, lambda x: t.destroy(), 'destroy the tmp object')
direct.gui.DirectGui.DirectButton(text='create', scale = .08, command=createTmpObject)